Results 1 to 12 of 12

Thread: get actual data from zoomed plot - how to cut a part of a curve?

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

    Default get actual data from zoomed plot - how to cut a part of a curve?

    • supposing you plot a set of x-y data.
    • Then you zoom/pan
    • and finally decide that a specific part of the curve/plot is interesting for your problem


    how can i get back this part of the plot in a double array?
    In other words, which functions should I use in order to get the data points(x,y coordinates) of the curve currently plotted?
    Any suggestions as a starting point?

    Alternatively is it possible to get the range of the axis(after I zoomed/panned), so I can go back to the initial data set and look for the specific area of x/y coordinates that are interesting to my problem?

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

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?

    Is there any qwt example close to this user case scenario?

  3. #3
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    1
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?

    hello all,
    I am new to Qwt . I am trying to Zoom my plot using QwtPlotZoomer.
    It does Zooms in but when I rightclick it resets the plot.
    What should I do to get a stepwise Zoom OUT ?

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

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?


  5. #5
    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: get actual data from zoomed plot - how to cut a part of a curve?

    Quote Originally Posted by mohini View Post
    What should I do to get a stepwise Zoom OUT ?
    The default setting is to unzoom stepwise with the middle mouse button and to unzoom completely with the right mouse button. You can change this using: QwtEventPattern::setMousePattern.

    F.e. the spectrogram example implements unzooming stepwise with the right mouse button and unzooming completely with CTRL + right mouse button the following code:

    Qt Code:
    1. zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
    2. Qt::RightButton, Qt::ControlModifier);
    3. zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
    4. Qt::RightButton);
    To copy to clipboard, switch view to plain text mode 

    The concept behind the mouse/key patterns makes it possible to implement very individual navigation models - but it is not so easy to understand.

    Uwe

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

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?

    getting back to the main subject of the post, I am still working on how to get the data points of a zoomed plot.
    I ended up to the following scenarios:

    • find an existing qwt function that returns the data points of a plot

    • get the axis values, for instance x from 100 to 1000, y from -100 to 100, and go back to the initial data set and search the data points (x,y) that are included in these limits (x:100 to 1000,y:-100 to 100)

    • get the coordinates of the rect of the qwt zoomer:

    QwtDoubleRect QwtPlotZoomer::zoomRect() const?


    which of these is the most feasible?!

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?

    I think the point you might be missing is that the QwtPlot is simply a way to display and interact with your program's data. The data itself should be kept somewhere else so you can use it to implement the kind of user interface features you are describing. The QwtPlot (and QwtPlotCurve) classes are designed from this point of view - the curve does not own the data, your application does. That is why there is a QwtData class.

    So, you need to make a connection to the QwtPlotZoomer::zoomed() signal so your application can keep track of the current zoom rect. When your user decides that "this is interesting", then it is up to your application to find out which (x,y) pairs in your data array are in the zoom rect. That's not really a Qwt problem.

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

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?

    thanks!!!I will check it out the soonest possible,
    until then...

    HAPPY NEW YEAR TO EVERYONE!!!!!!!!!!!!!!!!!!!!!!!!!!l:

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

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?

    I think the point you might be missing is that the QwtPlot is simply a way to display and interact with your program's data. The data itself should be kept somewhere else so you can use it to implement the kind of user interface features you are describing.
    I think you are right, so I tried to receive the Rect of the zoom area and then get back to the original data set:


    Qt Code:
    1. void my2dPlot::enableZoomMode(bool on)
    2. {
    3. m_zoomer->setZoomBase();
    4. m_zoomer->setEnabled(on);
    5. m_zoomer->zoom(0);
    6. d_picker->setEnabled(!on);
    7.  
    8.  
    9. QwtDoubleRect rect;
    10. rect = m_zoomer->zoomBase();
    11. leftRange = rect.x();
    12. rightRange = rect.right();
    13. }
    To copy to clipboard, switch view to plain text mode 
    (leftRange,rightRange are double private members)

    This part of code works correctly only when I click/unclick the enableZoomMode button (just like the bode example).
    Is there a way to insert these lines

    Qt Code:
    1. QwtDoubleRect rect;
    2. rect = m_zoomer->zoomBase();
    3. leftRange = rect.x();
    4. rightRange = rect.right();
    To copy to clipboard, switch view to plain text mode 

    in a different part of the code and get a realtime reaction?i.e. whenever I choose a zooming rect I get straight away the values of the rect stored?

  10. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?

    Quote Originally Posted by fatecasino View Post
    Is there a way to insert these lines

    Qt Code:
    1. QwtDoubleRect rect;
    2. rect = m_zoomer->zoomBase();
    3. leftRange = rect.x();
    4. rightRange = rect.right();
    To copy to clipboard, switch view to plain text mode 

    in a different part of the code and get a realtime reaction?i.e. whenever I choose a zooming rect I get straight away the values of the rect stored?
    Yes. Implement slots connecting to the appended() and moved() signals (these are members of the QwtPlotPicker class, from which QwtPlotZoomer is derived). You will start out getting two appended() signals when the user first clicks the mouse down. These two points will be the same, and will be the mouse position in axis coordinates. Use that as the topRight() coordinate of the zoomRect. Then, as the user drags the zoom rect, you will get a moved() signal with the updated mouse position. This is the bottomRight() coordinate of the zoom rect. You will probably need to normalize this rect, since the user can start the zoom rect anywhere and go in any direction.

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

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?

    thanks!
    after having finished studying at 7am I am off for 4 days for a trip.
    I'll be back and check this solution out!

  12. #12
    Join Date
    Feb 2010
    Location
    Cuba
    Posts
    35
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: get actual data from zoomed plot - how to cut a part of a curve?

    This is exactly what I need, get actual data from a zoomed curve. I'll see now how can I achieve it.

Similar Threads

  1. detach only one qwt plot curve?
    By kja in forum Qwt
    Replies: 1
    Last Post: 3rd December 2010, 07:54
  2. Replies: 4
    Last Post: 6th October 2010, 13:29
  3. How to plot tan(x) curve?
    By Name in forum Qwt
    Replies: 1
    Last Post: 17th September 2010, 13:20
  4. Replies: 2
    Last Post: 8th January 2010, 14:09
  5. Plotting part of a curve
    By viridis in forum Qwt
    Replies: 6
    Last Post: 21st July 2008, 08:12

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.