home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH10 / SRC / BSPLINE.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-05-02  |  21.2 KB  |  701 lines

  1. VERSION 4.00
  2. Begin VB.Form BSplineForm 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "B-Spline"
  6.    ClientHeight    =   5700
  7.    ClientLeft      =   285
  8.    ClientTop       =   885
  9.    ClientWidth     =   9105
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   1
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   6390
  21.    KeyPreview      =   -1  'True
  22.    Left            =   225
  23.    LinkTopic       =   "Form1"
  24.    ScaleHeight     =   5700
  25.    ScaleWidth      =   9105
  26.    Top             =   255
  27.    Width           =   9225
  28.    Begin VB.OptionButton Choice 
  29.       Caption         =   "Urn"
  30.       Height          =   255
  31.       Index           =   8
  32.       Left            =   7080
  33.       TabIndex        =   18
  34.       Top             =   2880
  35.       Width           =   2055
  36.    End
  37.    Begin VB.OptionButton Choice 
  38.       Caption         =   "Tent"
  39.       Height          =   255
  40.       Index           =   2
  41.       Left            =   7080
  42.       TabIndex        =   17
  43.       Top             =   720
  44.       Width           =   2055
  45.    End
  46.    Begin VB.CheckBox ShowGridCheck 
  47.       Caption         =   "Show Control Grid"
  48.       Height          =   255
  49.       Left            =   7080
  50.       TabIndex        =   16
  51.       Top             =   3840
  52.       Width           =   2055
  53.    End
  54.    Begin VB.OptionButton Choice 
  55.       Caption         =   "Hill"
  56.       Height          =   255
  57.       Index           =   0
  58.       Left            =   7080
  59.       TabIndex        =   15
  60.       Top             =   0
  61.       Value           =   -1  'True
  62.       Width           =   2055
  63.    End
  64.    Begin VB.OptionButton Choice 
  65.       Caption         =   "Wave"
  66.       Height          =   255
  67.       Index           =   1
  68.       Left            =   7080
  69.       TabIndex        =   14
  70.       Top             =   360
  71.       Width           =   2055
  72.    End
  73.    Begin VB.OptionButton Choice 
  74.       Caption         =   "Curl"
  75.       Height          =   255
  76.       Index           =   3
  77.       Left            =   7080
  78.       TabIndex        =   13
  79.       Top             =   1080
  80.       Width           =   2055
  81.    End
  82.    Begin VB.OptionButton Choice 
  83.       Caption         =   "Pipe"
  84.       Height          =   255
  85.       Index           =   4
  86.       Left            =   7080
  87.       TabIndex        =   12
  88.       Top             =   1440
  89.       Width           =   2055
  90.    End
  91.    Begin VB.OptionButton Choice 
  92.       Caption         =   "Cowling"
  93.       Height          =   255
  94.       Index           =   5
  95.       Left            =   7080
  96.       TabIndex        =   11
  97.       Top             =   1800
  98.       Width           =   2055
  99.    End
  100.    Begin VB.OptionButton Choice 
  101.       Caption         =   "Twist"
  102.       Height          =   255
  103.       Index           =   6
  104.       Left            =   7080
  105.       TabIndex        =   10
  106.       Top             =   2160
  107.       Width           =   2055
  108.    End
  109.    Begin VB.OptionButton Choice 
  110.       Caption         =   "Spiral"
  111.       Height          =   255
  112.       Index           =   7
  113.       Left            =   7080
  114.       TabIndex        =   9
  115.       Top             =   2520
  116.       Width           =   2055
  117.    End
  118.    Begin VB.CheckBox ShowControlsCheck 
  119.       Caption         =   "Show Control Points"
  120.       Height          =   255
  121.       Left            =   7080
  122.       TabIndex        =   8
  123.       Top             =   3480
  124.       Width           =   2055
  125.    End
  126.    Begin VB.CheckBox ShowAxesCheck 
  127.       Caption         =   "Show Axes"
  128.       Height          =   255
  129.       Left            =   7080
  130.       TabIndex        =   7
  131.       Top             =   4200
  132.       Width           =   2055
  133.    End
  134.    Begin VB.TextBox PhiText 
  135.       Height          =   285
  136.       Left            =   3600
  137.       TabIndex        =   6
  138.       Text            =   "0.1570"
  139.       Top             =   5400
  140.       Width           =   855
  141.    End
  142.    Begin VB.TextBox ThetaText 
  143.       Height          =   285
  144.       Left            =   2040
  145.       TabIndex        =   4
  146.       Text            =   "0.6283"
  147.       Top             =   5400
  148.       Width           =   855
  149.    End
  150.    Begin VB.TextBox RText 
  151.       Height          =   285
  152.       Left            =   480
  153.       TabIndex        =   2
  154.       Text            =   "10"
  155.       Top             =   5400
  156.       Width           =   855
  157.    End
  158.    Begin VB.PictureBox Pict 
  159.       AutoRedraw      =   -1  'True
  160.       Height          =   5295
  161.       Left            =   0
  162.       ScaleHeight     =   349
  163.       ScaleMode       =   3  'Pixel
  164.       ScaleWidth      =   461
  165.       TabIndex        =   0
  166.       Top             =   0
  167.       Width           =   6975
  168.    End
  169.    Begin MSComDlg.CommonDialog LoadDialog 
  170.       Left            =   7080
  171.       Top             =   4800
  172.       _version        =   65536
  173.       _extentx        =   847
  174.       _extenty        =   847
  175.       _stockprops     =   0
  176.       cancelerror     =   -1  'True
  177.    End
  178.    Begin VB.Label Label1 
  179.       Caption         =   "Phi"
  180.       Height          =   255
  181.       Index           =   2
  182.       Left            =   3240
  183.       TabIndex        =   5
  184.       Top             =   5400
  185.       Width           =   375
  186.    End
  187.    Begin VB.Label Label1 
  188.       Caption         =   "Theta"
  189.       Height          =   255
  190.       Index           =   1
  191.       Left            =   1440
  192.       TabIndex        =   3
  193.       Top             =   5400
  194.       Width           =   495
  195.    End
  196.    Begin VB.Label Label1 
  197.       Caption         =   "R"
  198.       Height          =   255
  199.       Index           =   0
  200.       Left            =   240
  201.       TabIndex        =   1
  202.       Top             =   5400
  203.       Width           =   255
  204.    End
  205.    Begin VB.Menu mnuFile 
  206.       Caption         =   "&File"
  207.       Begin VB.Menu mnuFileLoad 
  208.          Caption         =   "&Load..."
  209.          Shortcut        =   ^L
  210.       End
  211.       Begin VB.Menu mnuFileSaveAs 
  212.          Caption         =   "&Save As..."
  213.          Shortcut        =   ^A
  214.       End
  215.       Begin VB.Menu mnuFileSep 
  216.          Caption         =   "-"
  217.       End
  218.       Begin VB.Menu mnuFileExit 
  219.          Caption         =   "E&xit"
  220.       End
  221.    End
  222. Attribute VB_Name = "BSplineForm"
  223. Attribute VB_Creatable = False
  224. Attribute VB_Exposed = False
  225. Option Explicit
  226. ' Location of viewing eye.
  227. Dim EyeR As Single
  228. Dim EyeTheta As Single
  229. Dim EyePhi As Single
  230. Const Dtheta = PI / 20
  231. Const Dphi = PI / 20
  232. Const Dr = 1
  233. ' Location of focus point.
  234. Const FocusX = 0#
  235. Const FocusY = 0#
  236. Const FocusZ = 0#
  237. Dim Projector(1 To 4, 1 To 4) As Single
  238. Dim ThePicture As ObjPicture
  239. Dim TheSurface As ObjBSpline
  240. Dim ShowingParameters As Boolean
  241. Dim ChoiceNum As Integer
  242. ' *******************************************************
  243. ' Rotate the points in the cube and draw the cube.
  244. ' *******************************************************
  245. Private Sub DrawData(pic As Object)
  246. Dim s(1 To 4, 1 To 4) As Single
  247. Dim t(1 To 4, 1 To 4) As Single
  248. Dim ST(1 To 4, 1 To 4) As Single
  249. Dim PST(1 To 4, 1 To 4) As Single
  250.     MousePointer = vbHourglass
  251.     Refresh
  252.     ' Prevent overflow errors when drawing lines
  253.     ' too far out of bounds.
  254.     On Error Resume Next
  255.     ' Scale and translate so it looks OK in pixels.
  256.     m3Scale s, 35, -35, 1
  257.     m3Translate t, 230, 175, 0
  258.     m3MatMultiplyFull ST, s, t
  259.     m3MatMultiplyFull PST, Projector, ST
  260.     ' Transform the points.
  261.     ThePicture.ApplyFull PST
  262.     ' Display the data.
  263.     pic.Cls
  264.     ThePicture.Draw pic, EyeR
  265.     pic.Refresh
  266.     ' Display the viewnig parameters.
  267.     ShowViewingParameters
  268.     MousePointer = vbDefault
  269. End Sub
  270. ' ************************************************
  271. ' Set the control points for a urn.
  272. ' ************************************************
  273. Sub MakeUrn()
  274. Dim r(1 To 5) As Single
  275. Dim h(1 To 5) As Single
  276. Dim i As Integer
  277.     TheSurface.SetBounds 5, 6
  278.     r(1) = 0.5
  279.     r(2) = 0.5
  280.     r(3) = 2.5
  281.     r(4) = 0.75
  282.     r(5) = 0.75
  283.     h(1) = 4
  284.     h(2) = 3.5
  285.     h(3) = 2
  286.     h(4) = -1
  287.     h(5) = -3
  288.         
  289.     For i = 1 To 5
  290.         TheSurface.SetControlPoint i, 1, -1.5 * r(i), h(i), 0
  291.         TheSurface.SetControlPoint i, 2, -1.5 * r(i), h(i), -1.5 * r(i)
  292.         TheSurface.SetControlPoint i, 3, 1.5 * r(i), h(i), -1.5 * r(i)
  293.         TheSurface.SetControlPoint i, 4, 1.5 * r(i), h(i), 1.5 * r(i)
  294.         TheSurface.SetControlPoint i, 5, -1.5 * r(i), h(i), 1.5 * r(i)
  295.         TheSurface.SetControlPoint i, 6, -1.5 * r(i), h(i), 0
  296.     Next i
  297. End Sub
  298. ' ************************************************
  299. ' Set the control points for a pipe.
  300. ' ************************************************
  301. Sub MakePipe()
  302. Const s = 3
  303. Dim i As Integer
  304. Dim x As Single
  305.     TheSurface.SetBounds 4, 6
  306.     For i = 1 To 4
  307.         x = 1.5 * (i - 2.5)
  308.         TheSurface.SetControlPoint i, 1, x, _
  309.             -s, 0
  310.         TheSurface.SetControlPoint i, 2, x, _
  311.             -s, -s
  312.         TheSurface.SetControlPoint i, 3, x, _
  313.             s, -s
  314.         TheSurface.SetControlPoint i, 4, x, _
  315.             s, s
  316.         TheSurface.SetControlPoint i, 5, x, _
  317.             -s, s
  318.         TheSurface.SetControlPoint i, 6, x, _
  319.             -s, 0
  320.     Next i
  321. End Sub
  322. ' ************************************************
  323. ' Set the control points for a curl.
  324. ' ************************************************
  325. Sub MakeCurl()
  326. Dim ang As Integer
  327. Dim j As Integer
  328. Dim r As Single
  329. Dim x As Single
  330. Dim y As Single
  331. Dim z As Single
  332.     TheSurface.SetBounds 4, 4
  333.     For j = 1 To 4
  334.         z = 1.5 * (j - 2.5)
  335.         r = 6 - Abs(2 * j - 5)
  336.         For ang = 1 To 4
  337.             x = r * Cos((ang - 1) * PI / 2)
  338.             y = r * Sin((ang - 1) * PI / 2)
  339.             TheSurface.SetControlPoint ang, j, x, y, z
  340.         Next ang
  341.     Next j
  342. End Sub
  343. ' ************************************************
  344. ' Set the control points for a wave.
  345. ' ************************************************
  346. Sub MakeWave()
  347. Dim i As Integer
  348. Dim j As Integer
  349.             
  350.     TheSurface.SetBounds 4, 4
  351.     ' Start flat and modify from there.
  352.     For i = 1 To 4
  353.         For j = 1 To 4
  354.             TheSurface.SetControlPoint i, j, 2 * i - 5, 0, 2 * j - 5
  355.         Next j
  356.     Next i
  357.     ' Make the modifications.
  358.     TheSurface.SetControlPoint 2, 2, -1, -7, -1
  359.     TheSurface.SetControlPoint 2, 3, -1, 7, 1
  360.     TheSurface.SetControlPoint 3, 2, 1, -7, -1
  361.     TheSurface.SetControlPoint 3, 3, 1, 7, 1
  362. End Sub
  363. ' ************************************************
  364. ' Set the control points for a tent.
  365. ' ************************************************
  366. Sub MakeTent()
  367.     TheSurface.SetBounds 3, 3
  368.     TheSurface.SetControlPoint 1, 1, -3, -2, -3
  369.     TheSurface.SetControlPoint 1, 2, -3, 2, 0
  370.     TheSurface.SetControlPoint 1, 3, -3, -2, 3
  371.     TheSurface.SetControlPoint 2, 1, 0, 2, -3
  372.     TheSurface.SetControlPoint 2, 2, 0, 4, 0
  373.     TheSurface.SetControlPoint 2, 3, 0, 2, 3
  374.     TheSurface.SetControlPoint 3, 1, 3, -2, -3
  375.     TheSurface.SetControlPoint 3, 2, 3, 2, 0
  376.     TheSurface.SetControlPoint 3, 3, 3, -2, 3
  377. End Sub
  378. ' ************************************************
  379. ' Set the control points for a spiral.
  380. ' ************************************************
  381. Sub MakeSpiral()
  382.     TheSurface.SetBounds 5, 3
  383.     TheSurface.SetControlPoint 1, 1, -4, 2, 0
  384.     TheSurface.SetControlPoint 1, 2, -4, 0, 0
  385.     TheSurface.SetControlPoint 1, 3, -4, -2, 0
  386.     TheSurface.SetControlPoint 2, 1, -2, 0, -4
  387.     TheSurface.SetControlPoint 2, 2, -2, 0, 0
  388.     TheSurface.SetControlPoint 2, 3, -2, 0, 4
  389.     TheSurface.SetControlPoint 3, 1, 0, -4, 0
  390.     TheSurface.SetControlPoint 3, 2, 0, 0, 0
  391.     TheSurface.SetControlPoint 3, 3, 0, 4, 0
  392.     TheSurface.SetControlPoint 4, 1, 2, 0, 4
  393.     TheSurface.SetControlPoint 4, 2, 2, 0, 0
  394.     TheSurface.SetControlPoint 4, 3, 2, 0, -4
  395.     TheSurface.SetControlPoint 5, 1, 4, 2, 0
  396.     TheSurface.SetControlPoint 5, 2, 4, 0, 0
  397.     TheSurface.SetControlPoint 5, 3, 4, -2, 0
  398. End Sub
  399. ' ************************************************
  400. ' Set the control points for a twist.
  401. ' ************************************************
  402. Sub MakeTwist()
  403.     TheSurface.SetBounds 3, 3
  404.     TheSurface.SetControlPoint 1, 1, -3, 0, -3
  405.     TheSurface.SetControlPoint 1, 2, -3, 0, 0
  406.     TheSurface.SetControlPoint 1, 3, -3, 0, 3
  407.     TheSurface.SetControlPoint 2, 1, 0, -1.7, -1.7
  408.     TheSurface.SetControlPoint 2, 2, 0, 0, 0
  409.     TheSurface.SetControlPoint 2, 3, 0, 1.7, 1.7
  410.     TheSurface.SetControlPoint 3, 1, 3, -3, 0
  411.     TheSurface.SetControlPoint 3, 2, 3, 0, 0
  412.     TheSurface.SetControlPoint 3, 3, 3, 3, 0
  413. End Sub
  414. ' ************************************************
  415. ' Set the control points for a cowling.
  416. ' ************************************************
  417. Sub MakeCowl()
  418. Dim i As Integer
  419. Dim s As Single
  420. Dim y As Single
  421.     TheSurface.SetBounds 4, 6
  422.     For i = 1 To 4
  423.         y = 3 - 2 * Abs(i - 2.5)
  424.         
  425.         s = 2 + i / 2
  426.         
  427.         TheSurface.SetControlPoint i, 1, _
  428.             1.25 * s - 1, y, 0
  429.         TheSurface.SetControlPoint i, 2, _
  430.             1.25 * s - 1, y, s
  431.         TheSurface.SetControlPoint i, 3, _
  432.             -s - 1, y, s
  433.         TheSurface.SetControlPoint i, 4, _
  434.             -s - 1, y, -s
  435.         TheSurface.SetControlPoint i, 5, _
  436.             1.25 * s - 1, y, -s
  437.         TheSurface.SetControlPoint i, 6, _
  438.             1.25 * s - 1, y, 0
  439.     Next i
  440. End Sub
  441. ' ************************************************
  442. ' Set the control points for a hill.
  443. ' ************************************************
  444. Sub MakeHill()
  445. Dim i As Integer
  446. Dim j As Integer
  447.             
  448.     TheSurface.SetBounds 5, 5
  449.     ' Start flat and modify from there.
  450.     For i = 1 To 5
  451.         For j = 1 To 5
  452.             TheSurface.SetControlPoint i, j, 2 * (i - 3), 0, 2 * (j - 3)
  453.         Next j
  454.     Next i
  455.     ' Make the modifications.
  456.     TheSurface.SetControlPoint 3, 3, 0, 5, 0
  457. End Sub
  458. Sub ShowViewingParameters()
  459.     ShowingParameters = True
  460.     RText.Text = Format$(EyeR, "0.0000")
  461.     ThetaText.Text = Format$(EyeTheta, "0.0000")
  462.     PhiText.Text = Format$(EyePhi, "0.0000")
  463.     RText.Refresh
  464.     ThetaText.Refresh
  465.     PhiText.Refresh
  466.     ShowingParameters = False
  467. End Sub
  468. Private Sub Choice_Click(Index As Integer)
  469.     ChoiceNum = Index
  470.     CreateData (ShowAxesCheck.value = vbChecked)
  471.     DrawData Pict
  472.     Pict.SetFocus
  473. End Sub
  474. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  475.     Select Case KeyCode
  476.         Case vbKeyLeft
  477.             EyeTheta = EyeTheta - Dtheta
  478.         
  479.         Case vbKeyRight
  480.             EyeTheta = EyeTheta + Dtheta
  481.         
  482.         Case vbKeyUp
  483.             EyePhi = EyePhi - Dphi
  484.         
  485.         Case vbKeyDown
  486.             EyePhi = EyePhi + Dphi
  487.                 
  488.         Case Else
  489.             Exit Sub
  490.     End Select
  491.     m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
  492.     DrawData Pict
  493. End Sub
  494. Private Sub Form_KeyPress(KeyAscii As Integer)
  495.     Select Case KeyAscii
  496.         Case Asc("+")
  497.             EyeR = EyeR + Dr
  498.         
  499.         Case Asc("-")
  500.             EyeR = EyeR - Dr
  501.         
  502.         Case Else
  503.             Exit Sub
  504.     End Select
  505.     m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
  506.     DrawData Pict
  507. End Sub
  508. Private Sub Form_Load()
  509.     ' Initialize the eye position.
  510.     EyeR = 10
  511.     EyeTheta = PI * 0.2
  512.     EyePhi = PI * 0.1
  513.     ' Initialize the projection transformation.
  514.     m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
  515.     ' Create the data.
  516.     CreateData (ShowAxesCheck.value = vbChecked)
  517.     ' Project and draw the data.
  518.     Me.Show
  519.     DrawData Pict
  520. End Sub
  521. ' ************************************************
  522. ' Create the surface.
  523. ' ************************************************
  524. Sub CreateData(show_axes As Boolean)
  525. Const GapU = 0.25
  526. Const GapV = 0.25
  527. Const Du = GapU / 5
  528. Const Dv = GapV / 5
  529. Dim axis As ObjPolyline
  530.     MousePointer = vbHourglass
  531.     Refresh
  532.     Set ThePicture = New ObjPicture
  533.     Set TheSurface = New ObjBSpline
  534.     ThePicture.objects.Add TheSurface
  535.     TheSurface.DrawControls = (ShowControlsCheck.value = vbChecked)
  536.     TheSurface.DrawGrid = (ShowGridCheck.value = vbChecked)
  537.     If show_axes Then
  538.         Set axis = New ObjPolyline
  539.         ThePicture.objects.Add axis
  540.         axis.AddSegment 0, 0, 0, 5.5, 0, 0
  541.         axis.AddSegment 0, 0, 0, 0, 3, 0
  542.         axis.AddSegment 0, 0, 0, 0, 0, 5.5
  543.     End If
  544.     ' Set the control points.
  545.     Select Case ChoiceNum
  546.         Case 0  ' Hill.
  547.             MakeHill
  548.         Case 1  ' Wave.
  549.             MakeWave
  550.         Case 2  ' Tent.
  551.             MakeTent
  552.             
  553.         Case 3  ' Curl.
  554.             MakeCurl
  555.             
  556.         Case 4  ' Pipe.
  557.             MakePipe
  558.             
  559.         Case 5  ' Cowling.
  560.             MakeCowl
  561.             
  562.         Case 6  ' Twist.
  563.             MakeTwist
  564.         
  565.         Case 7  ' Spiral.
  566.             MakeSpiral
  567.         
  568.         Case 8  ' Urn.
  569.             MakeUrn
  570.         
  571.         Case Else  ' Something safe.
  572.             MakeHill
  573.     End Select
  574.     ' Create the grid to represent the surface.
  575.     TheSurface.InitializeGrid _
  576.         3, 3, GapU, GapV, Du, Dv
  577. End Sub
  578. Private Sub mnuFileExit_Click()
  579.     Unload Me
  580. End Sub
  581. Private Sub mnuFileLoad_Click()
  582. Dim fname As String
  583. Dim filenum As Integer
  584. Dim txt As String
  585. Dim Xmin As Single
  586. Dim ymin As Single
  587. Dim Xmax As Single
  588. Dim ymax As Single
  589.     ' Allow the user to pick a file.
  590.     On Error Resume Next
  591.     LoadDialog.filename = "*.APF"
  592.     LoadDialog.ShowOpen
  593.     If Err.Number = cdlCancel Then
  594.         Unload LoadDialog
  595.         Exit Sub
  596.     ElseIf Err.Number <> 0 Then
  597.         Unload LoadDialog
  598.         Beep
  599.         MsgBox "Error selecting file.", , vbExclamation
  600.         Exit Sub
  601.     End If
  602.     On Error GoTo 0
  603.     fname = LoadDialog.filename
  604.     LoadDialog.InitDir = Left$(fname, Len(fname) _
  605.         - Len(LoadDialog.FileTitle) - 1)
  606.     ' Clear the picture.
  607.     Set ThePicture = Nothing
  608.     ' Open the file.
  609.     filenum = FreeFile
  610.     Open fname For Input As #filenum
  611.     ' Make sure it's an Object Picture File.
  612.     Input #filenum, txt
  613.     If txt <> "3D APF PICTURE" Then
  614.         Close filenum
  615.         Beep
  616.         MsgBox "Error reading file """ & fname & """.", , vbExclamation
  617.         Exit Sub
  618.     End If
  619.     ' Read the picture.
  620.     MousePointer = vbHourglass
  621.     DoEvents
  622.     Set ThePicture = New ObjPicture
  623.     ThePicture.FileInput filenum
  624.     If ThePicture.objects(1).ObjectType = "BSPLINE" Then
  625.         Set TheSurface = ThePicture.objects(1)
  626.         TheSurface.DrawControls = (ShowControlsCheck.value = vbChecked)
  627.         TheSurface.DrawGrid = (ShowGridCheck.value = vbChecked)
  628.     End If
  629.     ' Close the file.
  630.     Close filenum
  631.     ' Refresh the display.
  632.     DrawData Pict
  633.     ' Deselect all the option buttons.
  634.     For ChoiceNum = 0 To 8
  635.         If Choice(ChoiceNum).value Then _
  636.             Choice(ChoiceNum).value = False
  637.     Next ChoiceNum
  638.     MousePointer = vbDefault
  639. End Sub
  640. Private Sub mnuFileSaveAs_Click()
  641. Dim fname As String
  642. Dim filenum As Integer
  643.     ' Allow the user to pick a file.
  644.     On Error Resume Next
  645.     LoadDialog.filename = "*.APF"
  646.     LoadDialog.ShowOpen
  647.     If Err.Number = cdlCancel Then
  648.         Unload LoadDialog
  649.         Exit Sub
  650.     ElseIf Err.Number <> 0 Then
  651.         Unload LoadDialog
  652.         Beep
  653.         MsgBox "Error selecting file.", , vbExclamation
  654.         Exit Sub
  655.     End If
  656.     On Error GoTo 0
  657.     fname = LoadDialog.filename
  658.     LoadDialog.InitDir = Left$(fname, Len(fname) _
  659.         - Len(LoadDialog.FileTitle) - 1)
  660.     ' Open the file.
  661.     filenum = FreeFile
  662.     Open fname For Output As #filenum
  663.     ' Write the picture.
  664.     ThePicture.FileWrite filenum
  665.     ' Close the file.
  666.     Close filenum
  667. End Sub
  668. Private Sub PhiText_Change()
  669.     If ShowingParameters Then Exit Sub
  670.     EyePhi = CSng(PhiText.Text)
  671.     m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
  672.     DrawData Pict
  673. End Sub
  674. Private Sub RText_Change()
  675.     If ShowingParameters Then Exit Sub
  676.     EyeR = CSng(RText.Text)
  677.     m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
  678.     DrawData Pict
  679. End Sub
  680. Private Sub ShowAxesCheck_Click()
  681.     CreateData (ShowAxesCheck.value = vbChecked)
  682.     DrawData Pict
  683.     Pict.SetFocus
  684. End Sub
  685. Private Sub ShowControlsCheck_Click()
  686.     TheSurface.DrawControls = (ShowControlsCheck.value = vbChecked)
  687.     DrawData Pict
  688.     Pict.SetFocus
  689. End Sub
  690. Private Sub ShowGridCheck_Click()
  691.     TheSurface.DrawGrid = (ShowGridCheck.value = vbChecked)
  692.     DrawData Pict
  693.     Pict.SetFocus
  694. End Sub
  695. Private Sub ThetaText_Change()
  696.     If ShowingParameters Then Exit Sub
  697.     EyeTheta = CSng(ThetaText.Text)
  698.     m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
  699.     DrawData Pict
  700. End Sub
  701.