Results 1 to 3 of 3

Thread: Refreshtest example. How to introduce new data in the circularbuffer.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2011
    Posts
    26
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Post Refreshtest example. How to introduce new data in the circularbuffer.

    Hello,

    These days I have been trying to use the refreshtest example to plot different data (i.e. not a circular buffer) when the plot is being updated, changing the last value that is being plotted (the one which appears on the right part of the plot) by another value, for example the one I have in a QDoubleSpinBox implemented in the panel. I was able to change the last value in the buffer, but that last value is moving to the left in this way:

    (Values of the buffer and refreshplot example)

    Qt Code:
    1. At the beginning when I start the programm ([0] and [last value] are index of the buffer)
    2.  
    3. [0].................................................................................[last value]
    4.  
    5. When some timerEvent has ocurred:
    6.  
    7. .........................[last value] [0].......................................................
    8.  
    9. For example, imagine I have all 0's and one [last value] to 0.1, after some timerEvents:
    10. _
    11. _ _
    12. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _ _ _
    13.  
    14. Now, If change my QDouble Spinbox to 0.2, then, (after again some timerEvents), the same point changes:
    15.  
    16. -
    17. - -
    18. - -
    19. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    20.  
    21. However, what I would like is the following behaviour (the new value enters by the right, with value 0.1, and the 0.2 value continues moving to the left).
    22. -
    23. - - _
    24. - - _
    25. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    To copy to clipboard, switch view to plain text mode 



    This is what I do in the fill function:
    Qt Code:
    1. void CircularBuffer::fill(double interval, size_t numPoints, double ReceivedValue)
    2. {
    3. if ( interval <= 0.0 || numPoints < 2 )
    4. return;
    5.  
    6. d_values.resize(numPoints);
    7. d_values.fill(0.0);
    8.  
    9. d_step = interval / (numPoints - 2);
    10.  
    11. //MODIFY LAST POINT
    12. d_values[numPoints-1] = ReceivedValue;
    13.  
    14. d_interval = interval;
    15. }
    To copy to clipboard, switch view to plain text mode 

    It is clear that I have to modify the d_values index in another way, and I think it has something to do with the setReferenceTime of the CircularBuffer implementation. Do you have any suggestion of how to do that?

    Regards,

    -E

    PS: I thought about using the oscilloscope example as a base of my implementation, but I prefer the refreshtext example to always have the last receibed value in the right part of the plot.
    Last edited by Ethan; 25th October 2011 at 11:51. Reason: clarification

Similar Threads

  1. DockWidgetArea change and layout direction change
    By mstegehu in forum Qt Programming
    Replies: 1
    Last Post: 21st February 2012, 21:24
  2. QTableView with QSqlTableModel - change widget for edit data
    By elektrrrus in forum Qt Programming
    Replies: 3
    Last Post: 24th February 2011, 15:51
  3. Replies: 8
    Last Post: 25th April 2010, 21:19
  4. Replies: 1
    Last Post: 25th January 2010, 10:12
  5. Change database data in the QTabelView
    By sophister in forum Qt Programming
    Replies: 3
    Last Post: 9th April 2009, 16:40

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