<div class="gmail_quote">I haven't seen any responses to this post so I'm including some code which demonstrates the problem. I'm looking for an example (preferably in Python) of how to pick a vtkAxesActor. I need to be able to distinguish between picks of the X, Y, and Z axes. I am currently able to pick other OpenGL actors. But trying to pick any of the axes is the same as picking nothing. I have tried setting PickableOn but it didn't help. Is there some setting to use with vtkOrientationMarkerWidget?<br>
<br>
Thank you.<br><font color="#888888">
<br>
Lee Gross<br>
Amoeba Technologies, Inc.<br>
<br>========================<br><br>#!/usr/bin/env python<br><br>import vtk<br><br>def handle_pick(obj, event):<br> # Print the picked actor type, if any<br> picker = vtk.vtkPropPicker()<br> mousePos = obj.GetEventPosition()<br>
picker.PickProp(mousePos[0], mousePos[1], ren)<br> pickedActor = picker.GetActor()<br> print "picked actor type=", type(pickedActor)<br><br><br># Create the usual rendering stuff<br>ren = vtk.vtkRenderer()<br>
renWin = vtk.vtkRenderWindow()<br>renWin.AddRenderer(ren)<br>iren = vtk.vtkRenderWindowInteractor()<br>iren.SetRenderWindow(renWin)<br>iren.AddObserver("LeftButtonPressEvent", handle_pick)<br><br>istyle = vtk.vtkInteractorStyleSwitch()<br>
iren.SetInteractorStyle(istyle)<br>istyle.SetCurrentStyleToTrackballCamera()<br><br># Create reference axes<br>axes = vtk.vtkAxesActor()<br>axes.SetShaftTypeToCylinder()<br>axes.PickableOn()<br><br>marker = vtk.vtkOrientationMarkerWidget()<br>
marker.SetOrientationMarker(axes)<br>marker.SetViewport(0, 0, 0.3, 0.3)<br>marker.SetInteractor(iren)<br>marker.EnabledOn()<br>marker.InteractiveOff()<br>marker.KeyPressActivationOff()<br><br># Create a box<br>box = vtk.vtkCubeSource()<br>
mapper = vtk.vtkPolyDataMapper()<br>mapper.SetInput(box.GetOutput())<br>boxActor = vtk.vtkActor()<br>boxActor.SetMapper(mapper)<br><br># Add the actor to the renderer, set the background and size<br>ren.AddActor(boxActor)<br>
ren.SetBackground(0.1, 0.2, 0.2)<br>renWin.SetSize(500, 500)<br>ren.ResetCamera()<br>ren.ResetCameraClippingRange()<br><br>iren.Initialize()<br>renWin.Render()<br>iren.Start()<br><br>
<br>
<br>
</font></div><br>