After
redCurve.setRawData(xval,redCurveData,size);
greenCurve.setRawData(xval,greenCurveData,size);
redCurve.setRawData(xval,redCurveData,size);
greenCurve.setRawData(xval,greenCurveData,size);
To copy to clipboard, switch view to plain text mode
you don't need the previous samples anymore (it seems) so you can call freeData() after that, of course delaying assign of new pointers until after the free of old data:
void Dialog::getData()
{
int size = 1+rand()%10 + 10;
double* redCurveDataPtr = new double[size];
double* greenCurveData = new double[size];
double* xval = new double[size];
for(int i = 0; i < size; i++)
{
redCurveData[i] = 0+rand()%10;
greenCurveData[i] = 0+rand()%10;
xval[i] = i + 1;
}
redCurve.setRawData(xval,redCurveData,size);
greenCurve.setRawData(xval,greenCurveData,size);
// old data is no more needed now
freeData();
// now we can add newly created samples pointers
samplesPtr << redCurveDataPtr << greenCurveData << xval;
plot
->setAxisScale
(QwtPlot::xBottom,
1, size
);
plot
->setAxisScale
(QwtPlot::yLeft,
0,
10);
drawCurves();
}
void Dialog::getData()
{
int size = 1+rand()%10 + 10;
double* redCurveDataPtr = new double[size];
double* greenCurveData = new double[size];
double* xval = new double[size];
for(int i = 0; i < size; i++)
{
redCurveData[i] = 0+rand()%10;
greenCurveData[i] = 0+rand()%10;
xval[i] = i + 1;
}
redCurve.setRawData(xval,redCurveData,size);
greenCurve.setRawData(xval,greenCurveData,size);
// old data is no more needed now
freeData();
// now we can add newly created samples pointers
samplesPtr << redCurveDataPtr << greenCurveData << xval;
plot->setAxisScale(QwtPlot::xBottom, 1, size);
plot->setAxisScale(QwtPlot::yLeft, 0, 10);
drawCurves();
}
To copy to clipboard, switch view to plain text mode
Bookmarks