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

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "12_2 Node Sensor"
  4.    ClientHeight    =   6795
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1425
  7.    ClientWidth     =   6390
  8.    Height          =   7170
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6795
  12.    ScaleWidth      =   6390
  13.    Top             =   1110
  14.    Width           =   6510
  15.    Begin VB.TextBox fieldName 
  16.       Enabled         =   0   'False
  17.       Height          =   375
  18.       Left            =   4560
  19.       TabIndex        =   5
  20.       Top             =   5760
  21.       Width           =   1815
  22.    End
  23.    Begin VB.TextBox nodeName 
  24.       Enabled         =   0   'False
  25.       Height          =   375
  26.       Left            =   4560
  27.       TabIndex        =   1
  28.       Top             =   5280
  29.       Width           =   1815
  30.    End
  31.    Begin VB.Label Label8 
  32.       Caption         =   "Changes Detected"
  33.       Height          =   255
  34.       Left            =   3480
  35.       TabIndex        =   13
  36.       Top             =   4680
  37.       Width           =   1455
  38.    End
  39.    Begin VB.Label Label7 
  40.       Caption         =   "Adjust the sliders to trigger the Node Sensor"
  41.       Height          =   375
  42.       Left            =   120
  43.       TabIndex        =   12
  44.       Top             =   4680
  45.       Width           =   3015
  46.    End
  47.    Begin VB.Label Label6 
  48.       Caption         =   "Cube Width"
  49.       Height          =   255
  50.       Left            =   120
  51.       TabIndex        =   11
  52.       Top             =   6240
  53.       Width           =   1095
  54.    End
  55.    Begin VB.Label Label5 
  56.       Caption         =   "Cube Height"
  57.       Height          =   255
  58.       Left            =   120
  59.       TabIndex        =   10
  60.       Top             =   5760
  61.       Width           =   1215
  62.    End
  63.    Begin VB.Label Label4 
  64.       Caption         =   "Sphere Radius"
  65.       Height          =   375
  66.       Left            =   120
  67.       TabIndex        =   9
  68.       Top             =   5280
  69.       Width           =   1215
  70.    End
  71.    Begin VB.Label Label3 
  72.       Caption         =   "Field Name"
  73.       Height          =   255
  74.       Left            =   3480
  75.       TabIndex        =   8
  76.       Top             =   5760
  77.       Width           =   855
  78.    End
  79.    Begin VB.Label Label2 
  80.       Caption         =   "Node Name"
  81.       Height          =   255
  82.       Left            =   3480
  83.       TabIndex        =   7
  84.       Top             =   5280
  85.       Width           =   975
  86.    End
  87.    Begin VB.Label Label1 
  88.       Caption         =   "This example demonstrates the use of a SoNodeSensor to detect changes to nodes in the scene graph."
  89.       BeginProperty Font 
  90.          name            =   "MS Sans Serif"
  91.          charset         =   0
  92.          weight          =   400
  93.          size            =   12
  94.          underline       =   0   'False
  95.          italic          =   0   'False
  96.          strikethrough   =   0   'False
  97.       EndProperty
  98.       Height          =   735
  99.       Left            =   120
  100.       TabIndex        =   6
  101.       Top             =   0
  102.       Width           =   6135
  103.    End
  104.    Begin ComctlLib.Slider boxHeight 
  105.       Height          =   375
  106.       Left            =   1440
  107.       TabIndex        =   4
  108.       Top             =   5760
  109.       Width           =   1455
  110.       _Version        =   65536
  111.       _ExtentX        =   2566
  112.       _ExtentY        =   661
  113.       _StockProps     =   64
  114.       LargeChange     =   1
  115.       Max             =   3
  116.    End
  117.    Begin ComctlLib.Slider boxWidth 
  118.       Height          =   375
  119.       Left            =   1440
  120.       TabIndex        =   3
  121.       Top             =   6240
  122.       Width           =   1455
  123.       _Version        =   65536
  124.       _ExtentX        =   2566
  125.       _ExtentY        =   661
  126.       _StockProps     =   64
  127.       LargeChange     =   1
  128.       Max             =   3
  129.    End
  130.    Begin ComctlLib.Slider sphere 
  131.       Height          =   390
  132.       Left            =   1440
  133.       TabIndex        =   2
  134.       Top             =   5280
  135.       Width           =   1455
  136.       _Version        =   65536
  137.       _ExtentX        =   2566
  138.       _ExtentY        =   688
  139.       _StockProps     =   64
  140.       LargeChange     =   1
  141.       Max             =   3
  142.    End
  143.    Begin TgsVisual3SpaceLibCtl.V3Space V3Space1 
  144.       Height          =   3735
  145.       Left            =   0
  146.       TabIndex        =   0
  147.       Top             =   840
  148.       Width           =   6375
  149.       _Version        =   131072
  150.       _ExtentX        =   11245
  151.       _ExtentY        =   6588
  152.       _StockProps     =   0
  153.       decorationOn    =   0   'False
  154.       viewingOn       =   0   'False
  155.    End
  156. Attribute VB_Name = "Form1"
  157. Attribute VB_Creatable = False
  158. Attribute VB_Exposed = False
  159.     Dim myCube As SoCube
  160.     Dim mySphere As SoSphere
  161. Private Sub boxHeight_Change()
  162.     Call myCube.Height.setValue(boxHeight.Value)
  163. End Sub
  164. Private Sub boxWidth_Change()
  165.     Call myCube.Width.setValue(boxWidth.Value)
  166. End Sub
  167. Private Sub Form_Initialize()
  168.     Dim root As SoSeparator
  169.     Set root = New SoSeparator
  170.     Call root.setName("Root")
  171.     Set myCube = New SoCube
  172.     Call root.addChild(myCube)
  173.     Call myCube.setName("Cube")
  174.     Dim tran As SoTranslation
  175.     Set tran = New SoTranslation
  176.     Call tran.translation.setValue(3, 0, 0)
  177.     Call root.addChild(tran)
  178.     Set mySphere = New SoSphere
  179.     Call root.addChild(mySphere)
  180.     Call mySphere.setName("Sphere")
  181.     Call V3Space1.setSceneRoot(root)
  182.     Call V3Space1.viewAll
  183.     Static sensorCB As SoSensorCB
  184.     Set sensorCB = New SoSensorCB
  185.     sensorCB.sensorType = 6 'nodeSensor
  186.     Dim mySensor As SoNodeSensor
  187.     Set mySensor = New SoNodeSensor
  188.     Call mySensor.setPriority(0)
  189.     Dim idisp As Object
  190.     Set idisp = V3Space1.GetIDispatch
  191.     Call mySensor.setFunction(idisp, sensorCB)
  192.     Call mySensor.attach(root)
  193.     sphere.Value = mySphere.radius.getValue
  194.     boxWidth.Value = myCube.Width.getValue
  195.     boxHeight.Value = myCube.Height.getValue
  196. End Sub
  197. Private Sub Slider1_Change()
  198.     Call mySphere.radius.setValue
  199. End Sub
  200. Private Sub Slider1_Click()
  201. End Sub
  202. Private Sub Form_Unload(Cancel As Integer)
  203.     Set myCube = Nothing
  204.     Set mySphere = Nothing
  205. End Sub
  206. Private Sub sphere_Change()
  207.     Call mySphere.radius.setValue(sphere.Value)
  208. End Sub
  209. Private Sub V3Space1_NodeSensor(ByVal sensorCB As Object, ByVal sensor As Object)
  210.     'We know the sensor is really a data sensor:
  211.     Dim changedNode As Object
  212.     Set changedNode = sensor.getTriggerNode()
  213.     Dim changedField As Object
  214.     Set changedField = sensor.getTriggerField()
  215.     If changedNode Is Nothing Then
  216.         GoTo cleanup
  217.     End If
  218.     nodeName.Text = changedNode.getName()
  219.     If changedField Is Nothing Then
  220.         GoTo cleanup
  221.     End If
  222.     Dim fn As SbName
  223.     Call changedNode.getFieldName(changedField, fn)
  224.     If fn Is Nothing Then
  225.         GoTo cleanup
  226.     End If
  227.     fieldName.Text = fn.getString()
  228.    'if (changedField != NULL) {
  229.    '   SbName fieldName;
  230.    '   changedNode->getFieldName(changedField, fieldName);
  231.    '   printf(" (field %s)\n", fieldName.getString());
  232.    '} else {
  233.    '   printf(" (no fields changed)\n");
  234.    '}
  235. cleanup:
  236.     Set changedNode = Nothing
  237.     Set changedField = Nothing
  238.     Set sensorCB = Nothing
  239.     Set sensor = Nothing
  240. End Sub
  241.