from Tkinter import *
from visual import *
from random import *

import time,sys,thread


kSpaceW = display(title='k Space', width=300, height=300, x=720, y=530, center=(pi,pi,0), background=(.95,.95,.95))
kSpaceW.fov = 0.001

kSpaceW.userzoom = 0
kSpaceW.userspin = 0
kSpaceW.range = 1.1*pi
kSpaceW.visible = 1


xAxis = []
for x in arange(0.0,2.0*pi+.1,2.0*pi):    xAxis.append(vector(x,pi,0.0))
xAxisLine = curve(pos=xAxis, color=(.0,.0,.0))

yAxis = []
for y in arange(0.0,2.0*pi+.1,2.0*pi):    yAxis.append(vector(pi,y,0.0))
yAxisLine = curve(pos=yAxis, color=(.0,.0,.0))



class kSpace:
    k = vector(0.0,0.0,0.0)
    kInputPoint = sphere(pos=vector(0.0,0.0,0.0), color=(0.5,0.5,0.9), radius=0.1)
    
    def __init__(self,parent):
        self.parent = parent
        thread.start_new_thread(self.watch,())
                
    def watch(self):
        while 1:
            if kSpaceW.mouse.events:
                kPoint = kSpaceW.mouse.getclick().pos
                  
                self.k.x = kPoint[0]
                self.k.y = kPoint[1]
               
                self.setkValues(kPoint)
                

    def setkValues(self,kInput):       
        self.kInputPoint.pos = vector(kInput[0],kInput[1],0.0)
        self.parent.kxWidget.set(kInput[0])
        self.parent.kyWidget.set(kInput[1])





