Changeset - f0f9e136b0cb
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 years ago 2005-06-15 03:20:12
drewp@bigasterisk.com
new curves now span the full range of the song
1 file changed with 11 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light9/curve.py
Show inline comments
 
@@ -4,25 +4,25 @@ from bisect import bisect_left,bisect,bi
 
import Tkinter as tk
 
from dispatch import dispatcher
 

	
 
import run_local
 
from light9 import Submaster, dmxclient, networking, cursors
 
from light9.TLUtility import make_attributes_from_args
 
from light9.dmxchanedit import gradient
 

	
 
class Curve:
 
    """curve does not know its name. see Curveset"""
 
    points = None # x-sorted list of (x,y)
 
    def __init__(self):
 
        self.points = [(0,0),(10,0)]
 
        self.points = []
 

	
 
    def load(self,filename):
 
        self.points[:]=[]
 
        for line in file(filename):
 
            self.points.append(tuple([float(a) for a in line.split()]))
 
        self.points.sort()
 
        dispatcher.send("points changed",sender=self)
 

	
 
    def save(self,filename):
 
        if filename.endswith('-music') or filename.endswith('_music'):
 
            print "not saving music track"
 
            return
 
@@ -352,48 +352,57 @@ class Curveset:
 
            c=Curve()
 
            c.load(filename)
 
            curvename = curvename.replace('-','_')
 
            self.add_curve(curvename,c)            
 
    def save(self,basename):
 
        """writes a file for each curve with a name
 
        like basename-curvename"""
 
        for name,cur in self.curves.items():
 
            cur.save("%s-%s" % (basename,name))
 
    def add_curve(self,name,curve):
 
        self.curves[name] = curve
 
        dispatcher.send("add_curve",sender=self,name=name)
 

	
 
    def globalsdict(self):
 
        return self.curves.copy()
 
    
 
    def get_time_range(self):
 
        return -4, dispatcher.send("get max time")[0][1]+15
 

	
 
    def new_curve(self,name):
 
        if name=="":
 
            print "no name given"
 
            return
 
        while name in self.curves:
 
           name=name+"-1"
 

	
 
        self.add_curve(name,Curve())
 
        c = Curve()
 
        s,e = self.get_time_range()
 
        c.points.extend([(s,0), (e,0)])
 
        self.add_curve(name,c)
 

	
 

	
 
class Curvesetview(tk.Frame):
 
    curves = None # curvename : Curveview
 
    def __init__(self,master,curveset,**kw):
 
        self.curves = {}
 
        self.curveset = curveset
 
        tk.Frame.__init__(self,master,**kw)
 
        
 
        f = tk.Frame(self,relief='raised',bd=1)
 
        f.pack(side='top',fill='x')
 
        tk.Button(f,text="new curve named:",
 
                  command=lambda: self.curveset.new_curve(self.newcurvename.get())).pack(side='left')
 
        self.newcurvename = tk.StringVar()
 
        tk.Entry(f,textvariable=self.newcurvename).pack(side='left',
 
                                                        fill='x',exp=1)
 
        
 
        
 
        dispatcher.connect(self.add_curve,"add_curve",sender=self.curveset)
 
        
 
    def add_curve(self,name):
 
        f = tk.Frame(self,relief='raised',bd=1)
 
        f.pack(side='top',fill='both',exp=1)
 
        tk.Label(f,text="curve %r"%name,width=15).pack(side='left')
 
        cv = Curveview(f,self.curveset.curves[name])
 
        cv.pack(side='right',fill='both',exp=1)
 
        self.curves[name] = cv
0 comments (0 inline, 0 general)