Results 1 to 7 of 7

Thread: Rolling Y Axis needed

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Rolling Y Axis needed

    Hi all,

    I want to make a Yleft axis have a rolling effect . Example :

    3 -|
    2 -|
    1 -|
    0 -|

    now as you pan going up it will look,

    2 -|
    1 -|
    0 -|
    3 -|

    if you pan some more ....

    1 -|
    0 -|
    3 -|
    2 -|

    it will always keep the interval's width to be 4 in this case.

    How can I implement this? any help would be appreciated.

    -baray98-

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Rolling Y Axis needed

    A minimal approach is to implement a custom QwtScaleDraw and reimplement its label() method. Note that it will only change what is displayed on the axis, internally the values will still be taken from the original domain (e.g. double).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Rolling Y Axis needed

    thanks for the suggestion .. but i am aiming for a domain change as well meaning if my data contain a point (1,1) and my Y is showing
    0 -|
    3 -|
    2 -|
    1 -|
    0 -|
    3 -|
    2 -|
    1 -|

    I am explecting to see two points drawn.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Rolling Y Axis needed

    I'm afraid for that you need to implement a QwtScaleEngine subclass that will recalculate your scale and reimplement QwtPlotCurve::drawCurve() which is a bit of work.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    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: Rolling Y Axis needed

    Sounds like one of the QwtPlot::drawXY methods needs to be overloaded, where the overloaded draw method is called several times ( for each domain ) with different canvas maps. The maps can be build by translating the original map by the domain height.

    This height can be calculated from the original canvas map:

    Qt Code:
    1. qAbs( yMap.transform( 4 ) - yMap.transform( 0 ) ).
    To copy to clipboard, switch view to plain text mode 
    When you need to display values outside the area [0-3] you need to add some clipping code.

    But when you don't have many points it might be easier to implement your own type of plot item - but we don't have enough information to recommend how to proceed.

    Uwe

  6. #6
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Rolling Y Axis needed

    this sounds like a lot of work to me. I will consider sticking to the linear scale engine and have a translator in between my data and the yScale so my data knows what is shown and translate y values. for the label, i will do what wysota suggested on scale widget.

    thanks for the help guys

    baray98

    P.S.

    Is there any signal from scale widget when it changes it range and content?

  7. #7
    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: Rolling Y Axis needed

    Quote Originally Posted by baray98 View Post
    Is there any signal from scale widget when it changes it range and content?
    QwtScaleWidget::scaleDivChanged() - but other options are overloading QwtPlotCurve::updateScaleDiv() or QwtSeriesData::setRectOfInterest(). Depends on where your translator sits.

    Maybe it is possible to do the translation and duplication in a class derived from QwtSeriesData.

    Uwe

Similar Threads

  1. Replies: 9
    Last Post: 3rd May 2011, 21:21
  2. Replies: 2
    Last Post: 22nd April 2011, 13:38
  3. Replies: 0
    Last Post: 9th August 2010, 10:46
  4. Getting the ball rolling!!!
    By Zuks in forum Qwt
    Replies: 2
    Last Post: 2nd December 2009, 09:59
  5. Help needed
    By rohitjun in forum Qt Programming
    Replies: 3
    Last Post: 11th May 2007, 11:39

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.