Hi Jean-Pierre,<br><br>I've checked and your example is identical to my CVS-checkout of VTK. Additionally when i copy/paste your code in a file, and run it in python, the example works. I assume you understand that the picking occurs when pressing the 'p'-button after navigating your mouse to the point you want to pick and not the mouse button. If not... that's your solution! :-). Otherwise we need more clues (error messages perhaps?) on what's going on.
<br><br>Regards - Geoframer<br><br><div><span class="gmail_quote">On 9/3/07, <b class="gmail_sendername">jb116896</b> <<a href="mailto:jean-pierre.both@cea.fr">jean-pierre.both@cea.fr</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello everybody,<br><br>having problem to get a text annotation of a picking<br>I checked the example in Examples/Annotation/Python downloaded with my<br>5.0.3 version of Vtk<br>and it doesn not work. I get no display of text
<br><br>here is the script :<br><br>========================================================<br><br>!/usr/bin/env python<br><br># This example demonstrates cell picking using vtkCellPicker. It<br># displays the results of picking using a vtkTextMapper.
<br><br>import vtk<br><br># create a sphere source, mapper, and actor<br>sphere = vtk.vtkSphereSource()<br>sphereMapper = vtk.vtkPolyDataMapper()<br>sphereMapper.SetInputConnection(sphere.GetOutputPort())<br>sphereMapper.GlobalImmediateModeRenderingOn
()<br>sphereActor = vtk.vtkLODActor()<br>sphereActor.SetMapper(sphereMapper)<br><br># create the spikes by glyphing the sphere with a cone. Create the<br># mapper and actor for the glyphs.<br>cone = vtk.vtkConeSource()<br>
glyph = vtk.vtkGlyph3D()<br>glyph.SetInputConnection(sphere.GetOutputPort())<br>glyph.SetSource(cone.GetOutput())<br>glyph.SetVectorModeToUseNormal()<br>glyph.SetScaleModeToScaleByVector()<br>glyph.SetScaleFactor(0.25)<br>
spikeMapper = vtk.vtkPolyDataMapper()<br>spikeMapper.SetInputConnection(glyph.GetOutputPort())<br>spikeActor = vtk.vtkLODActor()<br>spikeActor.SetMapper(spikeMapper)<br><br># Create a text mapper and actor to display the results of picking.
<br>textMapper = vtk.vtkTextMapper()<br>tprop = textMapper.GetTextProperty()<br>tprop.SetFontFamilyToArial()<br>tprop.SetFontSize(10)<br>tprop.BoldOn()<br>tprop.ShadowOn()<br>tprop.SetColor(1, 0, 0)<br>textActor = vtk.vtkActor2D
()<br>textActor.VisibilityOff()<br>textActor.SetMapper(textMapper)<br><br># Create a cell picker.<br>picker = vtk.vtkCellPicker()<br><br># Create a Python function to create the text for the text mapper used<br># to display the results of picking.
<br>def annotatePick(object, event):<br> global picker, textActor, textMapper<br> if picker.GetCellId() < 0:<br> textActor.VisibilityOff()<br> else:<br> selPt = picker.GetSelectionPoint()<br> pickPos =
picker.GetPickPosition()<br> textMapper.SetInput("(%.6f, %.6f, %.6f)"%pickPos)<br> textActor.SetPosition(selPt[:2])<br> textActor.VisibilityOn()<br><br># Now at the end of the pick event call the above function.
<br>picker.AddObserver("EndPickEvent", annotatePick)<br><br># Create the Renderer, RenderWindow, etc. and set the Picker.<br>ren = vtk.vtkRenderer()<br>renWin = vtk.vtkRenderWindow()<br>renWin.AddRenderer(ren)<br>
iren = vtk.vtkRenderWindowInteractor()<br>iren.SetRenderWindow(renWin)<br>iren.SetPicker(picker)<br><br># Add the actors to the renderer, set the background and size<br>ren.AddActor2D(textActor)<br>ren.AddActor(sphereActor)
<br>ren.AddActor(spikeActor)<br>ren.SetBackground(1, 1, 1)<br>renWin.SetSize(300, 300)<br><br># Get the camera and zoom in closer to the image.<br>ren.ResetCamera()<br>cam1 = ren.GetActiveCamera()<br>cam1.Zoom(1.4)<br><br>
iren.Initialize()<br># Initially pick the cell at this location.<br>picker.Pick(85, 126, 0, ren)<br>renWin.Render()<br>iren.Start()<br><br>===============================================================<br><br><br>Any solution to this problem ?
<br><br>Thanks a lot<br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ
</a><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br>