Mercurial > code > home > repos > light9
annotate bin/curvecalc @ 901:0dacbba70d06 last-2012
remove some broken profiler attempts
Ignore-this: 3d50124a16807ee922e85911d510ce58
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Mon, 10 Jun 2013 00:09:17 +0000 |
parents | db265102f7b5 |
children | bca2e8d754aa |
rev | line source |
---|---|
686
a301a0039c66
buildout and rdflib updates
Drew Perttula <drewp@bigasterisk.com>
parents:
684
diff
changeset
|
1 #!bin/python |
0 | 2 |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
3 """ |
351
a6662d61ebcd
SC, KC, CC now run and seem to load and save ok. CC does not have any rdf for its data files
Drew Perttula <drewp@bigasterisk.com>
parents:
335
diff
changeset
|
4 now launches like this: |
a6662d61ebcd
SC, KC, CC now run and seem to load and save ok. CC does not have any rdf for its data files
Drew Perttula <drewp@bigasterisk.com>
parents:
335
diff
changeset
|
5 % bin/curvecalc http://light9.bigasterisk.com/show/dance2007/song1 |
a6662d61ebcd
SC, KC, CC now run and seem to load and save ok. CC does not have any rdf for its data files
Drew Perttula <drewp@bigasterisk.com>
parents:
335
diff
changeset
|
6 |
a6662d61ebcd
SC, KC, CC now run and seem to load and save ok. CC does not have any rdf for its data files
Drew Perttula <drewp@bigasterisk.com>
parents:
335
diff
changeset
|
7 |
a6662d61ebcd
SC, KC, CC now run and seem to load and save ok. CC does not have any rdf for its data files
Drew Perttula <drewp@bigasterisk.com>
parents:
335
diff
changeset
|
8 |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
9 todo: curveview should preserve more objects, for speed maybe |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
10 |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
11 """ |
0 | 12 from __future__ import division |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
13 |
691 | 14 from twisted.internet import gtk2reactor |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
15 gtk2reactor.install() |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
16 from twisted.internet import reactor |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
17 |
763
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
18 import time, textwrap, os, optparse, gtk, linecache, signal, traceback, json |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
19 from urlparse import parse_qsl |
689 | 20 import louie as dispatcher |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
21 from rdflib import URIRef, Literal, RDF, RDFS |
319
2193eab0650b
add startup logging to curvecalc
Drew Perttula <drewp@bigasterisk.com>
parents:
296
diff
changeset
|
22 import logging |
0 | 23 |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
24 from run_local import log |
901
0dacbba70d06
remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents:
898
diff
changeset
|
25 from light9 import showconfig, networking |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
26 from light9.rdfdb import clientsession |
688 | 27 from light9.curvecalc.curve import Curveset |
696
929ccd4ec800
live reloading of curveview.py, very nice
Drew Perttula <drewp@bigasterisk.com>
parents:
695
diff
changeset
|
28 from light9.curvecalc import curveview |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
29 from light9.curvecalc.musicaccess import Music |
264
0f112a7dd6b3
fix window positoins for subcomposer and curvecalc. now saves geometry continuously
drewp@bigasterisk.com
parents:
248
diff
changeset
|
30 from light9.wavelength import wavelength |
335 | 31 from light9.namespaces import L9 |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
32 from light9.curvecalc.subterm import Subterm |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
33 from light9.curvecalc.subtermview import add_one_subterm |
690 | 34 from light9.curvecalc.output import Output |
708 | 35 from light9.gtkpyconsole import togglePyConsole |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
36 from light9.rdfdb.syncedgraph import SyncedGraph |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
37 from light9.rdfdb.patch import Patch |
856 | 38 from light9.editchoicegtk import EditChoice |
39 from light9.observable import Observable | |
0 | 40 |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
41 class SubtermExists(ValueError): |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
42 pass |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
43 |
691 | 44 class Main(object): |
892 | 45 def __init__(self, graph, opts, session, curveset, music): |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
46 self.graph, self.opts, self.session = graph, opts, session |
892 | 47 self.curveset, self.music = curveset, music |
751
5656767ca025
first drop action of a sub successfully gets current music time
drewp@bigasterisk.com
parents:
745
diff
changeset
|
48 self.lastSeenInputTime = 0 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
49 |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
50 wtree = self.wtree = gtk.Builder() |
702 | 51 wtree.add_from_file("light9/curvecalc/curvecalc.glade") |
691 | 52 mainwin = wtree.get_object("MainWindow") |
700
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
53 |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
54 mainwin.connect("destroy", self.onQuit) |
691 | 55 wtree.connect_signals(self) |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
56 gtk.rc_parse("theme/marble-ice/gtk-2.0/gtkrc") |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
57 gtk.rc_parse_string("""style "default" {font_name = "sans 7"}""") |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
58 if self.opts.reload: |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
59 self.refreshTheme() |
691 | 60 mainwin.show_all() |
61 | |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
62 mainwin.connect("delete-event", lambda *args: reactor.crash()) |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
63 def updateTitle(): |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
64 mainwin.set_title("curvecalc - %s" % |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
65 graph.label( |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
66 graph.value(session, L9['currentSong']))) |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
67 graph.addHandler(updateTitle) |
752 | 68 mainwin.parse_geometry("1x1-0+0") |
702 | 69 |
70 # this is the only one i found that would set the size right, | |
71 # but it's a minimum size, which i don't really want | |
745 | 72 mainwin.set_size_request(1678, 922) |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
73 |
856 | 74 songChoice = Observable(None) # to be connected with the session song |
761 | 75 |
856 | 76 def setSong(): |
77 songChoice(graph.value(session, L9['currentSong'])) | |
78 graph.addHandler(setSong) | |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
79 # next here, watch songChoice and patch the graph |
856 | 80 |
81 ec = EditChoice(graph, songChoice, label="Editing song:") | |
82 wtree.get_object("currentSongEditChoice").add(ec) | |
83 ec.show() | |
84 | |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
85 wtree.get_object("subterms").connect("add", self.onSubtermChildAdded) |
893
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
86 |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
87 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
88 self.refreshCurveView() |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
89 |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
90 self.makeStatusLines(wtree.get_object("status")) |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
91 |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
92 def connect(w): |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
93 w.drag_dest_set(flags=gtk.DEST_DEFAULT_ALL, |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
94 targets=[('text/uri-list', 0, 0)], |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
95 actions=gtk.gdk.ACTION_COPY) |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
96 w.connect("drag-data-received", self.onDataReceived) |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
97 #connect(mainwin) |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
98 # that's not enough- deeper windows don't accept the |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
99 # event. |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
100 #mainwin.forall(connect) # not very effective |
892 | 101 |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
102 wtree.get_object("newSubZone").drag_dest_set(flags=gtk.DEST_DEFAULT_ALL, |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
103 targets=[('text/uri-list', 0, 0)], |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
104 actions=gtk.gdk.ACTION_COPY) |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
105 |
892 | 106 # this probably isn't rerunning often enough to catch new data |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
107 #connect(wtree.get_object("subterms")) # works for that area |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
108 |
761 | 109 # may not work |
110 wtree.get_object("paned1").set_position(600) | |
111 | |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
112 def onDataReceived(self, widget, context, x, y, selection, |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
113 targetType, time): |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
114 data = selection.data.strip() |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
115 if '?' in data: |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
116 self.handleSubtermDrop(data) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
117 return |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
118 uri = URIRef(data) |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
119 subName = self.graph.label(uri) |
772
c0977217a7da
attempt to receive a brand new submaster. doesn't work, this fix doesn't address the problem. But you can drag it in twice as a workaround
drewp@bigasterisk.com
parents:
763
diff
changeset
|
120 |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
121 try: |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
122 self.makeSubterm(subName, withCurve=True) |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
123 except SubtermExists: |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
124 pass |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
125 curveView = self.curvesetView.row(subName).curveView |
759 | 126 t = self.lastSeenInputTime # curveView.current_time() # new curve hasn't heard the time yet. this has gotten too messy- everyone just needs to be able to reach the time source |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
127 print "time", t |
760
634e8a3ebd0a
when you drag a sub into CC and it makes a new fade, leave both points in the fade selected
drewp@bigasterisk.com
parents:
759
diff
changeset
|
128 curveView.add_points([(t - .5, 0), |
634e8a3ebd0a
when you drag a sub into CC and it makes a new fade, leave both points in the fade selected
drewp@bigasterisk.com
parents:
759
diff
changeset
|
129 (t, 1)]) |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
130 |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
131 def onDragDataInNewSubZone(self, widget, context, x, y, selection, |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
132 targetType, time): |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
133 self.makeSubterm(newname="cx", withCurve=True, |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
134 sub=URIRef(selection.data.strip())) |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
135 |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
136 def handleSubtermDrop(self, data): |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
137 params = parse_qsl(data.split('?')[1]) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
138 flattened = dict(params) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
139 self.makeSubterm(flattened['subtermName'], |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
140 expr=flattened['subtermExpr']) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
141 |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
142 for cmd, name in params: |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
143 if cmd == 'curve': |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
144 self.curveset.new_curve(name) |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
145 |
705 | 146 def onNewCurve(self, *args): |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
147 dialog = self.wtree.get_object("newCurve") |
705 | 148 entry = self.wtree.get_object("newCurveName") |
149 # if you don't have songx, that should be the suggested name | |
150 entry.set_text("") | |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
151 if dialog.run() == 1: |
705 | 152 self.curveset.new_curve(entry.get_text()) |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
153 dialog.hide() |
893
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
154 |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
155 def onSubtermsMap(self, *args): |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
156 # if this was called too soon, like in __init__, the gtktable |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
157 # would get its children but it wouldn't lay anything out that |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
158 # I can see, and I'm not sure why. Waiting for map event is |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
159 # just a wild guess. |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
160 self.graph.addHandler(self.set_subterms_from_graph) |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
161 |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
162 def onNewSubterm(self, *args): |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
163 dialog = self.wtree.get_object("newSubterm") |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
164 # the plan is to autocomplete this on existing subterm names |
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
165 # (but let you make one up, too) |
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
166 entry = self.wtree.get_object("newSubtermName").get_children()[0] |
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
167 entry.set_text("") |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
168 entry.grab_focus() |
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
169 if dialog.run() == 1: |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
170 newname = entry.get_text() |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
171 wc = self.wtree.get_object("newSubtermMakeCurve").get_active() |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
172 self.makeSubterm(newname, withCurve=wc) |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
173 dialog.hide() |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
174 |
898
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
175 def currentSong(self, current=None): |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
176 def fin(current): |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
177 return current.value(self.session, L9['currentSong']) |
898
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
178 if current is None: |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
179 with self.graph.currentState() as current: |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
180 return fin(current) |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
181 else: |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
182 return fin(current) |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
183 |
898
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
184 def songSubtermsContext(self, current=None): |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
185 return self.currentSong(current=current) |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
186 |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
187 def makeSubterm(self, newname, withCurve=False, expr=None, sub=None): |
898
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
188 with self.graph.currentState() as current: |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
189 song = self.currentSong(current=current) |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
190 for i in range(1000): |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
191 uri = song + "/subterm/%d" % i |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
192 if (uri, None, None) not in current: |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
193 break |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
194 else: |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
195 raise ValueError("can't pick a name for the new subterm") |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
196 |
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
197 ctx = self.songSubtermsContext() |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
198 quads = [ |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
199 (uri, RDF.type, L9.Subterm, ctx), |
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
200 (uri, RDFS.label, Literal(newname), ctx), |
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
201 (self.currentSong(), L9['subterm'], uri, ctx), |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
202 ] |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
203 if sub is not None: |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
204 quads.append((uri, L9['sub'], sub, ctx)) |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
205 if expr is not None: |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
206 quads.append((uri, L9['expression'], Literal(expr), ctx)) |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
207 self.graph.patch(Patch(addQuads=quads)) |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
208 |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
209 if withCurve: |
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
210 self.curveset.new_curve(newname) |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
211 return uri |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
212 |
892 | 213 def set_subterms_from_graph(self): |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
214 master = self.wtree.get_object("subterms") |
892 | 215 log.info("removing subterm widgets") |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
216 [master.remove(c) for c in master.get_children()] |
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
217 |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
218 song = self.graph.value(self.session, L9['currentSong']) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
219 |
892 | 220 for st in set(self.graph.objects(song, L9['subterm'])): |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
221 log.info("song %s has subterm %s", song, st) |
894
836ea837cae9
curvecalc just barely running its subexprs and outputting levels
Drew Perttula <drewp@bigasterisk.com>
parents:
893
diff
changeset
|
222 term = Subterm(self.graph, st, self.songSubtermsContext(), self.curveset) |
893
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
223 add_one_subterm(term, self.curveset, master) |
892 | 224 |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
225 master.show_all() |
893
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
226 log.info("%s table children showing" % len(master.get_children())) |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
227 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
228 def refreshTheme(self): |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
229 gtk.rc_reparse_all() |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
230 reactor.callLater(1, self.refreshTheme) |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
231 |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
232 def onSubtermChildAdded(self, subtermsTable, *args): |
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
233 # this would probably work, but isn't getting called |
893
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
234 log.info("onSubtermChildAdded") |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
235 v = subtermsTable.get_parent().props.vadjustment |
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
236 v.props.value = v.props.upper |
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
237 |
700
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
238 def onQuit(self, *args): |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
239 reactor.crash() |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
240 # there's a hang after this, maybe in sem_wait in two |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
241 # threads. I don't know whose they are. |
901
0dacbba70d06
remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents:
898
diff
changeset
|
242 # This fix affects profilers who want to write output at the end. |
700
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
243 os.kill(os.getpid(), signal.SIGKILL) |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
244 |
715
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
245 def onCollapseAll(self, *args): |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
246 self.curvesetView.collapseAll() |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
247 |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
248 def onCollapseNone(self, *args): |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
249 self.curvesetView.collapseNone() |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
250 |
711
e94989da079c
more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents:
708
diff
changeset
|
251 def onDelete(self, *args): |
e94989da079c
more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents:
708
diff
changeset
|
252 self.curvesetView.onDelete() |
e94989da079c
more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents:
708
diff
changeset
|
253 |
708 | 254 def onPythonConsole(self, item): |
773 | 255 ns = dict() |
256 ns.update(globals()) | |
257 ns.update(self.__dict__) | |
258 togglePyConsole(self, item, ns) | |
708 | 259 |
699
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
260 def onSeeCurrentTime(self, item): |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
261 dispatcher.send("see time") |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
262 |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
263 def onSeeTimeUntilEnd(self, item): |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
264 dispatcher.send("see time until end") |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
265 |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
266 def onZoomAll(self, item): |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
267 dispatcher.send("show all") |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
268 |
698
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
269 def onPlayPause(self, item): |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
270 # since the X coord in a curveview affects the handling, one |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
271 # of them may be able to pick this up |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
272 results = dispatcher.send("onPlayPause") |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
273 times = [t for listener, t in results if t is not None] |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
274 self.music.playOrPause(t=times[0] if times else None) |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
275 |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
276 def onSave(self, *args): |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
277 with self.graph.currentState() as g: |
897
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
278 song = g.value(self.session, L9['currentSong']) |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
279 |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
280 log.info("saving curves for %r", song) |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
281 self.curveset.save(basename=os.path.join( |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
282 showconfig.curvesDir(), |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
283 showconfig.songFilenameFromURI(song))) |
fc651955d6d9
curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents:
894
diff
changeset
|
284 log.info("saved") |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
285 |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
286 def makeStatusLines(self, master): |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
287 """various labels that listen for dispatcher signals""" |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
288 for row, (signame, textfilter) in enumerate([ |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
289 ('input time', lambda t: "%.2fs"%t), |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
290 ('output levels', |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
291 lambda levels: textwrap.fill("; ".join(["%s:%.2f"%(n,v) |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
292 for n,v in |
779
d3f6830f55a2
stop output entry box bouncing around
drewp@bigasterisk.com
parents:
778
diff
changeset
|
293 levels.items()[:2] |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
294 if v>0]),70)), |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
295 ('update period', lambda t: "%.1fms"%(t*1000)), |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
296 ('update status', lambda x: str(x)), |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
297 ]): |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
298 key = gtk.Label("%s:" % signame) |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
299 value = gtk.Label("") |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
300 master.resize(row + 1, 2) |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
301 master.attach(key, 0, 1, row, row + 1) |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
302 master.attach(value, 1, 2, row, row + 1) |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
303 key.set_alignment(1, 0) |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
304 value.set_alignment(0, 0) |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
305 |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
306 dispatcher.connect(lambda val, value=value, tf=textfilter: |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
307 value.set_text(tf(val)), |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
308 signame, weak=False) |
751
5656767ca025
first drop action of a sub successfully gets current music time
drewp@bigasterisk.com
parents:
745
diff
changeset
|
309 dispatcher.connect(lambda val: setattr(self, 'lastSeenInputTime', val), |
5656767ca025
first drop action of a sub successfully gets current music time
drewp@bigasterisk.com
parents:
745
diff
changeset
|
310 'input time', weak=False) |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
311 master.show_all() |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
312 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
313 def refreshCurveView(self): |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
314 wtree = self.wtree |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
315 mtimes = [os.path.getmtime(f) for f in [ |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
316 'light9/curvecalc/curveview.py', |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
317 'light9/curvecalc/zoomcontrol.py', |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
318 ]] |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
319 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
320 if (not hasattr(self, 'curvesetView') or |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
321 self.curvesetView._mtimes != mtimes): |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
322 print "reload curveview.py" |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
323 curvesVBox = wtree.get_object("curves") |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
324 zoomControlBox = wtree.get_object("zoomControlBox") |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
325 [curvesVBox.remove(c) for c in curvesVBox.get_children()] |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
326 [zoomControlBox.remove(c) for c in |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
327 zoomControlBox.get_children()] |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
328 try: |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
329 linecache.clearcache() |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
330 reload(curveview) |
716
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
331 |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
332 # old ones are not getting deleted right |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
333 if hasattr(self, 'curvesetView'): |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
334 self.curvesetView.live = False |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
335 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
336 # mem problem somewhere; need to hold a ref to this |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
337 self.curvesetView = curveview.Curvesetview( |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
338 curvesVBox, zoomControlBox, self.curveset) |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
339 self.curvesetView._mtimes = mtimes |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
340 |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
341 # this is scheduled after some tk shuffling, to |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
342 # try to minimize the number of times we redraw |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
343 # the curve at startup. If tk is very slow, it's |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
344 # ok. You'll just get some wasted redraws. |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
345 self.curvesetView.goLive() |
737
3d1112a894df
drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents:
736
diff
changeset
|
346 except Exception: |
716
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
347 print "reload failed:" |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
348 traceback.print_exc() |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
349 if self.opts.reload: |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
350 reactor.callLater(1, self.refreshCurveView) |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
351 |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
352 |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
353 class MaxTime(object): |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
354 """ |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
355 looks up the time in seconds for the session's current song |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
356 """ |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
357 def __init__(self, graph, session): |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
358 self.graph, self.session = graph, session |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
359 graph.addHandler(self.update) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
360 |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
361 def update(self): |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
362 song = self.graph.value(self.session, L9['currentSong']) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
363 if song is None: |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
364 self.maxtime = 0 |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
365 return |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
366 musicfilename = showconfig.songOnDisk(song) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
367 self.maxtime = wavelength(musicfilename) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
368 log.info("new max time %r", self.maxtime) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
369 dispatcher.send("max time", maxtime=self.maxtime) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
370 |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
371 def get(self): |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
372 return self.maxtime |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
373 |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
374 def launch(args, graph, session, opts, startTime, music): |
691 | 375 |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
376 try: |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
377 song = URIRef(args[0]) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
378 graph.patchObject(context=session, |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
379 subject=session, |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
380 predicate=L9['currentSong'], |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
381 newObject=song) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
382 except IndexError: |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
383 pass |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
384 |
505 | 385 curveset = Curveset(sliders=opts.sliders) |
386 | |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
387 def curvesetReload(): |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
388 # not sure if this clears right or not yet |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
389 song = graph.value(session, L9['currentSong']) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
390 if song is None: |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
391 return |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
392 curveset.load(basename=os.path.join( |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
393 showconfig.curvesDir(), |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
394 showconfig.songFilenameFromURI(song)), |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
395 skipMusic=opts.skip_music) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
396 graph.addHandler(curvesetReload) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
397 |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
398 log.debug("startup: output %s", time.time() - startTime) |
894
836ea837cae9
curvecalc just barely running its subexprs and outputting levels
Drew Perttula <drewp@bigasterisk.com>
parents:
893
diff
changeset
|
399 out = Output(graph, session, music, curveset) |
505 | 400 |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
401 mt = MaxTime(graph, session) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
402 dispatcher.connect(lambda: mt.get(), "get max time", weak=False) |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
403 |
892 | 404 start = Main(graph, opts, session, curveset, music) |
692
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
405 |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
406 dispatcher.send("show all") |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
407 |
692
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
408 if opts.startup_only: |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
409 log.debug("quitting now because of --startup-only") |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
410 return |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
411 |
763
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
412 from twisted.web import server, resource |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
413 class Hover(resource.Resource): |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
414 isLeaf = True |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
415 def render_GET(self, request): |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
416 if request.path == '/hoverTime': |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
417 results = dispatcher.send("onPlayPause") |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
418 times = [t for listener, t in results if t is not None] |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
419 if not times: |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
420 request.setResponseCode(404) |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
421 return "not hovering over any time" |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
422 with graph.currentState() as g: |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
423 song = g.value(session, L9['currentSong']) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
424 return json.dumps({"song": song, "hoverTime" : times[0]}) |
763
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
425 raise NotImplementedError() |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
426 |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
427 reactor.listenTCP(networking.curveCalc.port, |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
428 server.Site(Hover())) |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
429 |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
430 def main(): |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
431 startTime = time.time() |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
432 parser = optparse.OptionParser() |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
433 parser.set_usage("%prog [opts] [songURI]") |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
434 parser.add_option("--sliders", action='store_true', |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
435 help='use hardware sliders') |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
436 parser.add_option("--skip-music", action='store_true', |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
437 help="ignore music and smooth_music curve files") |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
438 parser.add_option("--debug", action="store_true", |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
439 help="log at DEBUG") |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
440 parser.add_option("--reload", action="store_true", |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
441 help="live reload of themes and code") |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
442 parser.add_option("--startup-only", action='store_true', |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
443 help="quit after loading everything (for timing tests)") |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
444 clientsession.add_option(parser) |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
445 opts, args = parser.parse_args() |
763
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
446 |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
447 log.setLevel(logging.DEBUG if opts.debug else logging.INFO) |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
448 |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
449 log.debug("startup: music %s", time.time() - startTime) |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
450 |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
451 |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
452 session = clientsession.getUri('curvecalc', opts) |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
453 |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
454 music = Music() |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
455 graph = SyncedGraph("curvecalc") |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
456 |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
457 graph.initiallySynced.addCallback( |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
458 lambda _: launch(args, graph, session, opts, startTime, music)) |
901
0dacbba70d06
remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents:
898
diff
changeset
|
459 |
0dacbba70d06
remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents:
898
diff
changeset
|
460 reactor.run() |
505 | 461 |
901
0dacbba70d06
remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents:
898
diff
changeset
|
462 main() |
789
ea8ca6502255
refactor to prepare for submasters to work out of the main graph
drewp@bigasterisk.com
parents:
779
diff
changeset
|
463 |