home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmVbCamera
- BorderStyle = 3 'Fixed Dialog
- Caption = "TurboCAD view"
- ClientHeight = 5640
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 8940
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 5640
- ScaleWidth = 8940
- ShowInTaskbar = 0 'False
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton CmOrbit
- Caption = "Orbit"
- Enabled = 0 'False
- Height = 375
- Left = 7440
- TabIndex = 6
- Top = 2895
- Width = 1275
- End
- Begin VB.CommandButton cmZoomAll
- Caption = "Zoom Extents"
- Height = 375
- Left = 7440
- TabIndex = 4
- Top = 2190
- Width = 1275
- End
- Begin VB.CommandButton cmZoomOut
- Caption = "ZoomOut"
- Height = 375
- Left = 7440
- TabIndex = 3
- Top = 1575
- Width = 1275
- End
- Begin VB.CommandButton cmZoomIn
- Caption = "ZoomIn"
- Height = 375
- Left = 7440
- TabIndex = 2
- Top = 960
- Width = 1275
- End
- Begin VB.CommandButton cmOpen
- Caption = "Open"
- Height = 375
- Left = 7440
- TabIndex = 1
- Top = 375
- Width = 1275
- End
- Begin VB.PictureBox picPreview
- Height = 4275
- Left = 450
- ScaleHeight = 4215
- ScaleWidth = 5745
- TabIndex = 0
- Top = 345
- Width = 5805
- Begin VB.CommandButton cmSpaceMode
- Height = 255
- Left = 0
- TabIndex = 5
- TabStop = 0 'False
- Top = 3975
- Width = 255
- End
- End
- Attribute VB_Name = "frmVbCamera"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '******************************************************************'
- '* *'
- '* TurboCAD for Windows *'
- '* Copyright (c) 1993 - 2001 *'
- '* International Microcomputer Software, Inc. *'
- '* (IMSI) *'
- '* All rights reserved. *'
- '* *'
- '******************************************************************'
- Option Explicit
- Const M_PI = 3.14159265358979
- Private Sub cmOpen_Click()
- Dim fName As String
- On Error Resume Next
- Err.Clear
- fName = ""
- fName = gxApp.GetOpenFilename("TCW", "Select a file", False)
- On Error GoTo ErrH
- Err.Clear
- If fName <> "" Then
- Set gxDr = gxApp.Drawings.Open(fName)
- Call AddPreview
- On Error Resume Next
- Call Camera_Plan(gxView)
- gxView.ZoomToExtents
- Err.Clear
- Call EnableButtons
- cmZoomAll.SetFocus
- End If
- Exit Sub
- ErrH:
- MsgBox Err.Description
- Err.Clear
- End Sub
- Private Sub AddPreview()
- Set gxView = gxDr.Views.Add(picPreview.hWnd)
- Dim varVal As Integer
- varVal = gxDr.Properties("TileMode")
- If varVal = imsiModelSpace Then
- gxView.SpaceMode = imsiModelSpace
- cmSpaceMode.Caption = "M"
- CmOrbit.Enabled = True
- Else
- gxView.SpaceMode = imsiPaperSpace
- cmSpaceMode.Caption = "P"
- CmOrbit.Enabled = False
- End If
- gxView.ZoomToExtents
- End Sub
- Private Sub CmOrbit_Click()
- Dim Cam As XCamera
- Dim i As Long
- Dim angle As Double
- ' Note we only can manipulate camera object if currect view mode is model space
- Set Cam = gxView.Camera
- angle = 18
- ' recalculate angle in radian
- angle = angle * M_PI / 180
- MsgBox "Camera is moving along the orbit is in XY pane"
- For i = 0 To 19
- Cam.Orbit angle, False, 0, 0, 1
- picPreview.Refresh
- gxView.Refresh
- Next i
- MsgBox "Camera is moving along the orbit in YZ pane"
- For i = 0 To 19
- Cam.Orbit angle, False, 1, 0, 0
- picPreview.Refresh
- gxView.Refresh
- Next i
- MsgBox "Camera is moving along the orbit in XZ pane"
- For i = 0 To 19
- Cam.Orbit angle, False, 0, 1, 0
- picPreview.Refresh
- gxView.Refresh
- Next i
- Set Cam = Nothing
- End Sub
- Private Sub cmSpaceMode_Click()
- If gxView.SpaceMode = imsiModelSpace Then
- gxView.Drawing.Properties("TileMode") = imsiPaperSpace
- gxView.SpaceMode = imsiPaperSpace
- cmSpaceMode.Caption = "P"
- CmOrbit.Enabled = False
- Else
- gxView.Drawing.Properties("TileMode") = imsiModelSpace
- gxView.SpaceMode = imsiModelSpace
- cmSpaceMode.Caption = "M"
- CmOrbit.Enabled = True
- End If
- cmZoomAll.SetFocus
- picPreview.Refresh
- gxView.ZoomToExtents
- End Sub
- Private Sub cmZoomAll_Click()
- picPreview.Refresh
- gxView.ZoomToExtents
- End Sub
- Private Sub cmZoomIn_Click()
- Call Zoom(0.8)
- picPreview.Refresh
- gxView.Refresh
- End Sub
- Private Sub cmZoomOut_Click()
- Call Zoom(1.2)
- picPreview.Refresh
- gxView.Refresh
- End Sub
- Private Sub Form_Initialize()
- Call DisableButtons
- End Sub
- Private Sub Form_Terminate()
- On Error Resume Next
- gxView.Delete
- Set gxView = Nothing
- gxDr.Close False
- Set gxDr = Nothing
- Set gxApp = Nothing
- End Sub
- Public Sub Zoom(factor As Double)
- If (factor <> 0) Then
- On Error GoTo VwZoom
- gxView.Camera.Zoom factor
- Exit Sub
- Else
- gxView.ZoomToExtents
- End If
- Exit Sub
- VwZoom:
- Dim xC As Double
- Dim yC As Double
-
- Dim w As Double
- Dim h As Double
- On Error GoTo Err
- w = gxView.ViewWidth
- h = gxView.ViewHeight
- xC = gxView.ViewLeft + w / 2
- yC = gxView.ViewTop - h / 2
- w = w * factor
- h = h * factor
- gxView.Update = False
-
- gxView.ViewLeft = xC - w / 2
- gxView.ViewTop = yC + h / 2
- gxView.ViewWidth = w
- gxView.ViewHeight = h
- End Sub
- Private Sub EnableButtons()
- cmZoomIn.Enabled = True
- cmZoomOut.Enabled = True
- cmZoomAll.Enabled = True
- End Sub
- Private Sub DisableButtons()
- cmZoomIn.Enabled = False
- cmZoomOut.Enabled = False
- cmZoomAll.Enabled = False
- End Sub
-