home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1998 October / DPPCPRO1098.ISO / Ocx / VCFIMP / VCIMPRES.Z / moving.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-11-01  |  8.3 KB  |  254 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Animated Data Example"
  5.    ClientHeight    =   5340
  6.    ClientLeft      =   1200
  7.    ClientTop       =   1530
  8.    ClientWidth     =   7425
  9.    Height          =   5805
  10.    Icon            =   "moving.frx":0000
  11.    Left            =   1110
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   5340
  16.    ScaleWidth      =   7425
  17.    Top             =   1155
  18.    Width           =   7605
  19.    Begin Threed.SSPanel pnlControls 
  20.       Height          =   5175
  21.       Left            =   5460
  22.       TabIndex        =   1
  23.       Top             =   60
  24.       Width           =   1815
  25.       _Version        =   65536
  26.       _ExtentX        =   3201
  27.       _ExtentY        =   9128
  28.       _StockProps     =   15
  29.       BackColor       =   12632256
  30.       BevelOuter      =   1
  31.       Begin VB.CommandButton Command1 
  32.          Caption         =   "Start"
  33.          Height          =   495
  34.          Left            =   300
  35.          TabIndex        =   10
  36.          Top             =   3840
  37.          Width           =   1215
  38.       End
  39.       Begin VB.CommandButton cmdStop 
  40.          Caption         =   "Stop"
  41.          Height          =   495
  42.          Left            =   300
  43.          TabIndex        =   9
  44.          Top             =   4440
  45.          Width           =   1215
  46.       End
  47.       Begin VB.Frame fraChartType 
  48.          Caption         =   " Chart Type "
  49.          Height          =   2595
  50.          Left            =   180
  51.          TabIndex        =   2
  52.          Top             =   240
  53.          Width           =   1455
  54.          Begin VB.OptionButton optChartType 
  55.             Caption         =   "Surface"
  56.             Height          =   195
  57.             Index           =   6
  58.             Left            =   240
  59.             TabIndex        =   11
  60.             Top             =   2160
  61.             Width           =   1095
  62.          End
  63.          Begin VB.OptionButton optChartType 
  64.             Caption         =   "2 D Line"
  65.             Height          =   195
  66.             Index           =   0
  67.             Left            =   240
  68.             TabIndex        =   8
  69.             Top             =   360
  70.             Value           =   -1  'True
  71.             Width           =   1095
  72.          End
  73.          Begin VB.OptionButton optChartType 
  74.             Caption         =   "3 D Line"
  75.             Height          =   195
  76.             Index           =   1
  77.             Left            =   240
  78.             TabIndex        =   7
  79.             Top             =   660
  80.             Width           =   1095
  81.          End
  82.          Begin VB.OptionButton optChartType 
  83.             Caption         =   "2 D Bar"
  84.             Height          =   195
  85.             Index           =   2
  86.             Left            =   240
  87.             TabIndex        =   6
  88.             Top             =   960
  89.             Width           =   1095
  90.          End
  91.          Begin VB.OptionButton optChartType 
  92.             Caption         =   "3 D Bar"
  93.             Height          =   195
  94.             Index           =   3
  95.             Left            =   240
  96.             TabIndex        =   5
  97.             Top             =   1260
  98.             Width           =   1095
  99.          End
  100.          Begin VB.OptionButton optChartType 
  101.             Caption         =   "Radar"
  102.             Height          =   195
  103.             Index           =   4
  104.             Left            =   240
  105.             TabIndex        =   4
  106.             Top             =   1560
  107.             Width           =   1095
  108.          End
  109.          Begin VB.OptionButton optChartType 
  110.             Caption         =   "Polar"
  111.             Height          =   195
  112.             Index           =   5
  113.             Left            =   240
  114.             TabIndex        =   3
  115.             Top             =   1860
  116.             Width           =   1095
  117.          End
  118.       End
  119.    End
  120.    Begin VCIFiLib.VtChart VtChart1 
  121.       Height          =   5175
  122.       Left            =   60
  123.       TabIndex        =   0
  124.       Top             =   60
  125.       Width           =   5235
  126.       _version        =   65536
  127.       _extentx        =   9234
  128.       _extenty        =   9128
  129.       _stockprops     =   96
  130.       borderstyle     =   1
  131.       filename        =   "moving.frx":030A
  132.    End
  133. Attribute VB_Name = "Form1"
  134. Attribute VB_Creatable = False
  135. Attribute VB_Exposed = False
  136. Option Explicit
  137. Dim run As Boolean
  138. Dim gChartType%, gRows%, gCols%
  139. Private Sub cmdStop_Click()
  140.    run = False
  141. End Sub
  142. Private Sub Command1_Click()
  143.    Const AngleIncrement = 0.2
  144.    Const PI = 3.14159264
  145.    Static DataAngle#, aMin#
  146.    MousePointer = 11 '              ' Wait cursor
  147.    run = True
  148.    While run
  149.       '' Move existing data to the left
  150.       VtChart1.DataGrid.MoveData 1, 1, gRows - 1, gCols, 0, 1
  151.       
  152.       DataAngle = DataAngle + AngleIncrement
  153.       aMin = (DataAngle / PI) - 1
  154.       If (aMin < 0) Then aMin = 0
  155.             
  156.       Select Case gChartType
  157.          Case VtChChartType2dXY
  158.             With VtChart1.DataGrid
  159.                .SetData 1, 1, DataAngle / PI, False
  160.                .SetData 1, 2, Sin(DataAngle), False
  161.                .SetData 1, 3, DataAngle / PI, False
  162.                .SetData 1, 4, Sin(DataAngle + PI / 2), False
  163.                .SetData 1, 5, DataAngle / PI, False
  164.                .SetData 1, 6, Sin(DataAngle - PI / 2), False
  165.             End With
  166.             
  167.          Case VtChChartType3dLine, VtChChartType2dBar, VtChChartType3dBar, VtChChartType2dRadar
  168.             With VtChart1.DataGrid
  169.                .SetData 1, 3, Sin(DataAngle + PI / 2), False
  170.                .SetData 1, 2, Sin(DataAngle), False
  171.                .SetData 1, 1, Sin(DataAngle - PI / 2), False
  172.              End With
  173.          
  174.          Case VtChChartType2dPolar
  175.             With VtChart1.DataGrid
  176.                .SetData 1, 1, (DataAngle * 30), False
  177.                .SetData 1, 2, Cos(DataAngle), False
  178.                .SetData 1, 3, (DataAngle * 50), False
  179.                .SetData 1, 4, Cos(DataAngle), False
  180.                .SetData 1, 5, (DataAngle * 10), False
  181.                .SetData 1, 6, Cos(DataAngle), False
  182.              End With
  183.          
  184.          Case VtChChartType3dSurface
  185.             With VtChart1.DataGrid
  186.                .SetData 1, 1, Sin(DataAngle), False
  187.                .SetData 1, 2, Sin(DataAngle + AngleIncrement), False
  188.                .SetData 1, 3, Sin(DataAngle + AngleIncrement * 2), False
  189.                .SetData 1, 4, Sin(DataAngle + AngleIncrement * 3), False
  190.                .SetData 1, 5, Sin(DataAngle + AngleIncrement * 4), False
  191.              End With
  192.          
  193.       End Select
  194.       
  195.       VtChart1.Plot.Axis(VtChAxisIdX).ValueScale.Maximum = aMin + 1
  196.       VtChart1.Plot.Axis(VtChAxisIdX).ValueScale.Minimum = aMin
  197.       
  198.       DoEvents
  199.    Wend
  200.    MousePointer = 0 ' default cursor
  201. End Sub
  202. Private Sub Form_Load()
  203.    VtChart1.DrawMode = VtChDrawModeBlit
  204.    Call optChartType_Click(0)
  205.    run = False
  206. End Sub
  207. Private Sub Form_Resize()
  208.    VtChart1.Repaint = False
  209.    pnlControls.Left = ScaleWidth - pnlControls.Width - 60
  210.    pnlControls.Height = ScaleHeight - 120
  211.    VtChart1.Width = pnlControls.Left - 150
  212.    VtChart1.Height = ScaleHeight - 120
  213.    VtChart1.Repaint = True
  214. End Sub
  215. Private Sub optChartType_Click(Index As Integer)
  216.    Select Case Index
  217.       Case 0
  218.          gChartType = VtChChartType2dXY
  219.          gRows = 18
  220.          gCols = 6
  221.       Case 1
  222.          gChartType = VtChChartType3dLine
  223.          gRows = 18
  224.          gCols = 3
  225.       Case 2
  226.          gChartType = VtChChartType2dBar
  227.          gRows = 18
  228.          gCols = 3
  229.       Case 3
  230.          gChartType = VtChChartType3dBar
  231.          gRows = 18
  232.          gCols = 3
  233.       Case 4
  234.          gChartType = VtChChartType2dRadar
  235.          gRows = 18
  236.          gCols = 3
  237.       Case 5
  238.          gChartType = VtChChartType2dPolar
  239.          gRows = 18
  240.          gCols = 6
  241.       Case 6
  242.          gChartType = VtChChartType3dSurface
  243.          gRows = 5
  244.          gCols = 5
  245.       Case Else
  246.          MsgBox "Chart type not available"
  247.          Call optChartType_Click(0)
  248.    End Select
  249.          
  250.    SetChartTypeAndSize VtChart1, gChartType, gRows, gCols
  251.    ZeroGrid VtChart1
  252.          
  253. End Sub
  254.