Results 1 to 7 of 7

Thread: how to make the plot display the last curve drawn ??

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default how to make the plot display the last curve drawn ??

    Hello guys,

    How can i make the plot display the last curve i draw ??
    for example, i draw curve 1 then i draw curve two in coodinate that far a way of curve one ... now i need to zoom and look for curve2 >>>

    how can i make the plot show the last curve with out me looking for it.
    and is there away where i can click on the legend and make it move to the clicked curve ??

    Thanks

  2. #2
    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: how to make the plot display the last curve drawn ??

    Use autoscaling ( read about QwtPlot::setAxisAutoScale() ). All else you need to do is to set/unset the QwtPlotItem::AutoScale flags of your curves depending on your current context before calling replot.

    Uwe

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

    jesse_mark (9th November 2012)

  4. #3
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to make the plot display the last curve drawn ??

    I think i still doing something wrong,

    I tried doing :

    Qt Code:
    1. setAxisAutoScale(QwtPlot::xBottom);
    2.  
    3. setAxisAutoScale(QwtPlot::yLeft);
    4.  
    5. // before I call replot(), i set
    6.  
    7. myCurve->setItemAttribute(QwtPlotItem::AutoScale,true);
    To copy to clipboard, switch view to plain text mode 

    but still i have to look for the curve on the plot, could you please tell me what is the the wrong thing im doing ?

    Thanks

  5. #4
    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: how to make the plot display the last curve drawn ??

    Qt Code:
    1. myCurve1->setItemAttribute( QwtPlotItem::AutoScale, false );
    2. myCurve2->setItemAttribute( QwtPlotItem::AutoScale, true );
    3. plot->setAxisAutoScale(QwtPlot::xBottom);
    4. plot->setAxisAutoScale(QwtPlot::yLeft);
    5. plot->replot();
    To copy to clipboard, switch view to plain text mode 

    or

    Qt Code:
    1. QRectF br = myCurve2->boundingRect();
    2. plot->setAxisAutoScale(QwtPlot::xBottom, br.left(), br.right() );
    3. plot->setAxisAutoScale(QwtPlot::yLeft, br.top(), br.bottom() );
    To copy to clipboard, switch view to plain text mode 
    Uwe

  6. #5
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to make the plot display the last curve drawn ??

    thanks Uwe,

    this exactlly what i need... but the second way when i use the boundingRect for the curve,

    The method
    Qt Code:
    1. plot->setAxisAutoScale(QwtPlot::xBottom, br.left(), br.right() );
    To copy to clipboard, switch view to plain text mode 
    is not exist.

    Is it in a new version of qwt ?

  7. #6
    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: how to make the plot display the last curve drawn ??

    No, of course it is: QwtPlot::setAxisScale.

    Uwe

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

    jesse_mark (12th November 2012)

  9. #7
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to make the plot display the last curve drawn ??

    using the Auto Scale works great, but there is affects other scales.

    Let me elaborate it.

    I am using

    Qt Code:
    1. rescaler = new QwtPlotRescaler( myplot->canvas() );
    2. rescaler->setReferenceAxis( QwtPlot::xBottom );
    3. rescaler->setAspectRatio( QwtPlot::yLeft, 1.0 );
    4. rescaler->setAspectRatio( QwtPlot::yRight, 0.0 );
    5. rescaler->setAspectRatio( QwtPlot::xTop, 0.0 );
    6. rescaler->setAspectRatio( QwtPlot::xBottom, 1.0 );
    7. rescaler->setRescalePolicy( QwtPlotRescaler::Fixed );
    To copy to clipboard, switch view to plain text mode 

    this code to prevent the curve to be stretched and lose its real shape.
    but when i use the AutoScale before i replot, the curve get stretched , where i have to zoom in and out so the rescaler works and the curve gets its "unstreached shape".

    how can i fix this issue.

    Thanks

Similar Threads

  1. Plot x^2 curve
    By qt_developer in forum Qwt
    Replies: 4
    Last Post: 14th June 2012, 08:17
  2. getting attached curve to a plot
    By corrado1972 in forum Qwt
    Replies: 2
    Last Post: 22nd June 2011, 09:35
  3. detach only one qwt plot curve?
    By kja in forum Qwt
    Replies: 1
    Last Post: 3rd December 2010, 07:54
  4. How to plot tan(x) curve?
    By Name in forum Qwt
    Replies: 1
    Last Post: 17th September 2010, 13:20
  5. Replies: 2
    Last Post: 8th January 2010, 14:09

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.