Mercurial > code > home > repos > light9
annotate bin/curvecalc @ 778:a2c1dc358bb1
support dragging in a url to make curves and subterms
Ignore-this: 8cb0583c1350d8d414d8ef2995524c68
author | drewp@bigasterisk.com |
---|---|
date | Sat, 16 Jun 2012 23:46:03 +0000 |
parents | 24db623e2097 |
children | d3f6830f55a2 |
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 |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
21 from rdflib import URIRef, Graph, Literal, RDF, RDFS |
319
2193eab0650b
add startup logging to curvecalc
Drew Perttula <drewp@bigasterisk.com>
parents:
296
diff
changeset
|
22 import logging |
2193eab0650b
add startup logging to curvecalc
Drew Perttula <drewp@bigasterisk.com>
parents:
296
diff
changeset
|
23 log = logging.getLogger() |
0 | 24 |
210
f41004d5a507
factored out some networking, new show/ layout, curvecalc works
drewp@bigasterisk.com
parents:
205
diff
changeset
|
25 import run_local |
763
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
26 from light9 import showconfig, prof, networking |
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 |
689 | 29 from light9.curvecalc.musicaccess import Music, currentlyPlayingSong |
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 |
690 | 32 from light9.curvecalc.subterm import read_all_subs, savekey, graphPathForSubterms |
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 |
0 | 36 |
505 | 37 def makeGraph(): |
38 graphOrig = showconfig.getGraph() | |
39 graph = Graph() # a copy, since we're going to add subs into it | |
40 for s in graphOrig: | |
41 graph.add(s) | |
42 read_all_subs(graph) | |
43 return graph | |
0 | 44 |
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
|
45 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
|
46 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
|
47 |
691 | 48 class Main(object): |
698
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
49 def __init__(self, graph, opts, song, curveset, subterms, music): |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
50 self.graph, self.opts, self.song = graph, opts, song |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
51 self.curveset, self.subterms, self.music = curveset, subterms, music |
751
5656767ca025
first drop action of a sub successfully gets current music time
drewp@bigasterisk.com
parents:
745
diff
changeset
|
52 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
|
53 |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
54 wtree = self.wtree = gtk.Builder() |
702 | 55 wtree.add_from_file("light9/curvecalc/curvecalc.glade") |
691 | 56 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
|
57 |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
58 mainwin.connect("destroy", self.onQuit) |
691 | 59 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
|
60 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
|
61 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
|
62 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
|
63 self.refreshTheme() |
691 | 64 mainwin.show_all() |
65 | |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
66 mainwin.connect("delete-event", lambda *args: reactor.crash()) |
692
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
67 mainwin.set_title("curvecalc - %s" % graph.label(song)) |
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 |
761 | 74 |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
75 wtree.get_object("subterms").connect("add", self.onSubtermChildAdded) |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
76 self.add_subterms_for_song(song, curveset, subterms) |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
77 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
|
78 |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
79 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
|
80 |
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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 w.connect("drag-data-received", self.onDataReceived) |
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
|
86 connect(mainwin) |
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
|
87 # 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
|
88 # event. |
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
|
89 mainwin.forall(connect) # not very effective |
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
|
90 connect(wtree.get_object("subterms")) # works for that area |
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
|
91 |
761 | 92 # may not work |
93 wtree.get_object("paned1").set_position(600) | |
94 | |
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
|
95 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
|
96 targetType, time): |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
97 data = selection.data.strip() |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
98 if '?' in data: |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
99 self.handleSubtermDrop(data) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
100 return |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
101 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
|
102 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
|
103 |
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
|
104 if not list(self.graph.subjects(L9['sub'], uri)): |
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
|
105 # might be a new one just created in KC |
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
|
106 print "didn't find %r, reloading subs" % uri |
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
|
107 self.onReloadSubs() |
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
|
108 |
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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 curveView = self.curvesetView.row(subName).curveView |
759 | 114 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
|
115 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
|
116 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
|
117 (t, 1)]) |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
118 |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
119 def handleSubtermDrop(self, data): |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
120 params = parse_qsl(data.split('?')[1]) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
121 flattened = dict(params) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
122 self.makeSubterm(flattened['subtermName'], |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
123 expr=flattened['subtermExpr']) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
124 |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
125 for cmd, name in params: |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
126 if cmd == 'curve': |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
127 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
|
128 |
705 | 129 def onNewCurve(self, *args): |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
130 dialog = self.wtree.get_object("newCurve") |
705 | 131 entry = self.wtree.get_object("newCurveName") |
132 # if you don't have songx, that should be the suggested name | |
133 entry.set_text("") | |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
134 if dialog.run() == 1: |
705 | 135 self.curveset.new_curve(entry.get_text()) |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
136 dialog.hide() |
705 | 137 |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
138 def onNewSubterm(self, *args): |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
139 dialog = self.wtree.get_object("newSubterm") |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
140 # 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
|
141 # (but let you make one up, too) |
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
142 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
|
143 entry.set_text("") |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
144 entry.grab_focus() |
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
145 if dialog.run() == 1: |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
146 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
|
147 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
|
148 self.makeSubterm(newname, withCurve=wc) |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
149 dialog.hide() |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
150 |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
151 def makeSubterm(self, newname, withCurve=False, expr=None): |
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
|
152 uri = L9['sub/%s' % newname] |
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
|
153 if (uri, RDF.type, L9.Subterm) in self.graph: |
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
|
154 raise SubtermExists("already have a subterm named %r" % newname) |
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
|
155 self.graph.add((uri, RDF.type, L9.Subterm)) |
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
|
156 self.graph.add((uri, RDFS.label, Literal(newname))) |
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
|
157 add_one_subterm(self.graph, uri, |
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
|
158 self.curveset, self.subterms, |
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
|
159 self.wtree.get_object("subterms"), |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
160 expr=expr, show=True) |
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
|
161 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
|
162 self.curveset.new_curve(newname) |
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
|
163 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
164 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
|
165 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
|
166 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
|
167 |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
168 def onSubtermChildAdded(self, subtermsTable, *args): |
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
169 # this would probably work, but isn't getting called |
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
170 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
|
171 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
|
172 |
700
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
173 def onQuit(self, *args): |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
174 reactor.crash() |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
175 # 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
|
176 # threads. I don't know whose they are. |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
177 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
|
178 |
715
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
179 def onCollapseAll(self, *args): |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
180 self.curvesetView.collapseAll() |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
181 |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
182 def onCollapseNone(self, *args): |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
183 self.curvesetView.collapseNone() |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
184 |
711
e94989da079c
more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents:
708
diff
changeset
|
185 def onDelete(self, *args): |
e94989da079c
more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents:
708
diff
changeset
|
186 self.curvesetView.onDelete() |
e94989da079c
more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents:
708
diff
changeset
|
187 |
708 | 188 def onPythonConsole(self, item): |
773 | 189 ns = dict() |
190 ns.update(globals()) | |
191 ns.update(self.__dict__) | |
192 togglePyConsole(self, item, ns) | |
708 | 193 |
699
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
194 def onSeeCurrentTime(self, item): |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
195 dispatcher.send("see time") |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
196 |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
197 def onSeeTimeUntilEnd(self, item): |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
198 dispatcher.send("see time until end") |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
199 |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
200 def onZoomAll(self, item): |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
201 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
|
202 |
698
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
203 def onPlayPause(self, item): |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
204 # 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
|
205 # 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
|
206 results = dispatcher.send("onPlayPause") |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
207 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
|
208 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
|
209 |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
210 def onSave(self, *args): |
703 | 211 savekey(self.song, self.subterms, self.curveset) |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
212 |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
213 def add_subterms_for_song(self, song, curveset, subterms): |
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
214 master = self.wtree.get_object("subterms") |
692
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
215 for st in self.graph.objects(song, L9['subterm']): |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
216 log.info("song %s has subterm %s", song, st) |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
217 add_one_subterm(self.graph, |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
218 self.graph.value(st, L9['sub']), |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
219 curveset, |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
220 subterms, |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
221 master, |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
222 self.graph.value(st, L9['expression'])) |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
223 master.show_all() |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
224 |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
225 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
|
226 """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
|
227 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
|
228 ('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
|
229 ('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
|
230 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
|
231 for n,v in |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
232 levels.items()[:5] |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
233 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
|
234 ('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
|
235 ('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
|
236 ]): |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
245 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
|
246 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
|
247 signame, weak=False) |
751
5656767ca025
first drop action of a sub successfully gets current music time
drewp@bigasterisk.com
parents:
745
diff
changeset
|
248 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
|
249 '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
|
250 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
|
251 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 '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
|
256 '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
|
257 ]] |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
258 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
259 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
|
260 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
|
261 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
|
262 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
|
263 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
|
264 [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
|
265 [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
|
266 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
|
267 try: |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
268 linecache.clearcache() |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
269 reload(curveview) |
716
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
270 |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
271 # old ones are not getting deleted right |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
272 if hasattr(self, 'curvesetView'): |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
273 self.curvesetView.live = False |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
274 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
275 # 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
|
276 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
|
277 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
|
278 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
|
279 |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
280 # 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
|
281 # 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
|
282 # 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
|
283 # 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
|
284 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
|
285 except Exception: |
716
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
286 print "reload failed:" |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
287 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
|
288 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
|
289 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
|
290 |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
291 def onReloadSubs(self, *args): # wants to be ctrl-r too |
757 | 292 read_all_subs(self.graph) # this will discover new subs (additive only) |
293 dispatcher.send('reload all subs') # this rereads each sub from its graph file | |
736
d1bff8a3b069
r key can't rebuild curves now that it's a marker key. let c-r rebuild all the curves
Drew Perttula <drewp@bigasterisk.com>
parents:
725
diff
changeset
|
294 dispatcher.send("all curves rebuild") |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
295 |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
296 |
505 | 297 def main(): |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
298 startTime = time.time() |
505 | 299 parser = optparse.OptionParser() |
551
ad5043f70fda
bin/curvecalc (with no song choice) defaults to whatever-ascoltami-is-currently-on
drewp@bigasterisk.com
parents:
532
diff
changeset
|
300 parser.set_usage("%prog [opts] [songURI]") |
505 | 301 parser.add_option("--sliders", action='store_true', |
302 help='use hardware sliders') | |
303 parser.add_option("--skip-music", action='store_true', | |
304 help="ignore music and smooth_music curve files") | |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
305 parser.add_option("--debug", action="store_true", |
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
306 help="log at DEBUG") |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
307 parser.add_option("--reload", action="store_true", |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
308 help="live reload of themes and code") |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
309 parser.add_option("--startup-only", action='store_true', |
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
310 help="quit after loading everything (for timing tests)") |
505 | 311 opts, args = parser.parse_args() |
312 | |
590 | 313 logging.basicConfig(format="%(asctime)s %(levelname)-5s %(name)s %(filename)s:%(lineno)d: %(message)s") |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
314 log.setLevel(logging.DEBUG if opts.debug else logging.INFO) |
590 | 315 |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
316 log.debug("startup: music %s", time.time() - startTime) |
505 | 317 try: |
318 song = URIRef(args[0]) | |
319 except IndexError: | |
551
ad5043f70fda
bin/curvecalc (with no song choice) defaults to whatever-ascoltami-is-currently-on
drewp@bigasterisk.com
parents:
532
diff
changeset
|
320 song = currentlyPlayingSong() |
505 | 321 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
322 music = Music() |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
323 graph = makeGraph() |
691 | 324 |
505 | 325 curveset = Curveset(sliders=opts.sliders) |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
326 subterms = [] |
505 | 327 |
704
d5a9933a2222
don't reload curve files upon curve code reload
Drew Perttula <drewp@bigasterisk.com>
parents:
703
diff
changeset
|
328 curveset.load(basename=os.path.join( |
d5a9933a2222
don't reload curve files upon curve code reload
Drew Perttula <drewp@bigasterisk.com>
parents:
703
diff
changeset
|
329 showconfig.curvesDir(), |
d5a9933a2222
don't reload curve files upon curve code reload
Drew Perttula <drewp@bigasterisk.com>
parents:
703
diff
changeset
|
330 showconfig.songFilenameFromURI(song)), |
d5a9933a2222
don't reload curve files upon curve code reload
Drew Perttula <drewp@bigasterisk.com>
parents:
703
diff
changeset
|
331 skipMusic=opts.skip_music) |
d5a9933a2222
don't reload curve files upon curve code reload
Drew Perttula <drewp@bigasterisk.com>
parents:
703
diff
changeset
|
332 |
637
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
333 subtermPath = graphPathForSubterms(song) |
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
334 try: |
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
335 graph.parse(subtermPath, format='n3') |
717
d8202a0a7fd5
fix up musicpad and wavecurve. ascoltami2 can now use relative paths in the config
Drew Perttula <drewp@bigasterisk.com>
parents:
716
diff
changeset
|
336 except IOError, e: |
d8202a0a7fd5
fix up musicpad and wavecurve. ascoltami2 can now use relative paths in the config
Drew Perttula <drewp@bigasterisk.com>
parents:
716
diff
changeset
|
337 if e.errno != 2: |
637
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
338 raise |
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
339 log.info("%s not found, starting with empty graph" % subtermPath) |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
340 |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
341 log.debug("startup: output %s", time.time() - startTime) |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
342 out = Output(subterms, music) |
505 | 343 |
344 musicfilename = showconfig.songOnDisk(song) | |
345 maxtime = wavelength(musicfilename) | |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
346 dispatcher.connect(lambda: maxtime, "get max time", weak=False) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
347 |
698
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
348 start = Main(graph, opts, song, curveset, subterms, music) |
692
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
349 |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
350 dispatcher.send("max time", maxtime=maxtime) |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
351 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
|
352 |
692
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
353 if opts.startup_only: |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
354 log.debug("quitting now because of --startup-only") |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
355 return |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
356 |
763
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
357 from twisted.web import server, resource |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
358 class Hover(resource.Resource): |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
359 isLeaf = True |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
360 def render_GET(self, request): |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
361 if request.path == '/hoverTime': |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
362 results = dispatcher.send("onPlayPause") |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
363 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
|
364 if not times: |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
365 request.setResponseCode(404) |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
366 return "not hovering over any time" |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
367 |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
368 return json.dumps({"song":song, "hoverTime" : times[0]}) |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
369 raise NotImplementedError() |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
370 |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
371 reactor.listenTCP(networking.curveCalc.port, |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
372 server.Site(Hover())) |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
373 |
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
374 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
375 prof.run(reactor.run, profile=False) |
505 | 376 |
377 main() |