home *** CD-ROM | disk | FTP | other *** search
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- END
- Attribute VB_Name = "ObjPicture"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
-
- Public Objects As New Collection
- ' ************************************************
- ' Find an object that contains this point.
- ' ************************************************
- Function NearestObject(x As Single, y As Single) As Object
- Dim obj As Object
-
- ' Find the object.
- For Each obj In Objects
- If obj.Contains(x, y) Then
- Set NearestObject = obj
- Exit Function
- End If
- Next obj
- Set NearestObject = Nothing
- End Function
-
-
- Function ObjectType() As String
- ObjectType = "APF PICTURE"
- End Function
-
-
- ' ************************************************
- ' Compute the world coordinate bounds for the
- ' picture.
- ' ************************************************
- Sub Bound(xmin As Single, ymin As Single, xmax As Single, ymax As Single)
- Dim x1 As Single
- Dim y1 As Single
- Dim x2 As Single
- Dim y2 As Single
- Dim obj As Object
- Dim i As Integer
-
- If Objects.Count < 1 Then
- xmin = 0
- xmax = 1
- ymin = 0
- ymax = 1
- Exit Sub
- End If
-
- Set obj = Objects.Item(1)
- obj.Bound xmin, ymin, xmax, ymax
-
- For i = 2 To Objects.Count
- Set obj = Objects.Item(i)
- obj.Bound x1, y1, x2, y2
- If x1 < xmin Then xmin = x1
- If y1 < ymin Then ymin = y1
- If x2 > xmax Then xmax = x2
- If y2 > ymax Then ymax = y2
- Next i
- End Sub
- ' ************************************************
- ' Read the picture from a file using Input.
- ' Begin with "PICTURE" to identify this object.
- ' ************************************************
- Sub FileInput(filenum As Integer)
- Dim num As Integer
- Dim i As Integer
- Dim obj As Object
- Dim obj_type As String
-
- ' Read the number of objects in the file.
- Input #filenum, num
-
- ' Repeatedly read objects from the file.
- For i = 1 To num
- Input #filenum, obj_type
- Select Case obj_type
- Case "APF PICTURE"
- Set obj = New ObjPicture
- Case "POLYGON"
- Set obj = New ObjPolygon
- Case Else
- Beep
- MsgBox "Unknown object type """ & obj_type & """.", , vbExclamation
- Exit Sub
- End Select
- obj.FileInput filenum
- Objects.Add obj
- Next i
- End Sub
-
- ' ************************************************
- ' Draw the picture on a Form, Printer, or
- ' PictureBox.
- ' ************************************************
- Sub Draw(canvas As Object)
- Dim obj As Object
-
- For Each obj In Objects
- obj.Draw canvas
- Next obj
- End Sub
- ' ************************************************
- ' Write the picture to a file using Write.
- ' Begin with "APF PICTURE" to identify this object.
- ' ************************************************
- Sub FileWrite(filenum As Integer)
- Dim obj As Object
-
- Write #filenum, "APF PICTURE"
- Write #filenum, Objects.Count
-
- For Each obj In Objects
- obj.FileWrite filenum
- Next obj
- End Sub
-
- ' ************************************************
- ' Apply a nonlinear transformation to the objects.
- ' ************************************************
- Sub Distort(trans As Object)
- Dim obj As Object
-
- For Each obj In Objects
- obj.Distort trans
- Next obj
- End Sub
-
-
- ' ************************************************
- ' Apply a transformation matrix to the objects.
- ' ************************************************
- Sub Transform(M() As Single)
- Dim obj As Object
-
- For Each obj In Objects
- obj.Transform M
- Next obj
- End Sub
-
-
-
-