home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "10_5 Selection Callback"
- ClientHeight = 5625
- ClientLeft = 1140
- ClientTop = 1425
- ClientWidth = 6750
- Height = 6000
- Left = 1080
- LinkTopic = "Form1"
- ScaleHeight = 5625
- ScaleWidth = 6750
- Top = 1110
- Width = 6870
- Begin TgsVisual3SpaceLibCtl.V3Space V3Space1
- Height = 5655
- Left = 0
- TabIndex = 0
- Top = 0
- Width = 6735
- _Version = 131072
- _ExtentX = 11880
- _ExtentY = 9975
- _StockProps = 0
- viewingOn = 0 'False
- urlPickEnable = 0 'False
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Dim mySphere As SoSphere
- Dim myText As SoText3
- Dim textMaterial As SoMaterial
- Dim sphereMaterial As SoMaterial
- Private Sub Form_Initialize()
- Static g_selCB
- Static g_dselCB
- Set g_selCB = New SoSelectionPathCB
- Set g_dselCB = New SoSelectionPathCB
- Dim selectionRoot As SoSelection
- Set selectionRoot = V3Space1.getSceneRoot
- 'Create the scene graph
- Dim root As SoSeparator
- Set root = New SoSeparator
- Call selectionRoot.addChild(root)
- 'Add a sphere node
- Dim sphereRoot As SoSeparator
- Set sphereRoot = New SoSeparator
- Dim sphereTransform As SoTransform
- Set sphereTransform = New SoTransform
- Call sphereTransform.translation.setValue(17#, 17#, 0#)
- Call sphereTransform.scaleFactor.setValue(8#, 8#, 8#)
- Call sphereRoot.addChild(sphereTransform)
- Set sphereMaterial = New SoMaterial
- Call sphereMaterial.diffuseColor.setValue(0.8, 0.8, 0.8)
- Call sphereRoot.addChild(sphereMaterial)
- Set mySphere = New SoSphere
- Call sphereRoot.addChild(mySphere)
- Call root.addChild(sphereRoot)
- 'Add a text node
- Dim textRoot As SoSeparator
- Set textRoot = New SoSeparator
- Dim textTransform As SoTransform
- Set textTransform = New SoTransform
- Call textTransform.translation.setValue(0#, -1#, 0#)
- Call textRoot.addChild(textTransform)
- Set textMaterial = New SoMaterial
- Call textMaterial.diffuseColor.setValue(0.8, 0.8, 0.8)
- Call textRoot.addChild(textMaterial)
- Dim textPickStyle As SoPickStyle
- Set textPickStyle = New SoPickStyle
- Call textPickStyle.Style.setValue(1) 'SoPickStyle::BOUNDING_BOX)
- Call textRoot.addChild(textPickStyle)
- Set myText = New SoText3
- Call myText.Str.setValue("rhubarb")
- Call textRoot.addChild(myText)
- Call root.addChild(textRoot)
- Call V3Space1.viewAll
-
- Call selectionRoot.addSelectionCallback(V3Space1.GetIDispatch(), g_selCB)
- Call selectionRoot.addDeselectionCallback(V3Space1.GetIDispatch(), g_dselCB)
-
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Set mySphere = Nothing
- Set myText = Nothing
- Set textMaterial = Nothing
- Set sphereMaterial = Nothing
- End Sub
- Private Sub V3Space1_DeselectionCallback(ByVal pathCB As Object, ByVal path As Object)
- Dim n As Object
- Set n = path.getTail()
- If n Is Nothing Then
- GoTo cleanup
- End If
- If n.isOfType(myText.getClassTypeId()) Then
- Call textMaterial.diffuseColor.setValue(0.8, 0.8, 0.8)
- ElseIf n.isOfType(mySphere.getClassTypeId()) Then
- Call sphereMaterial.diffuseColor.setValue(0.8, 0.8, 0.8)
- End If
- cleanup:
- Set pathCB = Nothing
- Set path = Nothing
- Set n = Nothing
- End Sub
- Private Sub V3Space1_SelectionCallback(ByVal pathCB As Object, ByVal path As Object)
-
- Dim n As Object
- Set n = path.getTail()
- If n Is Nothing Then
- GoTo cleanup
- End If
- If n.isOfType(myText.getClassTypeId()) Then
- Call textMaterial.diffuseColor.setValue(1#, 0.2, 0.2)
- ElseIf n.isOfType(mySphere.getClassTypeId()) Then
- Call sphereMaterial.diffuseColor.setValue(1#, 0.2, 0.2)
- End If
- cleanup:
- Set n = Nothing
- Set pathCB = Nothing
- Set path = Nothing
- End Sub
-