实时显示曲线

meilidexue 2008-02-22 11:38:18
横轴: A,B,C,D,E 位置固定
纵轴:A,B,C,D,E对应的时间变化(不断变化)数值来自label1.caption,label2.caption,label3.caption,label4.caption,label5.caption
如何实现在PICTURE控件里实时显示A,B,C,D,E对应纵轴坐标绘制而成的变化曲线。
...全文
235 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
guoln1010 2011-05-05
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 smalle 的回复:]
直接用line连接ABCDE各点。定时执行就行了
[/Quote]
坐标轴怎么显示?
cbm6666 2008-03-05
  • 打赏
  • 举报
回复
参考一下这个

【CBM666 的实时动态曲线图演示】

1.随机数取得数据动态往左移动(经由数据库或串口取得数据可自己修改)

2.每个页面自动保存图片(可自己增加浏览图片)

下载地址:
http://cbm666.com/curvrnd.exe

效果图:
http://hiphotos.baidu.com/cbm666/pic/item/26fdab18b5094d0d34fa4161.jpg

http://hiphotos.baidu.com/cbm666/pic/item/b7fb720e61e379c07bcbe190.jpg


shliping 2008-03-05
  • 打赏
  • 举报
回复
学习。
meilidexue 2008-02-27
  • 打赏
  • 举报
回复
smalle :你好!

你能给个事例不?
射天狼 2008-02-26
  • 打赏
  • 举报
回复
smalle 2008-02-25
  • 打赏
  • 举报
回复
直接用line连接ABCDE各点。定时执行就行了
meilidexue 2008-02-25
  • 打赏
  • 举报
回复
大家能否给个方法啊??
用户 昵称 2008-02-22
  • 打赏
  • 举报
回复
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5715
ClientLeft = 60
ClientTop = 450
ClientWidth = 8415
LinkTopic = "Form1"
ScaleHeight = 381
ScaleMode = 3 'Pixel
ScaleWidth = 561
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
BorderStyle = 0 'None
Height = 4680
Left = 90
ScaleHeight = 312
ScaleMode = 3 'Pixel
ScaleWidth = 539
TabIndex = 0
Top = 75
Width = 8085
End
Begin VB.Timer Timer1
Interval = 100
Left = 330
Top = 4980
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Const SRCCOPY = &HCC0020
Dim l As Long
Dim oldy As Long
Dim newy As Long
Private Sub Form_Load()
l = 0
Picture1.Width = 400
oldy = Picture1.Height / 3
newy = Picture1.Height / 3
End Sub

Private Sub Timer1_Timer()
Randomize Timer
newy = Picture1.Height / 3 + 100 * Rnd
If l + 20 < Picture1.Width Then
Picture1.Line (l, oldy)-(l + 20, newy)
l = l + 20
Else
BitBlt Picture1.hDC, 0, 0, Picture1.Width - 20, Picture1.Height, Picture1.hDC, 20, 0, SRCCOPY
Picture1.Line (l - 20, oldy)-(l - 1, newy)
Picture1.Refresh
End If
oldy = newy
End Sub
meilidexue 2008-02-22
  • 打赏
  • 举报
回复
只需显示现在的单一实时曲线,实时刷新!
能给个事例代码不? 很感谢阿!
用户 昵称 2008-02-22
  • 打赏
  • 举报
回复
你每次将picture的图像向一边bitblt一点,比如整幅图像左移一定的距离,在空出来的地方画上最新的数据就行了。
meilidexue 2008-02-22
  • 打赏
  • 举报
回复
楼上的不好用阿!
我的部分代码如下:

Option Explicit

Dim DataFromCom As Integer '从串口读过来的实时值
Dim DataFromComLast As Integer '上次的串口值
Dim TimeCount As Integer
dim timeline as integer

Private Sub Form_Load()
PicScale Pic '调整图像框的坐标系
PicMidleLine Pic '在图像框中画一条中线
End Sub
Private Sub PicScale(picX As PictureBox) '调整图像框的坐标系
picX.Scale (0, picX.ScaleHeight)-(picX.ScaleWidth, -picX.ScaleHeight)
End Sub

Private Sub PicMidleLine(picX As PictureBox) '在图像框中画一条中线
picX.Line (0, 0)-(picX.ScaleWidth, 0), vbGreen '画出中线
End Sub

Private Sub DrawRealLine(picX As PictureBox, TimeCountX As Integer, DataFromComX As Integer, DataFromComLastX As Integer)

If TimeCountX - 1 > 0 Then
picX.Line ((TimeCountX - 1) * 10, DataFromComLastX)-(TimeCountX * 10, DataFromComX), vbWhite
End If

End Sub

Private Sub Timer1_Timer()
timeline=val(label.caption)'label为控件数组,A,B,C,D,E对应的纵座标为其中的元素
DataFromComLast = datafromcom
DataFromCom = 3000 * timeline
TimeCount = TimeCount + 1
DrawRealLine Pic, TimeCount, DataFromCom, DataFromComLast '画出实时的曲线
End Sub
得到的曲线为连续变化曲线,不能得到对应A,B,C,D,E的时间变化的曲线(就是1楼我的提问),
如何修改阿???

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧