Results 1 to 5 of 5

Thread: QwtPlotPanner makes plot look jumpy due to tick labels.

  1. #1
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question QwtPlotPanner makes plot look jumpy due to tick labels.

    Problem

    I have implemented the QwtPlotPanner for my plots to pan the plots around. However when I move the canvas using the panner with the axis tick labels turned on, it makes the plot look jumpy because of how the tick labels are drawn.

    From what I have noticed when the tick label is large, it is centered under the tick mark. This centering cause the plot canvas to shrink so that the plot canvas physically becomes smaller and gap between the canvas and the right side is gapped (see the gapped_plot.png attachment below).

    gapped_plot..png

    Then when you pan the plot, the gap will go away as the axis tick label moves to the left or the right (see the nongapped_plot.png attachment below).

    nongapped_plot..png

    Panning the plot quickly makes it look like the plot is jumpy and will give you a headache after awhile.

    Behind The Scenes
    I am adjusting the plot to try and have the canvas and the scales line up. Maybe this is my problem?
    Qt Code:
    1. QwtPlot::plotLayout()->setMargin(2);
    2. QwtPlot::plotLayout()->setAlignCanvasToScales(true);
    To copy to clipboard, switch view to plain text mode 

    Help Me!

    My goal is to get the canvas to stay the same size always. That means that when the tick axis label is centered under the tick mark and the label would be clipped by the edge of the plot that I don't want it to show.

    Has anyone else ran into this issue and can help me?

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

    Default Re: QwtPlotPanner makes plot look jumpy due to tick labels.

    Quote Originally Posted by amoswood View Post
    My goal is to get the canvas to stay the same size always.
    Then don't tell the layout engine explicitly to align the canvas to the scales.

    Uwe

    PS: You could set a minimumExtent to your left scale ( like in the event_filter example ) to avoid that the canvas is resized, when the number of digits for the tick labels changes.

  3. #3
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Re: QwtPlotPanner makes plot look jumpy due to tick labels.

    Quote Originally Posted by Uwe View Post
    Then don't tell the layout engine explicitly to align the canvas to the scales.
    I tried this which helps a little bit. However, the canvas doesn't move now but the scales will jump in size when there are long tick labels.

    After looking into it more, I think that I found the issue but I am unable to figure out how to figure it.

    Findings and Example Scenario:

    I have a plot which has a xBottom scale of 0 to 10000. When using even normal sized font of 10pt, the right side tick label of "10,000" uses about 50-60 pixels to display. When that label is centered under the tick mark, the right portion uses 25-30 pixels of space. Now when the QwtScaleWidget::getBorderDistHint() function gets called, it calls the QwtScaleDraw::getBorderDistHint() function and it returns the "end" parameter to be 25-30 pixels to accomodate the "10,000" tick label.

    0to10000plot..png
    Figure 1: 0 to 10000 Plot

    Now because of the long tick label and the fact that the canvas and scale widget are not aligned (see QwtPlotLayout::setAlignCanvasToScale() function), the scale goes from 0 to 10000 while the canvas displays values from about -10 to 10700. The difference is because the tick label causes the tick mark to adjust so that the label can be displayed.

    So where the "jumpy" looks comes in happens when you change the scale of the xBottom scale to be -1 to 9999. When this happens, the "10,000" tick label doesn't need to show anymore and the QwtScaleDraw::getBorderDistHint() function returns 0 for the "end" parameter. Effectively, the scale widget goes from -1 to 9999 and the canvas aligns naturally and goes from -1 to 9999. Thus, the sudden change in scale ranges for the canvas and scale widget cause it look jumpy when panning.

    -1to9999plot..png
    Figure 2: -1 to 9999 Plot

    Solutions:
    1. I would think that sub-classing from the QwtScaleDraw class to overload the getBorderDistHint() function would be the way to handle this by always passing back a 0 for the "end" parameter. However, this function is not virtual for some reason.
    2. Sub-class from the QwtScaleWidget class to hold a custom QwtScaleDraw class and work around the issue that way. I see that the QwtScaleWidget class has virtual members which makes me think that I can sub-class from it. However, I don't see a way to create or set the scale widgets in the QwtPlot class.
    3. ??? - Now I am stuck???

    Any help or ideas on how to work around this?

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

    Default Re: QwtPlotPanner makes plot look jumpy due to tick labels.

    Youal ready got the answer im my previous mail.

    Uwe

  5. #5
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotPanner makes plot look jumpy due to tick labels.

    Quote Originally Posted by Uwe View Post
    Youal ready got the answer im my previous mail.
    The only thing that the previous mail answered is that to use minimumExtent. I don't understand how to make that work.

    The difference is that I don't know if the tick label is going to be 5 pixels long or 50 pixels long and I don't want to set the minimumExtent to be 50 pixels all of the time. It seems like having the ability to make one of the methods above have a virtual function is the way to go.

    Since you, Uwe, designed and wrote it, why didn't you make some of the functions virtual like the QwtScaleDraw::getBorderDistHint() function?
    Last edited by amoswood; 10th June 2010 at 14:16. Reason: spelling corrections
    Amos
    Qt Programmer Extraordinaire

    Current Work:
    Ripxx Sports Measurement Device - www.ripxx.com
    (Featured in MYTHBUSTERS on 2010-05-19 in S08E08)

Similar Threads

  1. Graphic effects of QwtPlotPanner
    By mastupristi in forum Qwt
    Replies: 2
    Last Post: 2nd July 2019, 21:14
  2. Axis Tick Labels Overlap
    By amoswood in forum Qwt
    Replies: 3
    Last Post: 8th June 2010, 15:52
  3. y-axis tick labels trimmed
    By gib in forum Qwt
    Replies: 2
    Last Post: 2nd April 2010, 05:19
  4. Tick Labels for Slider
    By jcraig in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 17:21
  5. QSlider with a custom set of labels for the tick marks?
    By whitefurrows in forum Qt Programming
    Replies: 3
    Last Post: 5th August 2007, 16:05

Tags for this Thread

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.