我已经编写了一个模拟程序,它解决了几个方程并在OpenGL窗口中绘制结果。模拟会随着时间的推移而不断发展。我想动态添加积分。我正在使用如下代码:
QwtPlot* plot = new...;
QwtPlotCurve* plotdata = new...;
QVector<QPoint> data = getData();
plotdata->setSamples(data);
这会让情节重置所有点。我可以简单地添加积分吗?
感谢您的任何努力:-)
如果没有办法做到这一点,我很想听听。请告诉我!
使用具有
可调间隔和QSpinBox
的QTimer
怎么样?
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updatePlot()));
timer->start(5000); //adjust from GUI with timer->setInterval(newValue)
...
void updatePlot(){
// QSettings initialized somewhere
int maxSamples = settings.value("plot/maxSamples", 100).toInt();
QVector<QPoint> data = getData(maxSamples); // get this many samples
plotdata->setSamples(data);
}
我明白了。没有办法以这种抽象的方式做到这一点。但人们可以回想一下方法:
void QwtPlotCurve::setRawSamples();
使用 replot(),这将是最便宜的方法。它不涉及任何数据复制。
干杯:)