[vtkusers] Translating small python code snippet to c++
    Prename Surname 
    bsd.diverse at gmail.com
       
    Wed Nov  1 08:41:13 EST 2006
    
    
  
Hello. I am making a userinterface, and i need to capture keyboard events.
I have found this codesnippet written in python, but i cannot really
translate it into C++.
It is especially the lines
 def Keypress(obj, event):
 global mpr, mip, surface
that i dont know how to translate..If someone could just help me with those
2 lines i would be grateful.
Thank you all
Snippet :
 def Keypress(obj, event):
  global mpr, mip, surface
  key = obj.GetKeySym()
  if key == "1":
   if mpr:
    planeX.EnabledOff()
    planeY.EnabledOff()
    planeZ.EnabledOff()
    mpr = 0
   else:
    planeX.EnabledOn()
    planeY.EnabledOn()
    planeZ.EnabledOn()
    mpr = 1
  elif key == "2":
   if mip:
    volume.VisibilityOff()
    mip = 0
    renWin.Render()
   else:
    volume.VisibilityOn()
    mip = 1
    renWin.Render()
  elif key == "3":
   if surface:
    surfaceActor.VisibilityOff()
    surface = 0
    renWin.Render()
   else:
    surfaceActor.VisibilityOn()
    surface = 1
    renWin.Render()
 def ButtonEvent(obj, event):
  planeX.EnabledOff()
  planeY.EnabledOff()
  planeZ.EnabledOff()
 iren.AddObserver("KeyPressEvent", Keypress)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061101/afa6a4d5/attachment.htm>
    
    
More information about the vtkusers
mailing list