title: vtkRenderWindowInteractor stalling program
body: <p>I've been working on a prototype application in Python for stereoscopic imaging of a 3D model using VTK, but I'm running into some issues on the interface end of things. The goal of the code below at the moment is to zoom in on both renderWindows when the middlemouse is pressed. However, upon calling the <code>vtkRenderWindowInteractor.Start()</code> function, my <code>vtkRenderWindowInteractor</code>s are effectively stalling out the entire program as if they were being run in the same thread. Even more curious is that keyboard interrupts are not being thrown when I use CTRL-C (I'm working in UNIX shell) until I close the render windows manually using the 'x' button. If I just close the window manually without hitting CTRL-C, the program picks up directly after the <code>Start()</code> call (e.g. in the code below, the infinite while loop). I've provided a sequence of screen captures at the end of this post to visualize exactly what is happening in the case that my explanation is confusing.</p>
  
  <p>I've tried multiple workarounds to remedy this but none so far have worked. Threading the renders into isolated threads made no difference even when I tried using ncurses for input, while forking them to a new process resulted in some OS issues that I'd rather not deal with. The most current interactor styles method (shown below) where I just use built-in VTK listeners works to a degree, allowing me to detect inputs when the windows are in focus and the interactors are active, but because of the lack of association between the camera and the <code>MyInteractorStyle</code> class, I can't really access the cameras without the inclusion a loop after the <code>Start()</code> call, which leads me right back to where I started. </p>
  
  <p>Any thoughts? Am I just misunderstanding how VTK's render tools are supposed to be used?</p>
  
  <pre><code>from vtk import*
  import os.path
  #import thread
  #import time
  #import threading 
  #import curses
  
  class MyInteractorStyle(vtk.vtkInteractorStyleTrackballCamera):
  
          pos1 = [0, 0, 200]
          foc1 = [0, 0, 0]
          pos2 = [40, 0, 200]
          foc2 = [0, 0, 0]
  
          def __init__(self,parent=None):
                  self.AddObserver("MiddleButtonPressEvent", self.middleButtonPressEvent)
                  self.AddObserver("MiddleButtonReleaseEvent", self.middleButtonReleaseEvent)
          def middleButtonPressEvent(self,obj,event):
                  print "Middle button pressed"
                  self.pos1[2] += 10
                  self.pos2[2] += 30
                  self.OnMiddleButtonDown()
                  return
          def middleButtonReleaseEvent(self,obj,event):
                  print "Middle button released"
                  self.OnMiddleButtonUp()
                  return
  def main():
  
  
          # create two cameras
          camera1 = vtkCamera()
          camera1.SetPosition(0,0,200)
          camera1.SetFocalPoint(0,0,0)
  
          camera2 = vtkCamera()
          camera2.SetPosition(40,0,200)
          camera2.SetFocalPoint(0,0,0)
  
  
          # create a rendering window and renderer
          ren1 = vtkRenderer()
          ren1.SetActiveCamera(camera1)
  
          ren2 = vtkRenderer()
          ren2.SetActiveCamera(camera2)
  
          # create source
          reader = vtkPolyDataReader()
          path = "/home/compilezone/Documents/3DSlicer/SlicerScenes/LegoModel-6_25/Model_5_blood.vtk"
          reader.SetFileName(path)
          print(path)
          reader.Update()
  
          # create render window
  
          renWin1 = vtkRenderWindow()
          renWin1.AddRenderer(ren1)
  
          renWin2 = vtkRenderWindow()
          renWin2.AddRenderer(ren2)
  
          # create a render window interactor
  
          inputHandler = MyInteractorStyle()
  
          iren1 = vtkRenderWindowInteractor()
          iren1.SetRenderWindow(renWin1)
          iren1.SetInteractorStyle(inputHandler)
  
          iren2 = vtkRenderWindowInteractor()
          iren2.SetRenderWindow(renWin2)
          iren2.SetInteractorStyle(inputHandler)
  
          # mapper
          mapper = vtkPolyDataMapper()
          mapper.SetInput(reader.GetOutput())
  
          # actor
          actor = vtkActor()
          actor.SetMapper(mapper)
  
          # assign actor to the renderer
          ren1.AddActor(actor)
          ren2.AddActor(actor)
  
          # enable user interface interactor
          iren1.Initialize()
          iren2.Initialize()
          renWin1.Render()
          renWin2.Render()
          iren1.Start()
          iren2.Start()
          print "Test"
          while 1:
                  pos1 = iren1.GetInteractorStyle().pos1
                  foc1 = iren1.GetInteractorStyle().foc1
                  pos2 = iren2.GetInteractorStyle().pos2
                  foc2 = iren2.GetInteractorStyle().foc2
                  print     
  
  if __name__ == '__main__':
          main()  
  </code></pre>
  
  <p>Program running
  <img src="https://i.stack.imgur.com/7WWDW.png" alt="">
  KeyboardInterrupt (CTRL-C hit and echoed in terminal but nothing happens)
  <img src="https://i.stack.imgur.com/u5Cxs.png" alt="">
  Render windows manually closed, KeyboardInterrupt thrown
  <img src="https://i.stack.imgur.com/0rvDN.png" alt=""></p>