annotate light8/subediting.py @ 90:d34a4956417a

rsn has a separate thread that receives rlslider connections from a potserver.py process, rsn has a separate thread that receives rlslider connections from a potserver.py process, and they work
author drewp
date Sat, 13 Jul 2002 02:57:27 +0000
parents 032b2b67bc10
children ddd3c8f04640
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1
45b12307c695 Initial revision
drewp
parents:
diff changeset
2 from Patch import get_dmx_channel
45b12307c695 Initial revision
drewp
parents:
diff changeset
3
45b12307c695 Initial revision
drewp
parents:
diff changeset
4 class Subediting:
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 """this class accepts input from Stage and edits subs. the
45b12307c695 Initial revision
drewp
parents:
diff changeset
6 Subpanels have widgets to tell us what subs to edit and when to
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 save them. this Subediting object has no UI of its own.
45b12307c695 Initial revision
drewp
parents:
diff changeset
8
45b12307c695 Initial revision
drewp
parents:
diff changeset
9 20:41:10 drewp: there are some funny rules
45b12307c695 Initial revision
drewp
parents:
diff changeset
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)
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
12 20:42:05 drewp: i dont know any other rules; but these seem odd
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
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
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
14 """
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 def __init__(self,currentoutputlevels):
45b12307c695 Initial revision
drewp
parents:
diff changeset
16 self.sub=None
45b12307c695 Initial revision
drewp
parents:
diff changeset
17 self.currentoutputlevels = currentoutputlevels
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
18 self.widgets={} # subname : widget list
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
19 self.oldcolors={} # widget : bgcolor
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
20
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
21 def refresh(self):
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
22 self.sub=None # this wouldn't last even if we wanted it to;
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
23 # the Sub objects are rebuilt upon reload
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
24 self.widgets={}
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
25 self.oldcolors={}
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
26
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
27 def register(self,subname,widget):
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
28 """tell subediting about any widgets that should be highlighted
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
29 when a sub is being edited"""
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
30 if subname not in self.widgets:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
31 self.widgets[subname]=[]
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
32 self.widgets[subname].append(widget)
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
33 self.oldcolors[widget] = widget.cget('bg')
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
34
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
35 def setsub(self,sub):
45b12307c695 Initial revision
drewp
parents:
diff changeset
36 """sets which (one) sub object should the stage be editing.
45b12307c695 Initial revision
drewp
parents:
diff changeset
37
45b12307c695 Initial revision
drewp
parents:
diff changeset
38 this is called by widgets that are set up in the Subpanels interfaces.
45b12307c695 Initial revision
drewp
parents:
diff changeset
39 """
45b12307c695 Initial revision
drewp
parents:
diff changeset
40
45b12307c695 Initial revision
drewp
parents:
diff changeset
41 print "subedit: editing ",sub.name
45b12307c695 Initial revision
drewp
parents:
diff changeset
42 self.sub = sub
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
43 self.highlighteditsub()
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
44 def highlighteditsub(self):
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
45 """based on how widgets got self.register'd, we highlight
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
46 just the row that's being edited"""
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
47
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
48 # highlight that row only
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
49 for n,wl in self.widgets.items():
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
50 if n==self.sub.name:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
51 for w in wl:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
52 w.config(bg='red')
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
53 else:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
54 for w in wl:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
55 w.config(bg=self.oldcolors[w])
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
56
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
57 #
45b12307c695 Initial revision
drewp
parents:
diff changeset
58 # next two methods are called by the Stage
45b12307c695 Initial revision
drewp
parents:
diff changeset
59 #
45b12307c695 Initial revision
drewp
parents:
diff changeset
60 def startlevelchange(self):
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
61 """stage is about to send some level changes. this method is
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
62 called by the Stage."""
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
63 print "subedit: start-------"
45b12307c695 Initial revision
drewp
parents:
diff changeset
64 if self.sub is None:
45b12307c695 Initial revision
drewp
parents:
diff changeset
65 print "not editing any sub!"
45b12307c695 Initial revision
drewp
parents:
diff changeset
66 return
45b12307c695 Initial revision
drewp
parents:
diff changeset
67
45b12307c695 Initial revision
drewp
parents:
diff changeset
68 self.startlevels = self.sub.getlevels()
45b12307c695 Initial revision
drewp
parents:
diff changeset
69
45b12307c695 Initial revision
drewp
parents:
diff changeset
70 def getcurrentlevel(self,lightname):
45b12307c695 Initial revision
drewp
parents:
diff changeset
71 try:
45b12307c695 Initial revision
drewp
parents:
diff changeset
72 ch = get_dmx_channel(lightname)
45b12307c695 Initial revision
drewp
parents:
diff changeset
73 except ValueError:
45b12307c695 Initial revision
drewp
parents:
diff changeset
74 return None
45b12307c695 Initial revision
drewp
parents:
diff changeset
75 return self.currentoutputlevels[ch]
45b12307c695 Initial revision
drewp
parents:
diff changeset
76
45b12307c695 Initial revision
drewp
parents:
diff changeset
77 def levelchange(self,lightnames,delta):
45b12307c695 Initial revision
drewp
parents:
diff changeset
78 """stage sends this message with its light names and a delta
45b12307c695 Initial revision
drewp
parents:
diff changeset
79 0..1 measured from the last startlevelchange call. this method is
45b12307c695 Initial revision
drewp
parents:
diff changeset
80 called by the Stage"""
45b12307c695 Initial revision
drewp
parents:
diff changeset
81
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
82 # print "subedit: level change",lightnames,delta
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
83 if self.sub is None:
45b12307c695 Initial revision
drewp
parents:
diff changeset
84 print "not editing any sub!"
45b12307c695 Initial revision
drewp
parents:
diff changeset
85 return
45b12307c695 Initial revision
drewp
parents:
diff changeset
86
45b12307c695 Initial revision
drewp
parents:
diff changeset
87 updatelevels={}
45b12307c695 Initial revision
drewp
parents:
diff changeset
88
45b12307c695 Initial revision
drewp
parents:
diff changeset
89 for l in lightnames:
45b12307c695 Initial revision
drewp
parents:
diff changeset
90 if l not in self.startlevels:
45b12307c695 Initial revision
drewp
parents:
diff changeset
91 # level was not in the sub
45b12307c695 Initial revision
drewp
parents:
diff changeset
92 cl = self.getcurrentlevel(l)
45b12307c695 Initial revision
drewp
parents:
diff changeset
93 if cl is None:
44
6540879e336e fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents: 42
diff changeset
94 print "light '%s' isn't even in the patch! skipping" % l
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 44
diff changeset
95 continue
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
96 print "copying current light level",cl,"into the sub"
45b12307c695 Initial revision
drewp
parents:
diff changeset
97 self.startlevels[l] = cl
45b12307c695 Initial revision
drewp
parents:
diff changeset
98
45b12307c695 Initial revision
drewp
parents:
diff changeset
99 updatelevels[l] = min(100,max(0,self.startlevels[l]+delta))
45b12307c695 Initial revision
drewp
parents:
diff changeset
100
45b12307c695 Initial revision
drewp
parents:
diff changeset
101 self.sub.reviselevels(updatelevels)
45b12307c695 Initial revision
drewp
parents:
diff changeset
102