Changeset - 9de7bbf50267
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 20 years ago 2005-06-17 03:49:07
drewp@bigasterisk.com
curvecalc fixes, especially a slowdown of the updates that's working better
2 files changed with 15 insertions and 13 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -297,15 +297,16 @@ def updateerr(e):
 
    dispatcher.send("update status",val=e.getErrorMessage())
 
    if later and not later.cancelled and not later.called: later.cancel()
 
    later = reactor.callLater(1,update)
 
def update2(t):
 
    global recent_t,later
 
    dispatcher.send("update status",
 
                    val="ok: receiving times from music player")
 
                    val="ok: receiving time from music player")
 
    if later and not later.cancelled and not later.called: later.cancel()
 
    later = reactor.callLater(.01,update)
 
    
 
    later = reactor.callLater(.05,update)
 

	
 
    recent_t = recent_t[-50:]+[t]
 
    period = (recent_t[-1]-recent_t[0])/len(recent_t)
 
    dispatcher.send("update period",val=period)
 
    out.send_dmx(t)
 
update()
 
@@ -314,13 +315,13 @@ update()
 
#    print "log",msg
 
#twisted.python.log.addObserver(logprint)
 

	
 
root.bind("<Control-Key-q>",lambda ev: reactor.stop)
 
root.bind("<Destroy>",lambda ev: reactor.stop)
 
root.protocol('WM_DELETE_WINDOW', reactor.stop)
 
tksupport.install(root,ms=10)
 
tksupport.install(root,ms=20)
 
if 0:
 
    sys.path.append("/home/drewp/projects/editor/pour")
 
    sys.path.append("/home/drewp/projects/cuisine/pour")
 
    from utils import runstats
 
    runstats("reactor.run()")
 
else:
 
    reactor.run()
light9/curve.py
Show inline comments
 
@@ -55,18 +55,18 @@ class Curveview(tk.Canvas):
 
        self.curve=curve
 
        self._time = 0
 
        tk.Canvas.__init__(self,master,width=10,height=10,
 
                           relief='sunken',bd=1,
 
                           closeenough=5,takefocus=1, **kw)
 
        self.selected_points=[] # idx of points being dragged
 
        self.update()
 
        self.update_curve()
 
        # self.bind("<Enter>",self.focus)
 
        dispatcher.connect(self.input_time,"input time")
 
        dispatcher.connect(self.update,"zoom changed")
 
        dispatcher.connect(self.update,"points changed",sender=self.curve)
 
        self.bind("<Configure>",self.update)
 
        dispatcher.connect(self.update_curve,"zoom changed")
 
        dispatcher.connect(self.update_curve,"points changed",sender=self.curve)
 
        self.bind("<Configure>",self.update_curve)
 
        for x in range(1, 6):
 
            def add_kb_marker_point(evt, x=x):
 
                print "add_kb_marker_point", evt
 
                self.add_point((self.current_time(), (x - 1) / 4.0))
 

	
 
            self.bind("<Key-%s>" % x, add_kb_marker_point)
 
@@ -101,13 +101,13 @@ class Curveview(tk.Canvas):
 
    def input_time(self,val):
 
        t=val
 
        pts = self.screen_from_world((val,0))+self.screen_from_world((val,1))
 
        self.delete('timecursor')
 
        self.create_line(*pts,**dict(width=2,fill='red',tags=('timecursor',)))
 
        self._time = t
 
    def update(self,*args):
 
    def update_curve(self,*args):
 

	
 
        self.zoom = dispatcher.send("zoom area")[0][1]
 
        cp = self.curve.points
 

	
 
        visible_x = (self.world_from_screen(0,0)[0],
 
                     self.world_from_screen(self.winfo_width(),0)[0])
 
@@ -157,15 +157,16 @@ class Curveview(tk.Canvas):
 
            endtime = endtimes[0][1]
 
            mark(endtime,"end %.1f"%endtime)
 
            mark(endtime+10,"post %.1f"%(endtime+10))
 
        
 
    def _draw_one_marker(self,t,label):
 
        x = self.screen_from_world((t,0))[0]
 
        self.create_line(x,self.winfo_height(),x,self.winfo_height()-20,
 
        ht = self.winfo_height()
 
        self.create_line(x,ht,x,ht-20,
 
                         tags=('curve',))
 
        self.create_text(x,self.winfo_height()-20,text=label,anchor='s',
 
        self.create_text(x,ht-20,text=label,anchor='s',
 
                         tags=('curve',))
 

	
 

	
 
    def _draw_line(self,visible_points):
 
        linepts=[]
 
        step=1
 
@@ -221,13 +222,13 @@ class Curveview(tk.Canvas):
 
        p = x, y
 
        self.add_point(p)
 

	
 
    def add_point(self, p):
 
        self.unselect()
 
        self.curve.insert_pt(p)
 
        self.update()
 
        self.update_curve()
 

	
 
    def highlight_selected_dots(self):
 
        for i,d in self.dots.items():
 
            if i in self.selected_points:
 
                self.itemconfigure(d,fill='red')
 
            else:
 
@@ -247,13 +248,13 @@ class Curveview(tk.Canvas):
 
                continue
 
            if idx<len(cp)-1 and x>=cp[idx+1][0]:
 
                continue
 
            moved=1
 
            cp[idx] = (x,y)
 
        if moved:
 
            self.update()
 
            self.update_curve()
 
    def unselect(self):
 
        self.selected_points=[]
 
        self.highlight_selected_dots()
 
        
 
    def dotrelease(self,ev,dotidx):
 
        self.unselect()
0 comments (0 inline, 0 general)