Hi all,
I implemented my own QwtData which works with a ring buffer and is filled from a different thread than the plot.
Because the Plotter stops the plot with a QMutex before setting rawData
curveList[a]->setRawData(dataList[a].x(), dataList[a].y(), dataList[a].size());
curveList[a]->setRawData(dataList[a].x(), dataList[a].y(), dataList[a].size());
To copy to clipboard, switch view to plain text mode
everything worked fine.
void ValuePlotData::append(qint64 xValue, qint64 yValue)
{
if(currentValuecount == arraySize)
{
long newArraySize = arraySize*2;
double * d_x_new = new double[newArraySize];
double * d_y_new = new double[newArraySize];
for(int i=0;i<arraySize;i++)
{
d_x_new[i]=d_x[i];
d_y_new[i]=d_y[i];
}
delete [] d_x;
delete [] d_y;
d_x = d_x_new;
d_y = d_y_new;
arraySize = newArraySize;
}
d_x[currentValuecount] = xValue;
d_y[currentValuecount] = yValue;
currentValuecount++;
}
void ValuePlotData::append(qint64 xValue, qint64 yValue)
{
if(currentValuecount == arraySize)
{
long newArraySize = arraySize*2;
double * d_x_new = new double[newArraySize];
double * d_y_new = new double[newArraySize];
for(int i=0;i<arraySize;i++)
{
d_x_new[i]=d_x[i];
d_y_new[i]=d_y[i];
}
delete [] d_x;
delete [] d_y;
d_x = d_x_new;
d_y = d_y_new;
arraySize = newArraySize;
}
d_x[currentValuecount] = xValue;
d_y[currentValuecount] = yValue;
currentValuecount++;
}
To copy to clipboard, switch view to plain text mode
double ValuePlotData::x(size_t i) const
{
return d_x[offset+(int)i];
}
double ValuePlotData::x(size_t i) const
{
return d_x[offset+(int)i];
}
To copy to clipboard, switch view to plain text mode
Now I had to use a zoomer for the plot and problems started.
Whenever I zoom in or out there is a chance of the program crashing with a "call to pure virtual method".
After getting post mortem debugging ready I found out, that a replot was issued and it died as I believe on Calling .x() method
I initialize the zoomer with AutoReplot(false) but still it seems to crash because of that.
How do you take care of concurrency issues with your plot, because I don't think it is wise to fill from the gui thread for many new values.
Thanks in advance, this has allready cost me several hours.
sun
Bookmarks