Mercurial > code > home > repos > light9
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 |
rev | line source |
---|---|
0 | 1 |
2 from Patch import get_dmx_channel | |
3 | |
4 class Subediting: | |
5 """this class accepts input from Stage and edits subs. the | |
6 Subpanels have widgets to tell us what subs to edit and when to | |
7 save them. this Subediting object has no UI of its own. | |
8 | |
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) | |
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 | |
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 | 14 """ |
15 def __init__(self,currentoutputlevels): | |
16 self.sub=None | |
17 self.currentoutputlevels = currentoutputlevels | |
18 | |
19 def setsub(self,sub): | |
20 """sets which (one) sub object should the stage be editing. | |
21 | |
22 this is called by widgets that are set up in the Subpanels interfaces. | |
23 """ | |
24 | |
25 print "subedit: editing ",sub.name | |
26 self.sub = sub | |
27 | |
28 # | |
29 # next two methods are called by the Stage | |
30 # | |
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 | 33 print "subedit: start-------" |
34 if self.sub is None: | |
35 print "not editing any sub!" | |
36 return | |
37 | |
38 self.startlevels = self.sub.getlevels() | |
39 | |
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 | 43 try: |
44 ch = get_dmx_channel(lightname) | |
45 except ValueError: | |
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 | 48 return self.currentoutputlevels[ch] |
49 | |
50 def levelchange(self,lightnames,delta): | |
51 """stage sends this message with its light names and a delta | |
52 0..1 measured from the last startlevelchange call. this method is | |
53 called by the Stage""" | |
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 | 56 if self.sub is None: |
57 print "not editing any sub!" | |
58 return | |
59 | |
60 updatelevels={} | |
61 | |
62 for l in lightnames: | |
63 if l not in self.startlevels: | |
64 # level was not in the sub | |
65 cl = self.getcurrentlevel(l) | |
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 | 69 print "copying current light level",cl,"into the sub" |
70 self.startlevels[l] = cl | |
71 | |
72 updatelevels[l] = min(100,max(0,self.startlevels[l]+delta)) | |
73 | |
74 self.sub.reviselevels(updatelevels) | |
75 |