Results 1 to 4 of 4

Thread: Sorry, still get problems with QwtZoomer. Please help!

  1. #1
    Join Date
    Feb 2009
    Posts
    51
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Sorry, still get problems with QwtZoomer. Please help!

    I searched the forum for similar threads but couldn't find the answer to my problem so I post it hoping someone will help me out:

    I use QwtPlot to make a simple 2D plot (following the bode example literally word by word). There are 2 problems that I've been scratching my head for days:

    1. The zoomer cannot zoom negative range. For example, if my plot contains Y values from -30 to 200, then when I zoom selecting a rectangle to cover from Y: -30 to 50 then it just zoom to the range 0 to 50!

    2. When I hit escape key to get back to original plot, it just automatically alter my plot range to cover X values from 0 to 1000 and Y values from 0 to 1000; despite the fact that my plot has a different scale, let's say X from 0 to 50 and Y from -200 to +5000.

    Anyone, please help!

    Thanks so much
    Sincerely,

    Wieland J.

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

    Default Re: Sorry, still get problems with QwtZoomer. Please help!

    1. The zoomer cannot zoom negative range. For example, if my plot contains Y values from -30 to 200, then when I zoom selecting a rectangle to cover from Y: -30 to 50 then it just zoom to the range 0 to 50!
    Well in general a zoomer can zoom negative ranges - look at the bode example. Without knowing your code its hard to say what you did wrong.

    2. When I hit escape key to get back to original plot, it just automatically alter my plot range to cover X values from 0 to 1000 and Y values from 0 to 1000;
    This is a problem, that has been asked and answered many, many times:

    The zoomer maintains a stack of the zoom rectangles so that the user can go back and forward in the zoom history. The first entry in this stack is added, when you create the zoomer or explicitly call QwtPlotZoomer::setZoomBase().

    0-1000 is the default range of a scale. Having a zoom base of (0, 0, 1000, 1000) indicates, that you have created/initialized your zoomer before you set up your scales ( = changed the scales behind the back of the zoomer ).

    Uwe

    PS: Note, that the assignments you made to the scales are not processed until the next call of replot. In earlier versions many users ran into this trap - that's why the constructor ( or setZoomBase ) of the zoomer now has the doReplot parameter, that is set to true by default.

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

    jwieland (24th November 2010)

  4. #3
    Join Date
    Feb 2009
    Posts
    51
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Sorry, still get problems with QwtZoomer. Please help!

    That was it! I did create the zoomer before call to set axis scale (I can only do this when user input new data set and hence the scale is known). Changing the order of call fixes both problem right away and nicely.

    Thanks so much, Uwe. The fact that this question has been asked many times and that you still took the time to answer me is greatly appreciated. Thanks again and sorry for having not looked deep enough.


    Added after 30 minutes:


    Quote Originally Posted by Uwe View Post
    0-1000 is the default range of a scale. Having a zoom base of (0, 0, 1000, 1000) indicates, that you have created/initialized your zoomer before you set up your scales ( = changed the scales behind the back of the zoomer ).
    Hi Uwe,

    Although I have successfully made it work using your instruction (create the zoomer after user input data, thus every time user input data I destroy the old instance of zoomer and create a new one), I am not very happy with this approach because it seems to be a waste of system resource. I tried to reuse the zoomer and call setZoomBase() every time the scale is reset but it does not work either.

    Is there anyway I can reuse the zoomer?


    Added after 34 minutes:


    Never mind the question. I realized I made a mistake by calling setZoomBase after replot(). Again, changing the order makes it work nicely. Thanks
    Last edited by jwieland; 24th November 2010 at 15:56.
    Sincerely,

    Wieland J.

  5. #4
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Sorry, still get problems with QwtZoomer. Please help!

    i have been searching for an answer for this question, too. Supposing you want to look into detail into graph (and later use some part of it) you zoom in. If you press the zoom button again (to toggle off) then the whole plot resets making the zoomer inappropriate to use. According to posts above,
    which functions should i look into in the user case scenario that:
    1. press the zoom button (on)
    2. zoom in, several times
    3. press the zoom button off( being satisfied with the zooming so far)
    4. later I realize that i want to zoom out a bit and press again the zoom button (on)
    5. zoom out and press the zoom button (off)
    6. end


    how should i modify the bode example to make the qwt zoomer to work like this?
    Last edited by fatecasino; 18th December 2010 at 20:55. Reason: updated contents

Similar Threads

  1. Problems with QwtZoomer
    By Quereinsteiger in forum Qwt
    Replies: 2
    Last Post: 12th November 2010, 07:55
  2. Replies: 2
    Last Post: 23rd July 2010, 14:53
  3. Replies: 1
    Last Post: 16th March 2010, 09:29
  4. Replies: 1
    Last Post: 9th February 2010, 12:11
  5. Replies: 1
    Last Post: 19th May 2009, 11:14

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
  •  
Qt is a trademark of The Qt Company.