
Originally Posted by
kuzulis
Do you mean to use the set of setSamples() methods?
No:
class YourData: public QwtSeriesData<QPointF>
{
virtual size_t size() const override
{
return ...;
}
virtual QPointF sample
( size_t i
) const override
{
return ...;
}
virtual QRectF boundingRect
() const override
{
// be careful with not introdicing a performance bottleneck here
// better calculate it in advance an cache it
return ...;
}
};
curve->setData( new YourData() );
class YourData: public QwtSeriesData<QPointF>
{
virtual size_t size() const override
{
return ...;
}
virtual QPointF sample( size_t i ) const override
{
return ...;
}
virtual QRectF boundingRect() const override
{
// be careful with not introdicing a performance bottleneck here
// better calculate it in advance an cache it
return ...;
}
};
curve->setData( new YourData() );
To copy to clipboard, switch view to plain text mode
It's totally up to you how these methods are implemented, but I guess they return values from some custom buffer. How these values come to this buffer is up the the application, Qwt does not see it.
Qt containers are implicitly shared: see http://doc.qt.io/qt-5/implicit-sharing.html.
So if you load your values only for the purpose of displaying it on the plot using a QPolygonF + setSamples is just fine. The only thing you could consider is to call setSamples( QPolygonF() ) before loading a new set of samples. Otherwise you need memory for 2 buffers until you can pass the new one in.
Uwe
Bookmarks