annotate light8/subediting.py @ 42:5e4fb4ac2d18

corrected Patch's error behavior and subediting's catching behavior
author drewp
date Sun, 07 Jul 2002 12:24:01 +0000
parents 02151923be45
children 6540879e336e
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
41
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
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
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
18
45b12307c695 Initial revision
drewp
parents:
diff changeset
19 def setsub(self,sub):
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 """sets which (one) sub object should the stage be editing.
45b12307c695 Initial revision
drewp
parents:
diff changeset
21
45b12307c695 Initial revision
drewp
parents:
diff changeset
22 this is called by widgets that are set up in the Subpanels interfaces.
45b12307c695 Initial revision
drewp
parents:
diff changeset
23 """
45b12307c695 Initial revision
drewp
parents:
diff changeset
24
45b12307c695 Initial revision
drewp
parents:
diff changeset
25 print "subedit: editing ",sub.name
45b12307c695 Initial revision
drewp
parents:
diff changeset
26 self.sub = sub
45b12307c695 Initial revision
drewp
parents:
diff changeset
27
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 #
45b12307c695 Initial revision
drewp
parents:
diff changeset
29 # next two methods are called by the Stage
45b12307c695 Initial revision
drewp
parents:
diff changeset
30 #
45b12307c695 Initial revision
drewp
parents:
diff changeset
31 def startlevelchange(self):
41
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
32 "stage is about to send some level changes. this method is called by the Stage."
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
33 print "subedit: start-------"
45b12307c695 Initial revision
drewp
parents:
diff changeset
34 if self.sub is None:
45b12307c695 Initial revision
drewp
parents:
diff changeset
35 print "not editing any sub!"
45b12307c695 Initial revision
drewp
parents:
diff changeset
36 return
45b12307c695 Initial revision
drewp
parents:
diff changeset
37
45b12307c695 Initial revision
drewp
parents:
diff changeset
38 self.startlevels = self.sub.getlevels()
45b12307c695 Initial revision
drewp
parents:
diff changeset
39
45b12307c695 Initial revision
drewp
parents:
diff changeset
40 def getcurrentlevel(self,lightname):
45b12307c695 Initial revision
drewp
parents:
diff changeset
41 try:
45b12307c695 Initial revision
drewp
parents:
diff changeset
42 ch = get_dmx_channel(lightname)
45b12307c695 Initial revision
drewp
parents:
diff changeset
43 except ValueError:
45b12307c695 Initial revision
drewp
parents:
diff changeset
44 return None
45b12307c695 Initial revision
drewp
parents:
diff changeset
45 return self.currentoutputlevels[ch]
45b12307c695 Initial revision
drewp
parents:
diff changeset
46
45b12307c695 Initial revision
drewp
parents:
diff changeset
47 def levelchange(self,lightnames,delta):
45b12307c695 Initial revision
drewp
parents:
diff changeset
48 """stage sends this message with its light names and a delta
45b12307c695 Initial revision
drewp
parents:
diff changeset
49 0..1 measured from the last startlevelchange call. this method is
45b12307c695 Initial revision
drewp
parents:
diff changeset
50 called by the Stage"""
45b12307c695 Initial revision
drewp
parents:
diff changeset
51
41
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
52 print "subedit: level change",lightnames,delta
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
53 if self.sub is None:
45b12307c695 Initial revision
drewp
parents:
diff changeset
54 print "not editing any sub!"
45b12307c695 Initial revision
drewp
parents:
diff changeset
55 return
45b12307c695 Initial revision
drewp
parents:
diff changeset
56
45b12307c695 Initial revision
drewp
parents:
diff changeset
57 updatelevels={}
45b12307c695 Initial revision
drewp
parents:
diff changeset
58
45b12307c695 Initial revision
drewp
parents:
diff changeset
59 for l in lightnames:
45b12307c695 Initial revision
drewp
parents:
diff changeset
60 if l not in self.startlevels:
45b12307c695 Initial revision
drewp
parents:
diff changeset
61 # level was not in the sub
45b12307c695 Initial revision
drewp
parents:
diff changeset
62 cl = self.getcurrentlevel(l)
45b12307c695 Initial revision
drewp
parents:
diff changeset
63 if cl is None:
41
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
64 print "light isn't even in the patch! skipping"
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
65 return
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
66 print "copying current light level",cl,"into the sub"
45b12307c695 Initial revision
drewp
parents:
diff changeset
67 self.startlevels[l] = cl
45b12307c695 Initial revision
drewp
parents:
diff changeset
68
45b12307c695 Initial revision
drewp
parents:
diff changeset
69 updatelevels[l] = min(100,max(0,self.startlevels[l]+delta))
45b12307c695 Initial revision
drewp
parents:
diff changeset
70
45b12307c695 Initial revision
drewp
parents:
diff changeset
71 self.sub.reviselevels(updatelevels)
45b12307c695 Initial revision
drewp
parents:
diff changeset
72