Results 1 to 7 of 7

Thread: How to rescale the QwtPlotZoomer->canvas

Hybrid View

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

    Default Re: How to rescale the QwtPlotZoomer->canvas

    There are only two ways how an axis scale can be set:
    • explicitly by setAxisScale or setAxisScaleDiv
    • implicitely by the auto scaler

    Autoscaling is enabled in the default setting of QwtPlot and executed each time replot ( updateAxes ) is called. As soon as you explicitly assign a scale autoscaling gets disabled until you re-enable it with setAxisAutoScale().

    The zoomer doesn't have a different API for setting the scales - all it can do is to use setAxisScale. So whenever the zoomer changes a scale autoscaling gets disabled.

    When you add a new curve and want to run the autoscaler again you have to do:

    Qt Code:
    1. plot->setAxisAutoScale( axisId, true );
    2. plot->replot();
    To copy to clipboard, switch view to plain text mode 
    Usually you don't want to keep a zoom stack ( the history of the zoom rectangles ) starting with the scales from your previous
    run of the autoscaler. To reinitialize the zoomer with the new scales you have to do:

    Qt Code:
    1. doReplot = false;
    2. zoomer->setZoomBase( doReplot );
    To copy to clipboard, switch view to plain text mode 
    The mystery behind the doReplot flag is, that setAxisScale/setAxisAutoScale only assign the parameters for the calculation of the new scale, but the scales are calculated later ( replot/updateAxes ). So you have to do a replot before you reinitialize the zoomer to avoid, that it gets initialized with the previous scales.

    In the code snippet above doReplot is set to false. This is only done because you already did the the replot above and you don't need to do it twice.

    Uwe

  2. The following user says thank you to Uwe for this useful post:

    revellix (7th October 2011)

  3. #2
    Join Date
    Jul 2011
    Posts
    26
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to rescale the QwtPlotZoomer->canvas

    Thanks, now I got it.

    Another little question: is it possible to change the MajorTickLabels manually ? F.e. I want the Unit to be at the next to last MajorTick .... xAxisTicks[ 0 1 2 µm 3 ] ?

  4. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to rescale the QwtPlotZoomer->canvas

    Overload QwtScaleDraw::drawLabel, you can decide here what is displayed over the major ticks.

  5. The following user says thank you to Spitfire for this useful post:

    revellix (7th October 2011)

  6. #4
    Join Date
    Jul 2011
    Posts
    26
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to rescale the QwtPlotZoomer->canvas

    this one is too hard for me now ... too noobish

Similar Threads

  1. QwtPlotZoomer zooming off the plot canvas
    By BettaUseYoNikes in forum Qwt
    Replies: 1
    Last Post: 26th June 2011, 11:38
  2. Replies: 1
    Last Post: 13th May 2011, 18:12
  3. Replies: 1
    Last Post: 7th March 2011, 08:34
  4. Replies: 0
    Last Post: 9th August 2010, 10:46
  5. Automatic rescale QwtPlotMarker
    By gpsgek in forum Qwt
    Replies: 0
    Last Post: 23rd May 2010, 16:26

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.