怎样制作动态曲线图像示波器一样的
我要做一个温度—时间的曲线图,是下载控件呢?还是自己画,类似示波器,一直在更新
横坐标作为时间,纵坐标作温度
数据的来源是传感器采集的
[解决办法]
http://www.codefans.net/soft/2884.shtml 自己下个吧
[解决办法]
描点连线呗,记录上一时刻的点坐标,然后画当前点,并在两点间画直线。Point、Line方法
[解决办法]
做了个简单波形图显示程序(VB6.0)
拿去改改吧.
[解决办法]
http://topic.csdn.net/u/20080604/14/7b4ac419-0927-4df9-8c54-67d58f2507b5.html
[解决办法]
http://download.csdn.net/source/1894278方法很多,问题的关键在于怎么移动曲线,就我的简单理解给楼主例举一下:
1、使用MSChart控件绘制“http://download.csdn.net/source/1483925
2、使用PictureBox控件,结合Line方法绘制
3、使用API函数在PictrueBox上绘制
4、使用API函数在内存中绘制,然后放置到PictureBox上:http://download.csdn.net/source/2368159
[解决办法]
我有一个简单的小程序,
教材上的
Option Explicit
- VB code
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)Private Const PS_SOLID& = 0 '实线Private Const SRCCOPY& = &HCC0020Private Declare Function DeleteObject& Lib "gdi32" (ByVal hObject As Long)Private Declare Function SelectObject& Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long)Private Declare Function CreatePen& Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long)Private Declare Function Rectangle& Lib "gdi32" (ByVal hDC As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long)Private Declare Function MoveToEx& Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal lpPoint As Long)Private Declare Function LineTo& Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long)Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private dX As LongPrivate dy As LongPrivate cuX As LongPrivate cuCopyX As LongPrivate picHeigth As IntegerPrivate picWidthPrivate isGrap As IntegerPrivate MyTimeEnabld As BooleanPrivate wait As IntegerPrivate Sub Command1_Click() EndEnd SubPrivate Sub Command2_Click() isStop = Not isStopEnd SubPrivate Sub Command4_Click() If Command4.Caption = "Start" Then Command4.Caption = "Stop" Else Command4.Caption = "Start" End If If MyTimeEnabld = False Then MyTimeEnabld = True MyTimer Else MyTimeEnabld = False End IfEnd SubPrivate Sub Form_Load() Height = 3300: Width = 5475 Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2 setValue isGrap = 1 HScroll1.Value = 5 End SubSub setValue() Dim dl& form1.ScaleMode = vbPixels Picture1.ScaleMode = vbPixels Picture2.ScaleMode = vbPixels Picture1.AutoRedraw = True Picture2.AutoRedraw = False picHeigth = Picture2.Height picWidth = Picture2.Width - 5 dy = Picture2.Height \ 2 dX = picWidth cuCopyX = 0 dl& = MoveToEx(Picture1.hDC, dX, dy, 0&)End SubPrivate Sub Form_Unload(Cancel As Integer) EndEnd SubPrivate Sub HScroll1_Change()wait = HScroll1.ValueLabel1.Caption = HScroll1.ValueEnd SubPrivate Sub Option1_Click(Index As Integer) Picture1.Cls setValue isGrap = IndexEnd SubPrivate Sub MyTimer() Do Select Case isGrap Case 0 Grap MyRnd() Case 1 Grap MySin() Case 2 Grap Xx() Case 3 Grap Pulse() End Select Sleep wait DoEvents If MyTimeEnabld = False Then Exit Do End If LoopEnd SubSub Grap(cuY As Long) Dim dl& Dim pen&, oldpen& If cuY < 0 Then cuY = 0 If cuY > picHeigth Then cuY = picHeigth cuX = dX + 1 cuCopyX = cuCopyX + 1 If cuCopyX > picWidth Then dX = picWidth cuX = dX + 1 cuCopyX = 1 Picture1.Cls dl& = MoveToEx(Picture1.hDC, dX, dy, 0&) dl& = BitBlt(Picture1.hDC, 0, 0, picWidth, picHeigth, Picture2.hDC, 0, 0, SRCCOPY) End If pen& = CreatePen(PS_SOLID, 1, RGB(255, 0, 0)) oldpen& = SelectObject(Picture1.hDC, pen&) dl& = LineTo(Picture1.hDC, cuX, cuY) dl& = SelectObject(Picture1.hDC, oldpen&) dl& = DeleteObject(pen&) dl& = BitBlt(Picture2.hDC, 0, 0, picWidth, picHeigth, Picture1.hDC, cuCopyX, 0, SRCCOPY) dy = cuY: dX = dX + 1 If dy > 200 Then StopEnd Sub'/////////////////////////////////Function MyRnd() As Long MyRnd = Rnd() * picHeigthEnd FunctionFunction MySin() Static Radim As Integer MySin = Sin(Sin(Radim * 3.1426 / 180)) * picHeigth \ 2 + picHeigth \ 2 Radim = Radim + 4 If Radim > 360 Then Radim = 0End FunctionFunction Xx() Static x As Integer Xx = x * x / 50 x = x + 1 If x = 100 Then x = 0End FunctionFunction Pulse() Static x As Integer Static y As Integer If x < 10 Then y = y + 1 Pulse = 25 If y > 50 Then x = 20 End If Else y = y - 1 Pulse = 125 If y < 0 Then x = 0 End If End If End Function
[解决办法]
可以用TeeChart
功能比较多
[解决办法]
应该是要用TChart控件和Timer定时器来实现,但是要注意刷新频率等一些问题,以前拿Delphi做过一个,频率做不好曲线就一直在闪,还有一搬要是串口通讯的话最好是下一个Mscommom第三方串口控件或者是Spcom(不知道拼对没有,呵呵英语不好)。