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)
At the beginning when I start the programm ([0] and [last value] are index of the buffer)
[0].................................................................................[last value]
When some timerEvent has ocurred:
.........................[last value] [0].......................................................
For example, imagine I have all 0's and one [last value] to 0.1, after some timerEvents:
_
_ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _ _ _
Now, If change my QDouble Spinbox to 0.2, then, (after again some timerEvents), the same point changes:
-
- -
- -
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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).
-
- - _
- - _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
At the beginning when I start the programm ([0] and [last value] are index of the buffer)
[0].................................................................................[last value]
When some timerEvent has ocurred:
.........................[last value] [0].......................................................
For example, imagine I have all 0's and one [last value] to 0.1, after some timerEvents:
_
_ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _ _ _
Now, If change my QDouble Spinbox to 0.2, then, (after again some timerEvents), the same point changes:
-
- -
- -
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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).
-
- - _
- - _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
To copy to clipboard, switch view to plain text mode
This is what I do in the fill function:
void CircularBuffer::fill(double interval, size_t numPoints, double ReceivedValue)
{
if ( interval <= 0.0 || numPoints < 2 )
return;
d_values.resize(numPoints);
d_values.fill(0.0);
d_step = interval / (numPoints - 2);
//MODIFY LAST POINT
d_values[numPoints-1] = ReceivedValue;
d_interval = interval;
}
void CircularBuffer::fill(double interval, size_t numPoints, double ReceivedValue)
{
if ( interval <= 0.0 || numPoints < 2 )
return;
d_values.resize(numPoints);
d_values.fill(0.0);
d_step = interval / (numPoints - 2);
//MODIFY LAST POINT
d_values[numPoints-1] = ReceivedValue;
d_interval = interval;
}
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.
Bookmarks