PDA

View Full Version : plot only subset of the data



pospiech
14th April 2008, 15:14
I have data with >1e6 entries. I want from these arrays howeve only a subset to be plotted. For example only the last 1000 entries.
To assign the data fast I use 'setRawData'

But what needs to be done to let qwt know that it shall only work with the last 1000 entries?

Matthias

Uwe
14th April 2008, 19:49
Derive from QwtData and implement your filters there.

Uwe

pospiech
14th April 2008, 21:03
Derive from QwtData and implement your filters there.

Could you direct me to an example, I could not figure out how this could be implemented.

In the meanwhile I implented the following


void QCurvePlot::setData(const unsigned int number, const double * xData, const double * yData, int start, int size)
{
if (number <= m_data.size())
{
int arraynumber = number - 1;
if (m_data[arraynumber].x != NULL )
delete [] m_data[arraynumber].x;
if (m_data[arraynumber].y != NULL )
delete [] m_data[arraynumber].y;
m_data[arraynumber].x = new double [size];
m_data[arraynumber].y = new double [size];
memcpy(m_data[arraynumber].x, xData + start, size * sizeof(double));
memcpy(m_data[arraynumber].y, yData + start, size * sizeof(double));
Curve[number].setRawData(m_data[arraynumber].x, m_data[arraynumber].y, size);
}
}

which however does not use any qwt code at all.

Matthias

Uwe
14th April 2008, 22:19
Could you direct me to an example, I could not figure out how this could be implemented.
Qwt itsself is full of examples. Look at the classes in qwt_data.h, or in the simple example. ( Passing double arrays also creates an internal QwtData object ).

If I were in your shoes I would implement a data object, that has a pointer to your original data structure holding your samples. Then you can add filters like "every 10th point" or whatever, and implement these filters easily in the virtual methods of QwtData.
In my example YourData::x(i) would return the x value from the sample 10*i from your structure.

Note, that you have to implement YourData::copy(). Here you have to copy the API - not the data itsself!

Uwe