需要快速c++ qt/qwt 散点图
我有大量 2D 点(大约 300 万对),我需要在基于 Qt 的应用程序中以合理的速度进行渲染。
我尝试过使用 QGraphicsScene,但即使在 400000 个图元上它也非常慢,所以我正在研究 qwt 库。
它的 sourceforge 页面上有一个 散点图示例屏幕截图,它看起来正是我所需要的,但我既找不到任何可用于此数据的实际代码,也找不到 qwt 文档中的相应 API - 它只提到了不同类型的曲线。
因此,最好能获得一些有关散点图示例的指导以及有关其性能的一些建议。 也欢迎提出其他可以处理如此大量数据的与 c++ qt 兼容的绘图库的建议。
I have a huge array of 2D points (about 3 millions of pairs), which I need to render with reasonable speed in a Qt-based application.
I've tried using QGraphicsScene
, but its very slow even on 400000 primitives, so I was looking into the qwt library instead.
It has a scatter plot example screenshot on its sourceforge page, which looks like exactly what I need, but I cannot find neither any kind of actual code that can be used for this data, nor an according API in qwt docs - it mentions only different types of curves.
So it would be good to get some pointers for scatter plot examples and some advice on its performance.
Suggestions for other c++ qt-compatible plotting libraries which can cope with this amount of data are also welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
散点图包含在“realtime”示例中:您需要的是
IncrementalPlot
类。我还建议绘制所有 300 万个点是不合理的,因为现代屏幕只有大约 200 万个像素:) 因此,最好预先通过将相邻点合并为一个阈值来简化绘图,该阈值取决于缩放系数。
Scatter plot is contained in the "realtime" example: what you want is the
IncrementalPlot
class.I'd also suggest that drawing all the 3 million points isn't reasonable, since modern screens have only about 2 million pixels :) Thus it seems better to simplify the plot beforehand by merging the adjacent points into one with a threshold dependent on the zoom factor.
正如 viens 指出的,生成 300 万个点的散点图可能不是一个好主意。
我使用 OpenGL 生成 30.000 点的 3D 散点图,取得了良好的性能。
OpenGL 速度很快并且与 Qt 集成良好。然而,它是一个低级 API,迫使您进行大量繁琐的编码。
VTK 可能是另一种选择。
As viens pointed out, generating scatter plots with 3 million points is probably not a good idea.
I have achieved good performance generating 3D scatter plots with 30.000 points using OpenGL.
OpenGL is fast and integrates well with Qt. However, it is a low level API that forces you to do a lot of tedious coding.
VTK may be another option.
MathGL 是免费的 (GPL) 跨平台绘图库。它是用 C++ 编写的,并有 Qt 小部件。而且它的速度相当快,但是 300 万个点……在我的笔记本电脑上绘制大约需要 30 秒。
MathGL is free (GPL) cross-platform plotting library. It was written in C++ and have Qt widget. Also it is rather fast, but 3 millions points ... it take about 30 seconds to plot in my laptop.
您建议像 @vines 所说的那样使用 OpenGL,特别是利用或显示列表
glGenList
或顶点缓冲区。几百万个点作为基元顶点应该不那么困难。You'd suggest using OpenGL as @vines said, and in particular exploiting or display lists
glGenList
or vertex buffers. Some million points as primitives vertices shouldn't be that difficult.