<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>I'm trying to create a class that manages a custom set of interactions in python and having some trouble hooking to key and mouse events. <br><br>In the CustomInteraction.py example (<a href="http://vtk.org/gitweb?p=VTK.git;a=blob_plain;f=Examples/GUI/Python/CustomInteraction.py">http://vtk.org/gitweb?p=VTK.git;a=blob_plain;f=Examples/GUI/Python/CustomInteraction.py</a>) it is recommended that you should subclass vtkInteractorStyle to do this (instead of observers).<br>
<br></div>I've built a test class called Interactor3rdPerson that should override the normal events, where at the moment I'm trying to catch the keyboard and mouse events at the 'i=0' places in debug:<br>class Interactor3rdPerson(vtk.vtkInteractorStyleUser):<br>
<br> # The tracked object.<br> __trackedObject = None<br> <br> def __init__(self, trackedSceneObject):<br> self.__trackedObject = trackedSceneObject<br> <br> i= 0<br> <br> # Overridden update method <br>
def OnTimer(self): <br> i = 0<br> <br> def OnKeyPress(self):<br> i = 0<br> <br> def OnKeyRelease(self):<br> i = 0<br> <br> def OnLeftButtonDown(self):<br> i = 0<br>
<br></div>In the main program I assign this to the render window interactor:<br><br>...<br></div> # Change the interactor to the new camera<br><div> interactor = Interactor3rdPerson.Interactor3rdPerson(axes)<br><div>
# axes is a scene object, but it isn't used yet<br></div><br> # An interactor<br> renderWindowInteractor = vtk.vtkRenderWindowInteractor()<br> renderWindowInteractor.SetInteractorStyle(interactor)<br> <br>
renderWindowInteractor.SetRenderWindow(renderWindow)<br> # renderWindowInteractor.CreateTimer(0)<br> interactor.EnabledOn()<br><br><br> # Render an image (lights and cameras are created automatically)<br> renderWindow.Render()<br>
<br> # Begin mouse interaction<br> renderWindowInteractor.Start()<br> renderWindowInteractor.Initialize()<br><br></div>The issue is that I don't seem to be catching any input events. The normal inputs are being triggered (I can pick and turn
wireframes on) but I don't see any catches when putting breakpoints at
the 'i=0' places in the custom interactor. Is there something that I'm missing or should be enabling? <br><br></div>Thanks,<br>Sam<br></div>