How to avoid linking both ends of a Curve Plot
Hello, I'm trying to implement a continuous plot application that has two main guidelines:
- when the plot reaches the end it must start to refresh the existing data from the start
- there must be a gap between the new data being fed to the plot and the data that gets erased
I managed to successfully maintain the gap between the new data and the old data using something like this:
Code:
m_mainData->takeFirst();
m_mainData->append(yValue);
the first time I reach the end of the screen I just delete some extra data from the start of the array and with it I guarantee that I'll always have that gap.
now ... the problem I'm facing is when the plot reaches the end and starts over, the plot interpolates the last point with the first one and visually I see a horizontal line that appears at different locations in relation to the last data point. My first idea was to try to plot the last and first data points off-screen so that the lines is not visible, but I don't see it as a clean approach and I may also have some cases where the line manages to appear since it depends on the data.
Any ideas on how I can manage to separate the last data point on screen with the first one painted? I'm using a left to right sweep for plotting, the signal type is the same as a medical electrocardiograph parameter for reference.
Thanks in advance
Re: How to avoid linking both ends of a Curve Plot
I'd try using two curves. First time through, add data to curve 1. When curve 1 reaches the end, start adding data to curve 2. At the same time, remove points from curve 1 to create the gap, then for each new point you add to curve 2, take one from the start of curve 1 to maintain the gap. When curve 1 has no more points, you have reached the end and now you start the process again by flipping curves.
Re: How to avoid linking both ends of a Curve Plot
Quote:
Originally Posted by
d_stranz
I'd try using two curves. First time through, add data to curve 1. When curve 1 reaches the end, start adding data to curve 2. At the same time, remove points from curve 1 to create the gap, then for each new point you add to curve 2, take one from the start of curve 1 to maintain the gap. When curve 1 has no more points, you have reached the end and now you start the process again by flipping curves.
thanks for the answer, that was my initial approach too, the application I'm developing uses 6 chart objects on screen and I felt having 12 charts at one point could be optimized. I started noticing some issues in performance when the application was running for 1 or 2 days non stop, but I could give it another go and see.
Re: How to avoid linking both ends of a Curve Plot
Quote:
I started noticing some issues in performance when the application was running for 1 or 2 days non stop
Then I'd suggest you start looking for a memory leak. It could also be that even if you don't have a leak, the constant modification of the curve data (and array length) is causing memory fragmentation. In that case, I would look at using fixed-length arrays where instead of adding or removing points, you simply give a different starting position and number of points by manipulating the pointers you send to the curve plot.
Re: How to avoid linking both ends of a Curve Plot
Quote:
Originally Posted by
d_stranz
Then I'd suggest you start looking for a memory leak. It could also be that even if you don't have a leak, the constant modification of the curve data (and array length) is causing memory fragmentation. In that case, I would look at using fixed-length arrays where instead of adding or removing points, you simply give a different starting position and number of points by manipulating the pointers you send to the curve plot.
okay, I'll keep it in mind, I'll test again first removing and adding points and if I notice something odd I'll fallback to using a pointer, thanks !!!
Re: How to avoid linking both ends of a Curve Plot
You could inherit from QwtSeriesData. Inside you would have an array of points and a start index. When a new point arrives you simply replace the point at the index and increment the index.
Then all you have to do is to reimplement the sample method in a way, that the start index is taken into count.
Or something similar along this idea
HTH,
Uwe