comparison light8/subediting.py @ 41:02151923be45

subediting is incorporated into rsn, and begins to work
author drewp
date Sun, 07 Jul 2002 12:18:06 +0000
parents 45b12307c695
children 5e4fb4ac2d18
comparison
equal deleted inserted replaced
40:f3d65ae17a8f 41:02151923be45
8 8
9 20:41:10 drewp: there are some funny rules 9 20:41:10 drewp: there are some funny rules
10 20:41:37 drewp: if you drag a light that's in the sub you're editing, you'll adjust it from it's position in the sub (Even if that sub is not visialbe, or if the light is doing someting else) 10 20:41:37 drewp: if you drag a light that's in the sub you're editing, you'll adjust it from it's position in the sub (Even if that sub is not visialbe, or if the light is doing someting else)
11 20:41:57 drewp: but if you touch a light that wasnt in the sub, the current light brightness from the stage gets copied into the sub, and then you adjust frmo there 11 20:41:57 drewp: but if you touch a light that wasnt in the sub, the current light brightness from the stage gets copied into the sub, and then you adjust frmo there
12 20:42:05 drewp: i dont know any other rules; but these seem odd 12 20:42:05 drewp: i dont know any other rules; but these seem odd
13 20:42:29 drewp: it may be necessary to highluight which lights are already in the sub, so you know what you're doing as soon as you click on one 13 20:42:29 drewp: it may be necessary to highlight which lights are already in the sub, so you know what you're doing as soon as you click on one
14 """ 14 """
15 def __init__(self,currentoutputlevels): 15 def __init__(self,currentoutputlevels):
16 self.sub=None 16 self.sub=None
17 self.currentoutputlevels = currentoutputlevels 17 self.currentoutputlevels = currentoutputlevels
18 self.widgets={} # subname : widget list
19 self.oldcolors={} # widget : bgcolor
20 18
21 def refresh(self):
22 self.sub=None # this wouldn't last even if we wanted it to;
23 # the Sub objects are rebuilt upon reload
24 self.widgets={}
25 self.oldcolors={}
26
27 def register(self,subname,widget):
28 """tell subediting about any widgets that should be highlighted
29 when a sub is being edited"""
30 if subname not in self.widgets:
31 self.widgets[subname]=[]
32 self.widgets[subname].append(widget)
33 self.oldcolors[widget] = widget.cget('bg')
34
35 def setsub(self,sub): 19 def setsub(self,sub):
36 """sets which (one) sub object should the stage be editing. 20 """sets which (one) sub object should the stage be editing.
37 21
38 this is called by widgets that are set up in the Subpanels interfaces. 22 this is called by widgets that are set up in the Subpanels interfaces.
39 """ 23 """
40 24
41 print "subedit: editing ",sub.name 25 print "subedit: editing ",sub.name
42 self.sub = sub 26 self.sub = sub
43 self.highlighteditsub()
44 def highlighteditsub(self, color='red'):
45 """based on how widgets got self.register'd, we highlight
46 just the row that's being edited"""
47 27
48 # highlight that row only
49 for n,wl in self.widgets.items():
50 if n == self.sub.name:
51 self.colorsub(n, color)
52 else:
53 self.colorsub(n, 'restore')
54
55 '''
56 # highlight that row only
57 for n,wl in self.widgets.items():
58 if n==self.sub.name:
59 for w in wl:
60 w.config(bg=color)
61 else:
62 for w in wl:
63 w.config(bg=self.oldcolors[w])
64 '''
65 def colorsub(self, name, color):
66 for w in self.widgets[name]:
67 if color == 'restore':
68 w.config(bg=self.oldcolors[w])
69 else:
70 w.config(bg=color)
71
72 # 28 #
73 # next two methods are called by the Stage 29 # next two methods are called by the Stage
74 # 30 #
75 def startlevelchange(self): 31 def startlevelchange(self):
76 """stage is about to send some level changes. this method is 32 "stage is about to send some level changes. this method is called by the Stage."
77 called by the Stage."""
78 print "subedit: start-------" 33 print "subedit: start-------"
79 if self.sub is None: 34 if self.sub is None:
80 print "not editing any sub!" 35 print "not editing any sub!"
81 return 36 return
82 37
83 self.startlevels = self.sub.getlevels() 38 self.startlevels = self.sub.getlevels()
84 39
85 def getcurrentlevel(self,lightname): 40 def getcurrentlevel(self,lightname):
41 print "resolve",lightname
42 ch = get_dmx_channel(lightname)
86 try: 43 try:
87 ch = get_dmx_channel(lightname) 44 ch = get_dmx_channel(lightname)
88 except ValueError: 45 except ValueError:
89 return None 46 return None
47 print "resolved ch",ch
90 return self.currentoutputlevels[ch] 48 return self.currentoutputlevels[ch]
91 49
92 def levelchange(self,lightnames,delta): 50 def levelchange(self,lightnames,delta):
93 """stage sends this message with its light names and a delta 51 """stage sends this message with its light names and a delta
94 0..1 measured from the last startlevelchange call. this method is 52 0..1 measured from the last startlevelchange call. this method is
95 called by the Stage""" 53 called by the Stage"""
96 54
97 # print "subedit: level change",lightnames,delta 55 print "subedit: level change",lightnames,delta
98 if self.sub is None: 56 if self.sub is None:
99 print "not editing any sub!" 57 print "not editing any sub!"
100 return 58 return
101 59
102 updatelevels={} 60 updatelevels={}
104 for l in lightnames: 62 for l in lightnames:
105 if l not in self.startlevels: 63 if l not in self.startlevels:
106 # level was not in the sub 64 # level was not in the sub
107 cl = self.getcurrentlevel(l) 65 cl = self.getcurrentlevel(l)
108 if cl is None: 66 if cl is None:
109 print "light '%s' isn't even in the patch! skipping" % l 67 print "light isn't even in the patch! skipping"
110 continue 68 return
111 print "copying current light level",cl,"into the sub" 69 print "copying current light level",cl,"into the sub"
112 self.startlevels[l] = cl 70 self.startlevels[l] = cl
113 71
114 updatelevels[l] = min(100,max(0,self.startlevels[l]+delta)) 72 updatelevels[l] = min(100,max(0,self.startlevels[l]+delta))
115 73