我如何做“实时”情节与wxMathPlot? [英] How can I make "real-time" plots with wxMathPlot?

查看:829
本文介绍了我如何做“实时”情节与wxMathPlot?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 wxMathPlot 绘制/绘制连续到达的某些数据。我想使用它绘制实时情节/图表。这是可能吗?



I.E。我不想只是一个文件的一次性读取的静态图 - 我想要的流数据绘制并继续出现在图的右侧 - (让左侧掉下/滚动视图) / p>

EDIT



我还没有得到答案。在wxmathPlot库中有一个有趣的类,名为mpFXYVector,但它只是从数据向量中绘制一个绘图。我想要的是可以喂一个流和水平滚动图表(如果需要也可以调整比例尺)。

解决方案

我认为mpFXYVector是要走的方式。



处理这个的最简单的方法可能是为mpFXYVector写一个包装类,它保存着最近数据点的FIFO缓冲区。每次新数据点到达时,将其添加到FIFO缓冲区,这将丢弃最旧的点,然后使用更新的缓冲区加载mpFXYVector。 wxMathPlot类mpWindow将会处理你需要的其余部分。



一个更优雅的方法是使用mpFXYVector的特殊化,它实现FIFO缓冲区, mpFXYVector。这样做的优点是,您只需要保存一个显示数据副本。除非你显示数千个点,否则我怀疑这个优点是值得继承mpFXYVector的额外麻烦,而不是简单地使用mpFXYVector文档化的界面。



细节,唯一棘手的比特是用新的方法Add()来替换mpFXYVector :: SetData(),以在数据点到达时添加数据点。新的方法需要管理mpFXYVector向量作为FIFO缓冲区,并重新实现代码来更新边界框(不幸的是,它并没有考虑到继承)。



结果是,专业化提供了一种具有比使用包装器更小的存储器需求和更多灵活性的解决方案。


I am thinking of using wxMathPlot for plotting/graphing some data that arrives continuously. I want to draw "Real-time" plot/graph using it. Is that possible?

I.E. I don't want just a static graph of a one-time read of a file - I want the streaming data plotted and continued out to the right of the graph - (and let the left side fall off/scroll out of view)

EDIT

I still have not gotten an answer for this. There is an interesting class in the wxmathPlot library called mpFXYVector but that appears just to draw one plot from a vector of data. What I want is something that can be fed a stream and scroll the graph horizontally (and also resize the scale if needed)

解决方案

I think mpFXYVector is the way to go.

The simplest way to deal with this might be to write a wrapper class for mpFXYVector which holds a FIFO buffer of recent data points. Each time a new datapoint arrives, add it to the FIFO buffer, which will drop the oldest point, then load mpFXYVector with the updated buffer. The wxMathPlot class mpWindow will look after the rest of what you need.

A more elegant approach would be a specialization of mpFXYVector which implements the FIFO buffer, using the simple vectors in mpFXYVector. The advantage of this would be that you are holding just one copy of the display data. Unless you are displaying many thousands of points, I doubt the advantage is worth the extra trouble of inheriting from mpFXYVector, rather than simply using the mpFXYVector documented interface.

After looking at the details, the only tricky bit is to replace mpFXYVector::SetData() with a new method Add() to add data points as they arrive. The new method needs to manage the mpFXYVector vectors as FIFO buffers, and to re-implement the code to update the bounding box ( which unfortunately was not written with inheritance in mind ).

The result is that specialization gives a solution with a smaller memory requirement and more flexibility than using a wrapper.

这篇关于我如何做“实时”情节与wxMathPlot?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆