home *** CD-ROM | disk | FTP | other *** search
/ Using Visual Basic 5 (Platinum Edition) / vb5.iso / ACTIVEX / VIS3SPAC / DATA.9 / examples / vb / 10_5SelectionCB / 10_5SelectionCB.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-11-10  |  4.2 KB  |  123 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "10_5 Selection Callback"
  4.    ClientHeight    =   5625
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1425
  7.    ClientWidth     =   6750
  8.    Height          =   6000
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5625
  12.    ScaleWidth      =   6750
  13.    Top             =   1110
  14.    Width           =   6870
  15.    Begin TgsVisual3SpaceLibCtl.V3Space V3Space1 
  16.       Height          =   5655
  17.       Left            =   0
  18.       TabIndex        =   0
  19.       Top             =   0
  20.       Width           =   6735
  21.       _Version        =   131072
  22.       _ExtentX        =   11880
  23.       _ExtentY        =   9975
  24.       _StockProps     =   0
  25.       viewingOn       =   0   'False
  26.       urlPickEnable   =   0   'False
  27.    End
  28. Attribute VB_Name = "Form1"
  29. Attribute VB_Creatable = False
  30. Attribute VB_Exposed = False
  31.     Dim mySphere As SoSphere
  32.     Dim myText As SoText3
  33.     Dim textMaterial As SoMaterial
  34.     Dim sphereMaterial As SoMaterial
  35. Private Sub Form_Initialize()
  36.     Static g_selCB
  37.     Static g_dselCB
  38.     Set g_selCB = New SoSelectionPathCB
  39.     Set g_dselCB = New SoSelectionPathCB
  40.     Dim selectionRoot As SoSelection
  41.     Set selectionRoot = V3Space1.getSceneRoot
  42.     'Create the scene graph
  43.     Dim root As SoSeparator
  44.     Set root = New SoSeparator
  45.     Call selectionRoot.addChild(root)
  46.     'Add a sphere node
  47.     Dim sphereRoot As SoSeparator
  48.     Set sphereRoot = New SoSeparator
  49.     Dim sphereTransform As SoTransform
  50.     Set sphereTransform = New SoTransform
  51.     Call sphereTransform.translation.setValue(17#, 17#, 0#)
  52.     Call sphereTransform.scaleFactor.setValue(8#, 8#, 8#)
  53.     Call sphereRoot.addChild(sphereTransform)
  54.     Set sphereMaterial = New SoMaterial
  55.     Call sphereMaterial.diffuseColor.setValue(0.8, 0.8, 0.8)
  56.     Call sphereRoot.addChild(sphereMaterial)
  57.     Set mySphere = New SoSphere
  58.     Call sphereRoot.addChild(mySphere)
  59.     Call root.addChild(sphereRoot)
  60.     'Add a text node
  61.     Dim textRoot As SoSeparator
  62.     Set textRoot = New SoSeparator
  63.     Dim textTransform As SoTransform
  64.     Set textTransform = New SoTransform
  65.     Call textTransform.translation.setValue(0#, -1#, 0#)
  66.     Call textRoot.addChild(textTransform)
  67.     Set textMaterial = New SoMaterial
  68.     Call textMaterial.diffuseColor.setValue(0.8, 0.8, 0.8)
  69.     Call textRoot.addChild(textMaterial)
  70.     Dim textPickStyle As SoPickStyle
  71.     Set textPickStyle = New SoPickStyle
  72.     Call textPickStyle.Style.setValue(1) 'SoPickStyle::BOUNDING_BOX)
  73.     Call textRoot.addChild(textPickStyle)
  74.     Set myText = New SoText3
  75.     Call myText.Str.setValue("rhubarb")
  76.     Call textRoot.addChild(myText)
  77.     Call root.addChild(textRoot)
  78.     Call V3Space1.viewAll
  79.         
  80.     Call selectionRoot.addSelectionCallback(V3Space1.GetIDispatch(), g_selCB)
  81.     Call selectionRoot.addDeselectionCallback(V3Space1.GetIDispatch(), g_dselCB)
  82.         
  83. End Sub
  84. Private Sub Form_Unload(Cancel As Integer)
  85.     Set mySphere = Nothing
  86.     Set myText = Nothing
  87.     Set textMaterial = Nothing
  88.     Set sphereMaterial = Nothing
  89. End Sub
  90. Private Sub V3Space1_DeselectionCallback(ByVal pathCB As Object, ByVal path As Object)
  91.     Dim n As Object
  92.     Set n = path.getTail()
  93.     If n Is Nothing Then
  94.         GoTo cleanup
  95.     End If
  96.     If n.isOfType(myText.getClassTypeId()) Then
  97.         Call textMaterial.diffuseColor.setValue(0.8, 0.8, 0.8)
  98.     ElseIf n.isOfType(mySphere.getClassTypeId()) Then
  99.         Call sphereMaterial.diffuseColor.setValue(0.8, 0.8, 0.8)
  100.     End If
  101. cleanup:
  102.     Set pathCB = Nothing
  103.     Set path = Nothing
  104.     Set n = Nothing
  105. End Sub
  106. Private Sub V3Space1_SelectionCallback(ByVal pathCB As Object, ByVal path As Object)
  107.         
  108.     Dim n As Object
  109.     Set n = path.getTail()
  110.     If n Is Nothing Then
  111.         GoTo cleanup
  112.     End If
  113.     If n.isOfType(myText.getClassTypeId()) Then
  114.         Call textMaterial.diffuseColor.setValue(1#, 0.2, 0.2)
  115.     ElseIf n.isOfType(mySphere.getClassTypeId()) Then
  116.         Call sphereMaterial.diffuseColor.setValue(1#, 0.2, 0.2)
  117.     End If
  118. cleanup:
  119.     Set n = Nothing
  120.     Set pathCB = Nothing
  121.     Set path = Nothing
  122. End Sub
  123.