Changeset - 2f2eb802e93d
[Not reviewed]
default
0 2 0
dmcc - 22 years ago 2002-07-09 08:35:27

stage shows levels now. aims have blue halo for easy recognition.
stage shows levels now. aims have blue halo for easy recognition.
old dummy config stored
2 files changed with 47 insertions and 28 deletions:
0 comments (0 inline, 0 general)
light8/Lightboard.py
Show inline comments
 
@@ -35,22 +35,24 @@ class Lightboard:
 
        self.subediting = Subediting(currentoutputlevels=self.oldlevels)
 

	
 
        self.get_data()
 
        self.buildinterface()
 
        self.load()
 
        self.backgroundloop()
 
        self.updatestagelevels()
 
        
 
    def buildinterface(self):
 
        for w in self.master.winfo_children():
 
            w.destroy()
 

	
 
        stage_tl = toplevelat(22,30)
 
        s = stage.Stage(stage_tl)
 
        stage.createlights(s)
 
        s.setsubediting(self.subediting)
 
        s.pack()
 
        self.stage = s # save it
 

	
 
        sub_tl = toplevelat(0,0,w=440,h=610)
 
        effect_tl = toplevelat(462,4)
 

	
 
        self.subpanels = Subpanels(sub_tl, effect_tl, self, self.scalelevels,
 
                                   Subs, self.xfader, self.changelevel,
 
@@ -143,25 +145,30 @@ class Lightboard:
 
        levels = [int(l) for l in levels]
 

	
 
        for lev,lab,oldlev,numlab in zip(levels, self.channel_levels, 
 
                                         self.oldlevels, 
 
                                         self.leveldisplay.number_labels):
 
            if lev != oldlev:
 
                lab.config(text="%d" % lev)
 
                colorlabel(lab)
 
                lab.config(text="%d" % lev) # update labels in lev display
 
                colorlabel(lab)             # recolor labels
 
                if lev < oldlev:
 
                    numlab['bg'] = 'blue'
 
                else:
 
                    numlab['bg'] = 'red'
 
            else:
 
                numlab['bg'] = 'lightPink'
 

	
 
        self.oldlevels[:] = levels[:] # replace the elements in oldlevels - don't make a new list (Subediting is watching it)
 
            
 
        self.parportdmx.sendlevels(levels)
 

	
 
    def updatestagelevels(self):
 
        self.master.after(100, self.updatestagelevels)
 
        for lev, idx in zip(self.oldlevels, xrange(0, 68 + 1)):
 
            self.stage.updatelightlevel(Patch.get_channel_name(idx + 1), lev)
 

	
 
    def load(self):
 
        try:
 
            filename = '/tmp/light9.prefs'
 
            if self.DUMMY:
 
                filename += '.dummy'
 
            print "Loading from", filename
light8/stage.py
Show inline comments
 
@@ -62,33 +62,39 @@ class Stage(Canvas):
 
                       # from None to 'pressed','rectangle','levelchange', etc
 

	
 
        self.alllights=[]
 
        self.selectedlights=[]
 
        self.alllighttags={} # tag: name lookup
 

	
 
        self.subeditor=None
 
        self.subeditor = None
 

	
 
    def setimage(self,stageimage):
 
        img = Image('photo',file=stageimage)
 
        self.img=img # can't lose this!
 
        print img.width()
 
        self.create_image(0,0,anchor='nw',image=img)
 
        self.config(width=img.width(),height=img.height())
 

	
 
    def setsubediting(self,subeditor):
 
        self.subeditor = subeditor
 

	
 
    # (17:00:06) drewp: if yes, then self.itemconfigure(tagOrId, text=...)
 
    def updatelightlevel(self, name, level):
 
        tag = self.nametag(name)
 
        self.itemconfigure("level_%s" % tag, text=level)
 

	
 
    #
 
    # selection management
 
    #
 
    def updateselectionboxes(self):
 
        "make selection boxes that match self.selectedlights"
 
        self.delete("selectbox")
 
        for l in self.selectedlights:
 
            for c in self.getlightbboxes(l):
 
               self.create_rectangle(c[0]-2,c[1]-2,c[2]+2,c[3]+2,
 
                                     outline='red',tag="selectbox")            
 
                                     outline='red',tag="selectbox")
 

	
 
    def selectall(self):
 
        self.selectedlights= self.alllights[:]
 
        self.updateselectionboxes()
 
    def clearselection(self):
 
        self.selectedlights=[]
 
@@ -102,30 +108,33 @@ class Stage(Canvas):
 
        """as a dynamic selection changes, keep calling this function
 
        with the names of the lights in the dynamic selection. the
 
        original selection (at the time of markfordynselection) will
 
        be shown along with any new lights. if subtract=1, the selection will
 
        be shown MINUS the newlights."""
 
        if subtract==0:
 
            # orig selection plus any newlights that weren't in the orig selection
 
            self.selectedlights = self.origselection[:] + [l for l in newlightnames if l not in self.origselection]
 
            # orig selection plus any newlights that weren't in the orig 
 
            # selection
 
            self.selectedlights = self.origselection[:] + \
 
                [l for l in newlightnames if l not in self.origselection]
 
        else:
 
            # orig selection lights except those that are in the newlightnames list
 
            self.selectedlights = [l for l in self.origselection if l not in newlightnames]
 
            # orig selection lights except those that are in the newlightnames 
 
            # list
 
            self.selectedlights = [l for l in self.origselection 
 
                if l not in newlightnames]
 
        self.updateselectionboxes()
 

	
 
    def select(self,lightname,select=1): # select=0 for deselect
 
        """select or deselect (select=0) a light by name"""
 
        if select:
 
            if lightname not in self.selectedlights:
 
                self.selectedlights.append(lightname)
 
        elif lightname in self.selectedlights:
 
            self.selectedlights.remove(lightname)
 

	
 
        self.updateselectionboxes()
 
                
 

	
 
    #
 
    # mouse handling
 
    #
 
    def press(self,ev):
 
        
 
        self.mode='pressed'
 
@@ -197,14 +206,15 @@ class Stage(Canvas):
 
                self.subeditor.levelchange(self.selectedlights,delta)
 

	
 
        if self.mode=='rectangle':
 
            sr = self.find_withtag('selectrect')
 
            if not sr:
 
                # make the selection rectangle
 
                sr=self.create_rectangle( self.mousedownpos[0],self.mousedownpos[1],coords[0],coords[1],
 
                                          outlinestipple='gray50',outline='yellow',tag='selectrect')
 
                sr=self.create_rectangle( self.mousedownpos[0],
 
                    self.mousedownpos[1],coords[0],coords[1],
 
                    outlinestipple='gray50',outline='yellow',tag='selectrect')
 

	
 
            # move rectangle with mouse
 
            self.coords(sr,*(self.mousedownpos+coords))
 

	
 
            # redo the dynselection with the new rectangle
 
            self.replacedynselection(self.findoverlappinglights((self.mousedownpos+coords),1),
 
@@ -213,19 +223,20 @@ class Stage(Canvas):
 
    def release(self,ev):
 
        if self.mode:
 
            if self.mode=='rectangle':
 
                self.delete('selectrect')
 

	
 
            if self.mode=='deselect-or-rectangle':
 
                # they didn't move enough to promote the mode to level, so it's a deselect click
 
                # they didn't move enough to promote the mode to level, so 
 
                # it's a deselect click
 
                self.clearselection()
 
            
 
            self.mode=None
 

	
 
    #
 
    #
 
    # subedit type things (correct me if i'm wrong)
 
    #
 
            
 
    def startlevelchange(self):
 
        """sets mode to levelchange AND notifies subeditor. this
 
        should be done exactly once (per mouse drag), when you first
 
        decide the mode is levelchange"""
 
@@ -256,28 +267,37 @@ class Stage(Canvas):
 
        self.create_oval(location[0]-2,location[1]-2,
 
                         location[0]+2,location[1]+2,
 
                         fill='red',tag=tags+" hotspot")
 
        if aim:
 
            self.create_oval(aim[0]-2,aim[1]-2,
 
                             aim[0]+2,aim[1]+2,
 
                             fill='red',tag=tags+" hotspot")
 
            self.create_line(location[0],location[1],aim[0],aim[1],fill='lightblue',
 
                             arrow='last',arrowshape="9 15 6",tag='light')
 
                             fill='blue',tag=tags+" hotspot")
 
            self.create_line(location[0],location[1],aim[0],aim[1],
 
                fill='lightblue', arrow='last',arrowshape="9 15 6",tag='light')
 

	
 
        # shadow
 
        self.create_text(location[0]-1,location[1]+6,
 
                         anchor='n',text=name,fill='black',
 
                         tag=tags,**dict([(k,v) for k,v in textstyle.items() if k!='fill']))
 
                         tag=tags,**dict([(k,v) 
 
                            for k,v in textstyle.items() if k!='fill']))
 
        # text
 
        self.create_text(location[0],location[1]+5,anchor='n',text=name,tag=tags,**textstyle)
 
        self.create_text(location[0],location[1]+5,anchor='n',text=name,
 
            tag=tags,**textstyle)
 

	
 
        # level
 
        self.create_text(location[0]-2,location[1]+13,anchor='n',
 
            text='0', # will be changed later
 
            tag='level_%s' % self.nametag(name),**textstyle)
 
        
 
        self.alllights.append(name)
 
        self.alllighttags[self.nametag(name)]=name
 

	
 
    def getlightbboxes(self,tag):
 
        """returns a list of bboxes for a light with a given name_ tag. the selection
 
        mechanism draws around these bboxes to show that a light is selected"""
 
        """returns a list of bboxes for a light with a given name_ tag. the 
 
        selection mechanism draws around these bboxes to show that a light is 
 
        selected"""
 
        bboxes=[]
 
        for o in self.find_withtag("name_%s" % self.nametag(tag)):
 
            if 'hotspot' in self.gettags(o):
 
                bboxes.append(self.bbox(o))
 
        return bboxes
 

	
 
@@ -348,19 +368,12 @@ def createlights(s):
 
    s.addlight('main 11',(636, 556),aim=(449, 409))
 

	
 
    s.addlight('sidepost2', (785, 609))
 
    s.addlight('sidepost1', (8, 613))
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
if __name__=='__main__':
 
    root=Tk()
 
    root.tk_focusFollowsMouse()
 
    root.wm_geometry("+376+330")
 
    s=Stage(root)
 
    s.setimage('guysanddolls.gif')
 
@@ -373,7 +386,6 @@ if __name__=='__main__':
 
            print "start lev change"
 
        def levelchange(self,lights,delta):
 
            print "change",lights,delta
 
    s.setsubediting(subediting_standin())
 
    
 
    root.mainloop()
 

	
0 comments (0 inline, 0 general)