Hi,<br> the following is the VTK example: annotatePick.tcl.I want to convert it into VC++ and understand the usage of vtkpicker.<br> Who can help me?<br> Thanks a lot<br><br><br><br><br><br><br><br><br># This example demonstrates cell picking using vtkCellPicker. It displays<br># the results of picking using a vtkTextMapper.<br><br>#<br># First we include the VTK Tcl packages which will make available<br># all of the vtk commands to Tcl<br>#<br>package require vtk<br>package require vtkinteraction<br><br># create a sphere source, mapper, and actor<br>#<br>vtkSphereSource sphere<br><br>vtkPolyDataMapper sphereMapper<br> sphereMapper SetInput [sphere GetOutput]<br> sphereMapper GlobalImmediateModeRenderingOn<br>vtkLODActor sphereActor<br> sphereActor SetMapper sphereMapper<br><br># create the spikes by glyphing the sphere with a cone. Create the mapper<br># and actor for the glyphs.<br>vtkConeSource cone<br>vtkGlyph3D glyph<br> glyph SetInput [sphere GetOutput]<br> glyph SetSource [cone GetOutput]<br> glyph SetVectorModeToUseNormal<br> glyph SetScaleModeToScaleByVector<br> glyph SetScaleFactor 0.25<br>vtkPolyDataMapper spikeMapper<br> spikeMapper SetInput [glyph GetOutput]<br>vtkLODActor spikeActor<br> spikeActor SetMapper spikeMapper<br><br># Create a cell picker.<br>vtkCellPicker picker<br> picker AddObserver EndPickEvent annotatePick<br><br># Create a text mapper and actor to display the results of picking.<br>vtkTextMapper textMapper<br>set tprop [textMapper GetTextProperty]<br> $tprop SetFontFamilyToArial<br> $tprop SetFontSize 10<br> $tprop BoldOn<br> $tprop ShadowOn<br> $tprop SetColor 1 0 0<br>vtkActor2D textActor<br> textActor VisibilityOff<br> textActor SetMapper textMapper<br><br># Create the Renderer, RenderWindow, and RenderWindowInteractor<br>#<br>vtkRenderer ren1<br>vtkRenderWindow renWin<br> renWin AddRenderer ren1<br>vtkRenderWindowInteractor iren<br> iren SetRenderWindow renWin<br> iren SetPicker picker<br><br># Add the actors to the renderer, set the background and size<br>#<br>ren1 AddActor2D textActor<br>ren1 AddActor sphereActor<br>ren1 AddActor spikeActor<br>ren1 SetBackground 1 1 1<br>renWin SetSize 300 300<br><br># Get the camera and zoom in closer to the image.<br>set cam1 [ren1 GetActiveCamera]<br>$cam1 Zoom 1.4<br><br># Set the user method (bound to key 'u')<br>iren AddObserver UserEvent {wm deiconify .vtkInteract}<br>iren Initialize<br><br># Withdraw the default tk window<br>wm withdraw .<br><br># Create a Tcl procedure to create the text for the text mapper used to<br># display the results of picking.<br>proc annotatePick {} {<br> if { [picker GetCellId] < 0 } {<br>        textActor VisibilityOff<br><br> } else {<br>        set selPt [picker GetSelectionPoint]<br>        set x [lindex $selPt 0] <br>        set y [lindex $selPt 1]<br>        set pickPos [picker GetPickPosition]<br>        set xp [lindex $pickPos 0] <br>        set yp [lindex $pickPos 1]<br>        set zp [lindex $pickPos 2]<br><br>        textMapper SetInput "($xp, $yp, $zp)"<br>        textActor SetPosition $x $y<br>        textActor VisibilityOn<br> }<br><br> renWin Render<br>}<br><br># Pick the cell at this location.<br>picker Pick 85 126 0 ren1<br><br><font style='font-size:14.8px'> </font>
<table width="750" border="0" cellspacing="1" cellpadding="0">
<tr>
<td height="1" bgcolor="#09448E"> </td>
</tr>
<tr>
<td height="22"><font style='font-size:14.8px'><a href="http://www.126.com" target="_blank" style="text-decoration: none ;">·<b><font color=red>1.5G
</font></b>全国最大空间——网易126免费邮箱 http://www.126.com 火热抢注中>>> </a></font></td>
</tr>
<tr>
<td height="22"><font style='font-size:14.8px'><a href="http://www.126.com" target="_blank" style="text-decoration: none ;"> 体验30兆超大附件发送,享受100%卡巴斯基专业杀毒……更多超G感受等您来体验!</a>
</font></td>
</tr>
</table>
<font style='font-size:14.8px'><br>
<br>
<a href="http://www.126.com" target="_blank" style="text-decoration: none ;"><br>
</a></font> <font style='font-size:14.8px'> </font>