annotate 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
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):
41
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
41 print "resolve",lightname
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
42 ch = get_dmx_channel(lightname)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
43 try:
45b12307c695 Initial revision
drewp
parents:
diff changeset
44 ch = get_dmx_channel(lightname)
45b12307c695 Initial revision
drewp
parents:
diff changeset
45 except ValueError:
45b12307c695 Initial revision
drewp
parents:
diff changeset
46 return None
41
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
47 print "resolved ch",ch
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
48 return self.currentoutputlevels[ch]
45b12307c695 Initial revision
drewp
parents:
diff changeset
49
45b12307c695 Initial revision
drewp
parents:
diff changeset
50 def levelchange(self,lightnames,delta):
45b12307c695 Initial revision
drewp
parents:
diff changeset
51 """stage sends this message with its light names and a delta
45b12307c695 Initial revision
drewp
parents:
diff changeset
52 0..1 measured from the last startlevelchange call. this method is
45b12307c695 Initial revision
drewp
parents:
diff changeset
53 called by the Stage"""
45b12307c695 Initial revision
drewp
parents:
diff changeset
54
41
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
55 print "subedit: level change",lightnames,delta
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
56 if self.sub is None:
45b12307c695 Initial revision
drewp
parents:
diff changeset
57 print "not editing any sub!"
45b12307c695 Initial revision
drewp
parents:
diff changeset
58 return
45b12307c695 Initial revision
drewp
parents:
diff changeset
59
45b12307c695 Initial revision
drewp
parents:
diff changeset
60 updatelevels={}
45b12307c695 Initial revision
drewp
parents:
diff changeset
61
45b12307c695 Initial revision
drewp
parents:
diff changeset
62 for l in lightnames:
45b12307c695 Initial revision
drewp
parents:
diff changeset
63 if l not in self.startlevels:
45b12307c695 Initial revision
drewp
parents:
diff changeset
64 # level was not in the sub
45b12307c695 Initial revision
drewp
parents:
diff changeset
65 cl = self.getcurrentlevel(l)
45b12307c695 Initial revision
drewp
parents:
diff changeset
66 if cl is None:
41
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
67 print "light isn't even in the patch! skipping"
02151923be45 subediting is incorporated into rsn, and begins to work
drewp
parents: 0
diff changeset
68 return
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
69 print "copying current light level",cl,"into the sub"
45b12307c695 Initial revision
drewp
parents:
diff changeset
70 self.startlevels[l] = cl
45b12307c695 Initial revision
drewp
parents:
diff changeset
71
45b12307c695 Initial revision
drewp
parents:
diff changeset
72 updatelevels[l] = min(100,max(0,self.startlevels[l]+delta))
45b12307c695 Initial revision
drewp
parents:
diff changeset
73
45b12307c695 Initial revision
drewp
parents:
diff changeset
74 self.sub.reviselevels(updatelevels)
45b12307c695 Initial revision
drewp
parents:
diff changeset
75