Results 1 to 3 of 3

Thread: set auto scaling without calling setRawSamples multiple times

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default set auto scaling without calling setRawSamples multiple times

    Hello!

    Recently I was with a problem regarding doing scaling of a QwtPlot in a real-time plotting graph using setRawSamples called just once (discussion was done here¹). One thing I learned with Uwe on that thread was that, without calling the setData() method, I couldn't use auto scaling since the Qwt system wouldn't be aware that the curve's data had changed.

    Well things have changed since then and now I don't have to do real time plotting anymore, but I still want to avoid calling setRawSamples() each second when the QwtPlot needs to be reploted (the reason is code "clarification" and efficiency), which would seem to mean that I'll have to reimplement QwtPlotCurve::boundingRect() as discussed on that topic.

    The point I was thinking was: since I don't have to optimize the bounding rect calculation as previously discussed, I could very well use the same system setData() uses to do the axis recalculation, calling it each time I need to replot my graph (but again without calling setData/setRawData). I went, then, to the setData() method which is

    Qt Code:
    1. if ( d_series != series )
    2. {
    3. delete d_series;
    4. d_series = series;
    5. dataChanged();
    6. }
    To copy to clipboard, switch view to plain text mode 

    and figured out that probably the dataChanged() was the method I needed to call before doing the QwtPlot::replot(). I went after it and discovered that it is a pure virtual method from the QwtAbstractSeriesStore class that is defined in QwtPlotSeriesItem (and only here) as being

    Qt Code:
    1. void QwtPlotSeriesItem::dataChanged()
    2. {
    3. itemChanged();
    4. }
    To copy to clipboard, switch view to plain text mode 

    while itemChanged() is

    Qt Code:
    1. void QwtPlotItem::itemChanged()
    2. {
    3. if ( d_data->plot )
    4. d_data->plot->autoRefresh();
    5. }
    To copy to clipboard, switch view to plain text mode 

    In other words, everything I needed to do, seems to me, was to do my reploting this way:

    Qt Code:
    1. //update curve's data without calling setRawData again
    2.  
    3. myPlot->autoRefresh();
    4. myPlot->replot();
    To copy to clipboard, switch view to plain text mode 

    or equivalent
    Qt Code:
    1. foreach (QwtPlotCurve* const poCurve, curveList)
    2. {
    3. poCurve->itemChanged();
    4. }
    5.  
    6. myPlot->replot();
    To copy to clipboard, switch view to plain text mode 

    Well, I did this and it didn't work the auto scaling is not working. What did I miss?


    Thanks,

    Momergil

    ¹: http://www.qtcentre.org/threads/5903...rking?p=262516
    Last edited by Momergil; 14th May 2014 at 13:09.
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: set auto scaling without calling setRawSamples multiple times

    Although some time passed and I somehow pass over this problem, I'm sill curious for an answer, so... moving up!
    May the Lord be with you. Always.

  3. #3
    Join Date
    Dec 2013
    Location
    Toronto, Canada
    Posts
    62
    Thanked 16 Times in 15 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: set auto scaling without calling setRawSamples multiple times

    //update curve's data without calling setRawData again
    Do you mean somehow assigning a new/updated series?

    myPlot->autoRefresh();
    myPlot->replot();
    It is not usual to follow a call to autoRefresh() by a call to replot()... if autoReplot() is true, autoRefresh() calls replot().

Similar Threads

  1. Plot auto-scaling
    By ccbaci in forum Qwt
    Replies: 3
    Last Post: 14th September 2013, 10:59
  2. Y axis not auto scaling
    By pkj in forum Qwt
    Replies: 0
    Last Post: 12th May 2011, 16:05
  3. Replies: 3
    Last Post: 26th October 2009, 19:11
  4. QLabel - auto font scaling possible?
    By Byngl in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2007, 16:50
  5. Replies: 5
    Last Post: 6th March 2007, 05:34

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.