仅更新图表中的一条曲线 [英] update only one curve line in graph

查看:56
本文介绍了仅更新图表中的一条曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我正在为发动机控制系统设计一个数据记录系统。



总结一下,你可以绘制一个包含多达12条曲线的图表(喷射和点火正时,以rpm和tps为单位)。

取决于传感器的位置,控制系统将选择其中一个曲线。



作为反馈,控制系统将连续(每次旋转)发送数据。

使用UI可以打开曲线在控制箱中编程。



十字准线将显示哪条曲线处于活动状态以及我们正在运行的转速。



每次旋转屏幕需要立即更新,因为它必须是实时记录器。



我现在使用

Hello All,

I am designing a data log system for an engine control system.

summarised, you can draw a graph (injection and ignition timing in function of rpm and tps) containing up to 12 curves.
depending on the position of a sensor, the control system will choose one of these curves.

as feedback, the control system will continously (every rotation) send data.
With an UI you can open the the curves that are programmed in the control box.

A crosshair will show which curve is active and at what rpm we are running.

each rotation the screen needs to be updated, without delay, since it has to be a real-time logger.

I now use

parent->RedrawWindow(graph_rect,NULL);





图表显示在父对话框中,子对话框将使用户能够选择一些视觉选项。



graph_rect是包含图形的主对话框中的CRect



这样可行,但由于rect不断更新,因此会产生闪烁效果。

不仅十字准线更新,而且整个图形(曲线,轴,图例,标题,网格......)



如果我使用



the graph is shown in the parent dialog, the child dialog will enable the user to select some visual options.

graph_rect is the CRect in the main dialog containing the graph

This works, but since the rect is continuously updating, you get a flicker effect.
As not only the crosshair is updated, but the entire graph (curves, axes, legends, title, grid,...)

if I use

parent->invalidate();



它顺利,没有闪烁,但有延迟,因为一切都会更新。

十字准线将远远落后于实际时间



我该如何避免这种情况?



提前谢谢


it goes smooth, without flicker, but there is a delay, since everything will be updated.
And the crosshair will run far behind the real timing

how can I avoid this?

Thanks in advance

推荐答案

我的建议是在内存中的位图上绘制整个图表,即使用内存DC。然后使用单个BitBlt操作将该位图复制到屏幕上。这有几个优点:



- 闪烁会消失

- 绘制到内存位图比在屏幕上绘图更快

- 如果需要,您可以轻松实现缩放



要优化此方案,您可以使用两个位图,一个用于所有不具有静态元素的位图从一个周期变为另一个周期。将该副本复制到第二个位图,在该位图中执行每周期绘制。第二个位图到屏幕的BitBlt。



详细信息我建议google一点;有许多文章和示例可供您用作模板。
My suggestion is to do the drawing of your entire diagram on bitmap in memory, i.e. with a memory DC. Then copy that bitmap over to the screen with a single BitBlt operation. This has several advantages:

- The flicker will go away
- Drawing onto a memory bitmap is way faster than drawing on the screen
- You could easily implement scaling if you need

To refine this scheme you could use two bitmaps, one for all static elements that do not change from one cycle to the next. You copy that one to a second bitmap in which you do the per-cycle drawing. The BitBlt that second bitmap to the screen.

For the details I would suggest to google a little; there are many articles and examples around which you can use as a template.


这篇关于仅更新图表中的一条曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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