Results 1 to 2 of 2

Thread: Qwt 6.1.2 dynamic axis dimension

  1. #1
    Join Date
    Jun 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qwt 6.1.2 dynamic axis dimension

    Hi everybody,

    I'm having an issue with the last version of Qwt.
    I'm receiving data in real time, communicating with a robot and i want to plot dynamcally the data on the fly. So I want my yLeft and xBottom axises to change their values dynamically. If the x coordinate of my new point is inferior to my xBotton axis lower bound, it becomes its new lower bound etc ..
    I didn't have trouble to do this in previous versions of Qwt using this sample of code : (x and y being the coordinates of the data i receive in real time )

    Qt Code:
    1. if(x < myPlot->axisScaleDiv(QwtPlot::xBottom)->lowerBound())
    2. {
    3. if(x < 0)
    4. {
    5. myPlot->setAxisScale(QwtPlot::xBottom,myPlot->axisScaleDiv(QwtPlot::xBottom)->lowerBound()+x-0.02, \
    6. myPlot->axisScaleDiv(QwtPlot::xBottom)->upperBound());
    7. }
    8. else
    9. {
    10. myPlot->setAxisScale(QwtPlot::xBottom,myPlot->axisScaleDiv(QwtPlot::xBottom)->lowerBound()-x-0.02, \
    11. myPlot->axisScaleDiv(QwtPlot::xBottom)->upperBound());
    12. }
    13.  
    14. }
    15. else if(x > myPlot->axisScaleDiv(QwtPlot::xBottom)->upperBound())
    16. {
    17. myPlot->setAxisScale(QwtPlot::xBottom,myPlot->axisScaleDiv(QwtPlot::xBottom)->lowerBound(), \
    18. myPlot->axisScaleDiv(QwtPlot::xBottom)->upperBound()+x+0.02);
    19. }
    20. if(y < myPlot->axisScaleDiv(QwtPlot::yLeft)->lowerBound())
    21. {
    22. if(y < 0)
    23. {
    24. myPlot->setAxisScale(QwtPlot::yLeft,myPlot->axisScaleDiv(QwtPlot::yLeft)->lowerBound()+y-0.02, \
    25. myPlot->axisScaleDiv(QwtPlot::yLeft)->upperBound());
    26. }
    27. else
    28. {
    29. myPlot->setAxisScale(QwtPlot::yLeft,myPlot->axisScaleDiv(QwtPlot::yLeft)->lowerBound()-y-0.02, \
    30. myPlot->axisScaleDiv(QwtPlot::yLeft)->upperBound());
    31. }
    32.  
    33. }
    34. else if(y > myPlot->axisScaleDiv(QwtPlot::yLeft)->upperBound())
    35. {
    36. myPlot->setAxisScale(QwtPlot::yLeft,myPlot->axisScaleDiv(QwtPlot::yLeft)->lowerBound(), \
    37. myPlot->axisScaleDiv(QwtPlot::yLeft)->upperBound()+y+0.02);
    38. }
    To copy to clipboard, switch view to plain text mode 

    This code worked pretty well, but my problem is that in qwt 6.1.2 you don't access the scale divisions of an axis with a pointer anymore. So this sample of code still works but it lags a lot, and it didn't with pointers.. Is there a simpler way, more memory efficient to do this in qwt 6.1.2 ? Did i miss something with dynamic axises ?

    Thanks for your help

  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: Qwt 6.1.2 dynamic axis dimension

    Quote Originally Posted by etienne1234 View Post
    This code worked pretty well, but my problem is that in qwt 6.1.2 you don't access the scale divisions of an axis with a pointer anymore.
    It's a reference now what should be of no difference memory- or performancewise, beside you make a copy in your code. But even when copying a QwtScaleDiv object to a local variable this shouldn't be such an expensive operation as the tick labels are stored in a QVector, what is implicitly shared ( depends of course on how often you call it ). By the way: if you want to have a local copy better use QwtPlot::axisInterval() - what returns the boundaries without the ticks.

    Guess the code below should be even faster than the one you have posted ( beside the compiler does some magic to avoid retrieving the QwtScaleDivs several times ):

    Qt Code:
    1. const QwtScaleDiv& xScaleDiv = myPlot->axisScaleDiv(QwtPlot::xBottom);
    2. const QwtScaleDiv& yScaleDiv = myPlot->axisScaleDiv(QwtPlot::yLeft);
    3. if( x < xScaleDiv.lowerBound() )
    4. {
    5. ....
    6. }
    7. ...
    To copy to clipboard, switch view to plain text mode 

    If there is still a performance issue it is probably not because of how you update the boundaries of the scale in the code above.

    Just a hint: I would update the bounding rectangle of the curve and then sync the axes with the bounding rectangle ( using the autoscaler or manually like in the method above ). You can avoid that the curve has to iterate over all points later to find out its bounding rectangle, when you run on an operation, where it is used.

    Uwe

Similar Threads

  1. Axis Title to axis label alignment
    By ROCKSTAR in forum Qwt
    Replies: 0
    Last Post: 5th February 2014, 13:47
  2. Qwt dynamic x axis labels
    By K4ELO in forum Qwt
    Replies: 4
    Last Post: 15th March 2013, 22:06
  3. Replies: 0
    Last Post: 29th March 2012, 20:56
  4. Replies: 9
    Last Post: 3rd May 2011, 22:21
  5. Replies: 0
    Last Post: 9th August 2010, 11:46

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.