import time
import vtk

cnt = 1
fname = '/home/andre/tiffs/out'

#load order: non-occ, occ, left_gray, right_gray, scalp

def frame_write(fname, count, MainVTKWindow):
    pass
    #print 'ok'
    #global cnt
    #w2i = vtk.vtkWindowToImageFilter()
    #writer = vtk.vtkTIFFWriter()
    #w2i.SetInput(MainVTKWindow.GetRenderWindow())
    #w2i.Update()
    #writer.SetInputConnection(w2i.GetOutputPort())
    ##prompt_user_input()
    ##save_name = raw_input("Save file as ... :")
    #writer.SetFileName("%s%04d.tif" %(fname,count))
    ##remove_prompt_user_input()
    #writer.Write()
    #print 'saved main window to %s%04d.tif sucessfully' %(fname,count)


def animate(MainVTKWindow):
    global cnt
    
    t = vtk.vtkTransform()
    t.Translate(0,-40,-70)
    t.RotateX(-12.5)

    print MainVTKWindow.ListOfObjects[-2].SetUserTransform(t)
    
    kajsdhfakjsd
    MainVTKWindow.widget.Render()
    print MainVTKWindow.ListOfObjects
    print MainVTKWindow.ListOfObjects[-1].GetBounds()
    print MainVTKWindow.ListOfObjects[-1].GetOrigin()
    print MainVTKWindow.ListOfObjects[-1].GetOrientation()
    print MainVTKWindow.ListOfObjects[-2].GetBounds()
    print MainVTKWindow.ListOfObjects[-2].GetOrigin()
    print MainVTKWindow.ListOfObjects[-2].GetOrientation()
    MainVTKWindow.ListOfObjects[-2].SetOrigin(-19.7908535, 250.5694122,175.2605133)
    #MainVTKWindow.ListOfObjects[-2].Modified()
    MainVTKWindow.ListOfObjects[-1].SetOrigin(-158.6321564, 250.0726929,175.6038361)
    #MainVTKWindow.ListOfObjects[-1].Modified()
    for i in range(1,46):
        MainVTKWindow.ListOfObjects[-1].SetOrientation(0,0,i)
        MainVTKWindow.ListOfObjects[-2].SetOrientation(0,0,-i)
        MainVTKWindow.widget.Render()
        time.sleep(0.1)
