简体   繁体   English

通过Gnuplot的管道接口从C / C ++可视化

[英]Visualization from C/C++ via Gnuplot's pipe interface

I am attempting to use the pipe interface to gnuplot (a standard one gnuplot_i.{cpp,hpp}) in order to generate a real time display of values that are continually changing within another program written in C++. 我试图将管道接口用于gnuplot(标准的一个gnuplot_i。{cpp,hpp}),以便生成在C ++编写的另一个程序中不断变化的值的实时显示。 This works ok but I wanted to see if anyone had any suggestions for improvement. 这项工作正常,但我想知道是否有人有任何改进建议。

This implementation contains a convenience method to plot a single vector and 2 vectors as a 2D plot. 该实现包含将单个矢量和2个矢量绘制为2D图的便利方法。 It achieved this by writing out to a temporary file via a standard library call to the mktemp function and then using that as input to a gnuplot plot call. 它是通过对mktemp函数的标准库调用写出临时文件,然后将其用作gnuplot plot调用的输入来实现的。 This generated too many temporary files and didn't appear to work well when the update rate on the plot is high (maybe IO limited at a point). 这会生成太多临时文件,并且当绘图上的更新速率很高(可能IO限制在某一点)时似乎不能正常工作。 I have decided to use the '-' pseudo file in the plot call and just send the vectors directly to the pipe (ended with a single line with "e" on it). 我决定在绘图调用中使用' - '伪文件,然后将向量直接发送到管道(以一行“e”结束)。 This works better but is still not great. 这效果更好,但仍然不是很好。

Is there a slicker way to do what I am attempting to do than to continually regenerate the plot when the values have changed? 有没有一种巧妙方式做什么,我试图做的比不断再生的情节,当值发生了变化? How often is it safe to update the plot with new information? 多久是安全的更新与新的信息的情节? Alternatively, maybe there's a much simpler way to achieve what I am trying to do? 或者,也许有一种更简单的方法来实现我想要做的事情?

@Andy Ross @Andy Ross

I have no "requirements" per se. 我本身没有“要求”。 What I meant by slick was that maybe there was a more elegant approach to doing what I was attempting while still using gnuplot. 浮石的意思是,在使用gnuplot时,可能有一种更优雅的方法来做我正在尝试的东西。 Although elegant is subjective, I find the approach I am presently taking particularly inelegant. 虽然优雅是主观的,但我发现我目前采取的方法特别不优雅。 What I meant by safe was whether anyone knew at what update rate there would be IO problems (eg, latency, lock-up of display, etc.) with said approach. 我所说的安全之处在于,是否有人知道在采用所述方法的IO问题(例如,延迟,显示器锁定等)的更新速率。

I'd like to avoid using a toolkit for the following reasons (my short-list at least). 我想避免使用工具包,原因如下(至少我的短名单)。

  • I have found that they are generally nontrivial to install properly on different architectures especially as non-root (and when they require dependencies that aren't standard across OSes). 我发现在不同的体系结构上安装它们通常是非常重要的,特别是作为非root用户(当它们需要跨操作系统不是标准的依赖时)。
  • They incur an additional compilation dependency for other people using this software. 它们会对使用此软件的其他人产生额外的编译依赖性。
  • There doesn't appear to be any real standard that most people use for this purpose afiak (myself as well as most people I work with generally just saves off log type files and does post run analysis in MATLAB). 大多数人似乎没有任何真正的标准用于此目的(我自己以及我工作的大多数人通常只保存日志类型文件并在MATLAB中进行运行后分析)。
  • I know/learning gnuplot syntax. 我知道/学习gnuplot语法。 I do not know superPlottingApiXX's syntax. 我不知道superPlottingApiXX的语法。
  • The feature set of gnuplot is almost ideal for the types of things I'd like to be able to do with this software. gnuplot的功能集几乎适用于我希望能够使用此软件的各种类型的东西。

However, if you have any particular suggestions in terms of C/C++ plotting libraries that seem like a good fit given the above list I am always interested in suggestions (warning: I have already looked around a good bit to find them). 但是,如果您对C / C ++绘图库有任何特别的建议,考虑到上面的列表似乎很合适,我总是对建议感兴趣(警告:我已经找了很多东西找到它们)。

gnuplot-cpp is an object-oriented C++ wrapper interface around a POSIX pipe connection with Gnuplot. gnuplot-cpp是一个面向对象的C ++包装器接口,围绕与Gnuplot的POSIX管道连接。

The example file compiled right away and the interfacing code looks decent; 立即编译示例文件,接口代码看起来不错; I'll be trying it in my current project. 我将在我目前的项目中尝试它。

there is a C2gnuplot library I wrote few years ago. 我几年前写过一个C2gnuplot库。 It is very simple but may give you some tips. 这很简单,但可能会给你一些提示。 Basically it uses FIFO files to pass data into Gnuplot.It is able to generate animation from the plots. 基本上它使用FIFO文件将数据传递到Gnuplot.It能够从图中生成动画。 Here is a video created with the app. 是使用该应用程序创建的视频。 I hope this will be useful for you. 我希望这对你有用。

Slicker? 雨衣? Safe? 安全? Can you be more specific about your requirements? 你能更具体地了解你的要求吗?

It sounds like you are trying to do an animated visualization with a tool designed for generating static images. 听起来您正在尝试使用专为生成静态图像而设计的工具进行动画可视化。 If your display is as simple as you say, why not write a quick GUI app (using the toolkit of your choice) to do the drawing instead? 如果您的显示器如您所说的那样简单,为什么不编写一个快速的GUI应用程序(使用您选择的工具包)来进行绘图呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM