Hi,
I have extended the class QwtPlot like the example "Oscilloscope". I must write a similar code but more simple. I have a thread "out of my control" that emit a signal each 100 msec. I have write in my custom class this slot:
void Plot::addSampledPoint(double time, double sample)
{
samples.
append(QPointF(time, sample
));
d_curve->setSamples(samples);
const QwtScaleMap xMap
= canvasMap
( d_curve
->xAxis
() );
const QwtScaleMap yMap
= canvasMap
( d_curve
->yAxis
() );
QwtSeriesData<QPointF> *data=d_curve->data();
QRectF br
= qwtBoundingRect
( *data,
0, data
->size
()-1 );
d_directPainter->setClipRegion( clipRect );
d_directPainter->drawSeries(d_curve, 0, data->size()-1);
}
void Plot::addSampledPoint(double time, double sample)
{
samples.append(QPointF(time, sample));
d_curve->setSamples(samples);
const QwtScaleMap xMap = canvasMap( d_curve->xAxis() );
const QwtScaleMap yMap = canvasMap( d_curve->yAxis() );
QwtSeriesData<QPointF> *data=d_curve->data();
QRectF br = qwtBoundingRect( *data, 0, data->size()-1 );
const QRect clipRect = QwtScaleMap::transform( xMap, yMap, br ).toRect();
d_directPainter->setClipRegion( clipRect );
d_directPainter->drawSeries(d_curve, 0, data->size()-1);
}
To copy to clipboard, switch view to plain text mode
When the samples are a QVector compatible with setSamples. I have no error but when I start the sampling I don't see anything.
P.s. If I initialize the samples when I write d_curve->attach(this) I van see the point.
Any suggest? Sorry for my simple English. (Obviously thank you at all).
Bookmarks