Mercurial > code > home > repos > light9
annotate bin/curvecalc @ 1859:f066d6e874db
2to3 with these fixers: all idioms set_literal
Ignore-this: cbd28518218c2f0ddce8c4f92d3b8b33
author | drewp@bigasterisk.com |
---|---|
date | Wed, 22 May 2019 00:08:22 +0000 |
parents | 7772cc48e016 |
children | 5bcb950024af |
rev | line source |
---|---|
686
a301a0039c66
buildout and rdflib updates
Drew Perttula <drewp@bigasterisk.com>
parents:
684
diff
changeset
|
1 #!bin/python |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
2 """ |
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
|
3 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
|
4 % 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
|
5 |
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 |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
8 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
|
9 |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
10 """ |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
11 |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
12 |
1036
a13eee92e60c
fix up curvecalc to run
Drew Perttula <drewp@bigasterisk.com>
parents:
994
diff
changeset
|
13 import sys |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
14 import imp |
1858 | 15 sys.path.append('/usr/lib/python2.7/dist-packages') # For gtk |
1056
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
16 from twisted.internet import gtk3reactor |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
17 gtk3reactor.install() |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
18 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
|
19 |
1056
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
20 import time, textwrap, os, optparse, linecache, signal, traceback, json |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
21 import gi |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
22 from gi.repository import Gtk |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
23 from gi.repository import GObject |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
24 from gi.repository import Gdk |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
25 |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
26 from urllib.parse import parse_qsl |
1858 | 27 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
|
28 from rdflib import URIRef, Literal, RDF, RDFS |
319
2193eab0650b
add startup logging to curvecalc
Drew Perttula <drewp@bigasterisk.com>
parents:
296
diff
changeset
|
29 import logging |
0 | 30 |
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
|
31 from run_local import log |
901
0dacbba70d06
remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents:
898
diff
changeset
|
32 from light9 import showconfig, networking |
1858 | 33 from light9.curvecalc import curveview |
688 | 34 from light9.curvecalc.curve import Curveset |
1063
4e449d40f42c
inputdemo sends updates to curvecalc, which edits the curve. doesn't display right
Drew Perttula <drewp@bigasterisk.com>
parents:
1061
diff
changeset
|
35 from light9.curvecalc.curveedit import serveCurveEdit |
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
|
36 from light9.curvecalc.musicaccess import Music |
1063
4e449d40f42c
inputdemo sends updates to curvecalc, which edits the curve. doesn't display right
Drew Perttula <drewp@bigasterisk.com>
parents:
1061
diff
changeset
|
37 from light9.curvecalc.output import Output |
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
|
38 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
|
39 from light9.curvecalc.subtermview import add_one_subterm |
1063
4e449d40f42c
inputdemo sends updates to curvecalc, which edits the curve. doesn't display right
Drew Perttula <drewp@bigasterisk.com>
parents:
1061
diff
changeset
|
40 from light9.editchoicegtk import EditChoice, Local |
708 | 41 from light9.gtkpyconsole import togglePyConsole |
1063
4e449d40f42c
inputdemo sends updates to curvecalc, which edits the curve. doesn't display right
Drew Perttula <drewp@bigasterisk.com>
parents:
1061
diff
changeset
|
42 from light9.namespaces import L9 |
4e449d40f42c
inputdemo sends updates to curvecalc, which edits the curve. doesn't display right
Drew Perttula <drewp@bigasterisk.com>
parents:
1061
diff
changeset
|
43 from light9.observable import Observable |
1698
f140153c087c
bring back clientsession which doesn't belong in rdfdb
Drew Perttula <drewp@bigasterisk.com>
parents:
1692
diff
changeset
|
44 from light9 import clientsession |
1692 | 45 from rdfdb.patch import Patch |
46 from rdfdb.syncedgraph import SyncedGraph | |
1063
4e449d40f42c
inputdemo sends updates to curvecalc, which edits the curve. doesn't display right
Drew Perttula <drewp@bigasterisk.com>
parents:
1061
diff
changeset
|
47 from light9.wavelength import wavelength |
0 | 48 |
1858 | 49 |
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
|
50 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
|
51 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
|
52 |
1858 | 53 |
691 | 54 class Main(object): |
1858 | 55 |
892 | 56 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
|
57 self.graph, self.opts, self.session = graph, opts, session |
892 | 58 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
|
59 self.lastSeenInputTime = 0 |
1858 | 60 self.currentSubterms = [ |
61 ] # Subterm objects that are synced to the graph | |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
62 |
1228 | 63 self.setTheme() |
1056
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
64 wtree = self.wtree = Gtk.Builder() |
702 | 65 wtree.add_from_file("light9/curvecalc/curvecalc.glade") |
691 | 66 mainwin = wtree.get_object("MainWindow") |
1858 | 67 |
700
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
68 mainwin.connect("destroy", self.onQuit) |
691 | 69 wtree.connect_signals(self) |
1228 | 70 |
691 | 71 mainwin.show_all() |
72 | |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
73 mainwin.connect("delete-event", lambda *args: reactor.crash()) |
1858 | 74 |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
75 def updateTitle(): |
1858 | 76 mainwin.set_title( |
77 "curvecalc - %s" % | |
78 graph.label(graph.value(session, L9['currentSong']))) | |
79 | |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
80 graph.addHandler(updateTitle) |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
81 |
1858 | 82 songChoice = Observable(None) # to be connected with the session song |
761 | 83 |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
84 self.registerGraphToSongChoice(wtree, session, graph, songChoice) |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
85 self.registerSongChoiceToGraph(session, graph, songChoice) |
1276
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
86 self.registerCurrentPlayerSongToUi(wtree, graph, songChoice) |
1056
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
87 |
856 | 88 ec = EditChoice(graph, songChoice, label="Editing song:") |
89 wtree.get_object("currentSongEditChoice").add(ec) | |
90 ec.show() | |
1858 | 91 |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
92 wtree.get_object("subterms").connect("add", self.onSubtermChildAdded) |
1858 | 93 |
94 self.refreshCurveView() | |
95 | |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
96 self.makeStatusLines(wtree.get_object("status")) |
951
1e01727312f0
CC more drag support and code cleanup
drewp@bigasterisk.com
parents:
950
diff
changeset
|
97 self.setupNewSubZone() |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
98 self.acceptDragsOnCurveViews() |
1858 | 99 |
761 | 100 # may not work |
101 wtree.get_object("paned1").set_position(600) | |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
102 |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
103 def registerGraphToSongChoice(self, wtree, session, graph, songChoice): |
1858 | 104 |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
105 def setSong(): |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
106 current = graph.value(session, L9['currentSong']) |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
107 if not wtree.get_object("followPlayerSongChoice").get_active(): |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
108 songChoice(current) |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
109 dispatcher.send("song_has_changed") |
1858 | 110 |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
111 graph.addHandler(setSong) |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
112 |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
113 def registerSongChoiceToGraph(self, session, graph, songChoice): |
1276
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
114 self.muteSongChoiceUntil = 0 |
1858 | 115 |
1276
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
116 def songChoiceToGraph(newSong): |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
117 if newSong is Local: |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
118 raise NotImplementedError('what do i patch') |
1276
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
119 log.debug('songChoiceToGraph is going to set to %r', newSong) |
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
120 |
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
121 # I get bogus newSong values in here sometimes. This |
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
122 # workaround may not even be helping. |
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
123 now = time.time() |
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
124 if now < self.muteSongChoiceUntil: |
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
125 log.debug('muted') |
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
126 return |
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
127 self.muteSongChoiceUntil = now + 1 |
1858 | 128 |
129 graph.patchObject(context=session, | |
130 subject=session, | |
131 predicate=L9['currentSong'], | |
132 newObject=newSong) | |
133 | |
1276
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
134 songChoice.subscribe(songChoiceToGraph) |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
135 |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
136 def registerCurrentPlayerSongToUi(self, wtree, graph, songChoice): |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
137 """current_player_song 'song' param -> playerSong ui |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
138 and |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
139 current_player_song 'song' param -> songChoice, if you're in autofollow |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
140 """ |
1858 | 141 |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
142 def current_player_song(song): |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
143 # (this is run on every frame) |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
144 ps = wtree.get_object("playerSong") |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
145 if URIRef(ps.get_uri()) != song: |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
146 log.debug("update playerSong to %s", ps.get_uri()) |
1858 | 147 |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
148 def setLabel(): |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
149 ps.set_label(graph.label(song)) |
1858 | 150 |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
151 graph.addHandler(setLabel) |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
152 ps.set_uri(song) |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
153 if song != songChoice(): |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
154 if wtree.get_object("followPlayerSongChoice").get_active(): |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
155 log.debug('followPlayerSongChoice is on') |
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
156 songChoice(song) |
1858 | 157 |
1275
b8e2b8acb02c
try to improve CC toggling
Drew Perttula <drewp@bigasterisk.com>
parents:
1228
diff
changeset
|
158 dispatcher.connect(current_player_song, "current_player_song") |
1276
e4aafd2242aa
CC try to debug why it jumps to random songs sometimes.
Drew Perttula <drewp@bigasterisk.com>
parents:
1275
diff
changeset
|
159 self.current_player_song = current_player_song |
1858 | 160 |
951
1e01727312f0
CC more drag support and code cleanup
drewp@bigasterisk.com
parents:
950
diff
changeset
|
161 def setupNewSubZone(self): |
957
fa78048a3240
new sub zone now makes a curve/sub pair named after the sub, but doesn't make any curve pts
drewp@bigasterisk.com
parents:
951
diff
changeset
|
162 self.wtree.get_object("newSubZone").drag_dest_set( |
1056
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
163 flags=Gtk.DestDefaults.ALL, |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
164 targets=[Gtk.TargetEntry('text/uri-list', 0, 0)], |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
165 actions=Gdk.DragAction.COPY) |
1858 | 166 |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
167 def acceptDragsOnCurveViews(self): |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
168 w = self.wtree.get_object("curves") |
1056
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
169 w.drag_dest_set(flags=Gtk.DestDefaults.ALL, |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
170 targets=[Gtk.TargetEntry('text/uri-list', 0, 0)], |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
171 actions=Gdk.DragAction.COPY) |
1858 | 172 |
173 def recv(widget, context, x, y, selection, targetType, time): | |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
174 subUri = URIRef(selection.data.strip()) |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
175 print("into curves", subUri) |
1858 | 176 with self.graph.currentState(tripleFilter=(subUri, RDFS.label, |
177 None)) as current: | |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
178 subName = current.label(subUri) |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
179 |
994
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
180 if '?' in subUri: |
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
181 subName = self.handleSubtermDrop(subUri) |
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
182 else: |
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
183 try: |
1858 | 184 self.makeSubterm(subName, |
185 withCurve=True, | |
994
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
186 sub=subUri, |
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
187 expr="%s(t)" % subName) |
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
188 except SubtermExists: |
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
189 # we're not making sure the expression/etc are |
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
190 # correct-- user mihgt need to fix things |
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
191 pass |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
192 curveView = self.curvesetView.row(subName).curveView |
1858 | 193 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 |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
194 print("time", t) |
1858 | 195 curveView.add_points([(t - .5, 0), (t, 1)]) |
196 | |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
197 w.connect("drag-data-received", recv) |
1858 | 198 |
951
1e01727312f0
CC more drag support and code cleanup
drewp@bigasterisk.com
parents:
950
diff
changeset
|
199 def onDragDataInNewSubZone(self, widget, context, x, y, selection, |
1858 | 200 targetType, time): |
951
1e01727312f0
CC more drag support and code cleanup
drewp@bigasterisk.com
parents:
950
diff
changeset
|
201 data = URIRef(selection.data.strip()) |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
202 if '?' in data: |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
203 self.handleSubtermDrop(data) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
204 return |
1858 | 205 with self.graph.currentState(tripleFilter=(data, None, |
206 None)) as current: | |
957
fa78048a3240
new sub zone now makes a curve/sub pair named after the sub, but doesn't make any curve pts
drewp@bigasterisk.com
parents:
951
diff
changeset
|
207 subName = current.label(data) |
1858 | 208 self.makeSubterm(newname=subName, |
209 withCurve=True, | |
210 sub=data, | |
957
fa78048a3240
new sub zone now makes a curve/sub pair named after the sub, but doesn't make any curve pts
drewp@bigasterisk.com
parents:
951
diff
changeset
|
211 expr="%s(t)" % subName) |
1858 | 212 |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
213 def handleSubtermDrop(self, data): |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
214 params = parse_qsl(data.split('?')[1]) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
215 flattened = dict(params) |
951
1e01727312f0
CC more drag support and code cleanup
drewp@bigasterisk.com
parents:
950
diff
changeset
|
216 self.makeSubterm(Literal(flattened['subtermName']), |
778
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
217 expr=flattened['subtermExpr']) |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
218 |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
219 for cmd, name in params: |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
220 if cmd == 'curve': |
a2c1dc358bb1
support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents:
773
diff
changeset
|
221 self.curveset.new_curve(name) |
994
304874a34934
support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents:
993
diff
changeset
|
222 return 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
|
223 |
705 | 224 def onNewCurve(self, *args): |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
225 dialog = self.wtree.get_object("newCurve") |
705 | 226 entry = self.wtree.get_object("newCurveName") |
227 # if you don't have songx, that should be the suggested name | |
228 entry.set_text("") | |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
229 if dialog.run() == 1: |
705 | 230 self.curveset.new_curve(entry.get_text()) |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
231 dialog.hide() |
972
92bffc402b52
bring back the ability to redraw canvases, since they still get mangled coords sometimes
drewp@bigasterisk.com
parents:
966
diff
changeset
|
232 |
92bffc402b52
bring back the ability to redraw canvases, since they still get mangled coords sometimes
drewp@bigasterisk.com
parents:
966
diff
changeset
|
233 def onRedrawCurves(self, *args): |
92bffc402b52
bring back the ability to redraw canvases, since they still get mangled coords sometimes
drewp@bigasterisk.com
parents:
966
diff
changeset
|
234 dispatcher.send("all curves rebuild") |
1858 | 235 |
893
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
236 def onSubtermsMap(self, *args): |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
237 # 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
|
238 # 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
|
239 # 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
|
240 # just a wild guess. |
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
241 self.graph.addHandler(self.set_subterms_from_graph) |
1858 | 242 |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
243 def onNewSubterm(self, *args): |
974 | 244 self.makeSubterm(Literal(""), withCurve=False) |
916
9ed01a562288
CC add subterm no longer has dialog; configure it after you make it
drewp@bigasterisk.com
parents:
915
diff
changeset
|
245 return |
9ed01a562288
CC add subterm no longer has dialog; configure it after you make it
drewp@bigasterisk.com
parents:
915
diff
changeset
|
246 |
9ed01a562288
CC add subterm no longer has dialog; configure it after you make it
drewp@bigasterisk.com
parents:
915
diff
changeset
|
247 # pretty sure i don't want this back, but not completely sure |
9ed01a562288
CC add subterm no longer has dialog; configure it after you make it
drewp@bigasterisk.com
parents:
915
diff
changeset
|
248 # what the UX should be to get the new curve. |
1858 | 249 |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
250 dialog = self.wtree.get_object("newSubterm") |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
251 # 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
|
252 # (but let you make one up, too) |
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
253 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
|
254 entry.set_text("") |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
255 entry.grab_focus() |
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
256 if dialog.run() == 1: |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
257 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
|
258 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
|
259 self.makeSubterm(newname, withCurve=wc) |
707
c4a38a247b26
cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents:
706
diff
changeset
|
260 dialog.hide() |
706
16042667ab51
ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents:
705
diff
changeset
|
261 |
915
5054d49ed44e
rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents:
903
diff
changeset
|
262 def currentSong(self): |
5054d49ed44e
rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents:
903
diff
changeset
|
263 |
1858 | 264 with self.graph.currentState(tripleFilter=(self.session, |
265 L9['currentSong'], | |
266 None)) as current: | |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
267 return current.value(self.session, L9['currentSong']) |
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
268 |
915
5054d49ed44e
rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents:
903
diff
changeset
|
269 def songSubtermsContext(self): |
5054d49ed44e
rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents:
903
diff
changeset
|
270 return self.currentSong() |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
271 |
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
|
272 def makeSubterm(self, newname, withCurve=False, expr=None, sub=None): |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
273 """ |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
274 raises SubtermExists if we had a subterm with a sub with the given |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
275 name. what about a no-sub term with the same label? who knows |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
276 """ |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
277 assert isinstance(newname, Literal), repr(newname) |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
278 if withCurve: |
1106
95ed52dcc3ab
remove some old curve api
Drew Perttula <drewp@bigasterisk.com>
parents:
1097
diff
changeset
|
279 self.curveset.new_curve(newname) |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
280 if newname in self.all_subterm_labels(): |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
281 raise SubtermExists("have a subterm who sub is named %r" % newname) |
898
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
282 with self.graph.currentState() as current: |
915
5054d49ed44e
rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents:
903
diff
changeset
|
283 song = self.currentSong() |
898
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
284 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
|
285 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
|
286 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
|
287 break |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
288 else: |
db265102f7b5
shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents:
897
diff
changeset
|
289 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
|
290 |
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
291 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
|
292 quads = [ |
889
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
293 (uri, RDF.type, L9.Subterm, ctx), |
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
294 (uri, RDFS.label, Literal(newname), ctx), |
3b1a435a29b8
start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents:
887
diff
changeset
|
295 (self.currentSong(), L9['subterm'], uri, ctx), |
1858 | 296 ] |
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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 self.graph.patch(Patch(addQuads=quads)) |
1858 | 302 |
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
|
303 return uri |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
304 |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
305 def all_subterm_labels(self): |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
306 """ |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
307 Literal labels of subs in subterms. doesn't currently include labels of the |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
308 subterm resources. I'm not sure what I'm going to do with |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
309 those. |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
310 """ |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
311 labels = [] |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
312 with self.graph.currentState() as current: |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
313 for st in current.objects( |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
314 current.value(self.session, L9['currentSong']), |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
315 L9['subterm']): |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
316 sub = current.value(st, L9['sub']) |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
317 if sub is not None: |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
318 labels.append(current.label(sub)) |
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
319 return labels |
1858 | 320 |
892 | 321 def set_subterms_from_graph(self): |
903
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
322 """rebuild all the gtktable 'subterms' widgets and the |
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
323 self.currentSubterms list""" |
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
324 song = self.graph.value(self.session, L9['currentSong']) |
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
325 |
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
326 newList = [] |
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
327 for st in set(self.graph.objects(song, L9['subterm'])): |
917 | 328 log.debug("song %s has subterm %s", song, st) |
903
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
329 term = Subterm(self.graph, st, self.songSubtermsContext(), |
1858 | 330 self.curveset) |
903
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
331 newList.append(term) |
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
332 self.currentSubterms[:] = newList |
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
333 |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
334 master = self.wtree.get_object("subterms") |
917 | 335 log.debug("removing subterm widgets") |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
336 [master.remove(c) for c in master.get_children()] |
903
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
337 for term in self.currentSubterms: |
893
1b19038f42e2
tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents:
892
diff
changeset
|
338 add_one_subterm(term, self.curveset, master) |
847
431ddd043b47
started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents:
789
diff
changeset
|
339 master.show_all() |
917 | 340 log.debug("%s table children showing" % len(master.get_children())) |
1228 | 341 |
342 def setTheme(self): | |
343 settings = Gtk.Settings.get_default() | |
344 settings.set_property("gtk-application-prefer-dark-theme", True) | |
345 | |
346 providers = [] | |
347 providers.append(Gtk.CssProvider()) | |
348 providers[-1].load_from_path("theme/Just-Dark/gtk-3.0/gtk.css") | |
349 providers.append(Gtk.CssProvider()) | |
350 providers[-1].load_from_data(''' | |
351 * { font-size: 92%; } | |
352 .button:link { font-size: 7px } | |
353 ''') | |
1858 | 354 |
1228 | 355 screen = Gdk.Display.get_default_screen(Gdk.Display.get_default()) |
356 for p in providers: | |
357 Gtk.StyleContext.add_provider_for_screen( | |
1858 | 358 screen, p, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) |
359 | |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
360 def onSubtermChildAdded(self, subtermsTable, *args): |
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
361 # 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
|
362 log.info("onSubtermChildAdded") |
725
e8f9f4815ab4
attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents:
717
diff
changeset
|
363 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
|
364 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
|
365 |
700
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
366 def onQuit(self, *args): |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
367 reactor.crash() |
d5692ab6bc2a
fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents:
699
diff
changeset
|
368 # 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
|
369 # threads. I don't know whose they are. |
901
0dacbba70d06
remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents:
898
diff
changeset
|
370 # 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
|
371 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
|
372 |
715
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
373 def onCollapseAll(self, *args): |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
374 self.curvesetView.collapseAll() |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
375 |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
376 def onCollapseNone(self, *args): |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
377 self.curvesetView.collapseNone() |
9865cf5e07fd
collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents:
711
diff
changeset
|
378 |
711
e94989da079c
more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents:
708
diff
changeset
|
379 def onDelete(self, *args): |
e94989da079c
more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents:
708
diff
changeset
|
380 self.curvesetView.onDelete() |
e94989da079c
more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents:
708
diff
changeset
|
381 |
708 | 382 def onPythonConsole(self, item): |
773 | 383 ns = dict() |
384 ns.update(globals()) | |
385 ns.update(self.__dict__) | |
386 togglePyConsole(self, item, ns) | |
1858 | 387 |
699
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
388 def onSeeCurrentTime(self, item): |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
389 dispatcher.send("see time") |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
390 |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
391 def onSeeTimeUntilEnd(self, item): |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
392 dispatcher.send("see time until end") |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
393 |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
394 def onZoomAll(self, item): |
d12bc8919d6e
ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents:
698
diff
changeset
|
395 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
|
396 |
698
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
397 def onPlayPause(self, item): |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
398 # 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
|
399 # 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
|
400 results = dispatcher.send("onPlayPause") |
2aac2ef23495
time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents:
697
diff
changeset
|
401 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
|
402 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
|
403 |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
404 def onSave(self, *args): |
950
41c6fbe95214
drag sub into curve area to get a curve+subterm and a 0..1 fade at the current play time
drewp@bigasterisk.com
parents:
940
diff
changeset
|
405 # only doing curves still. I hope to eliminate all this. |
1048
86732ba7d9ae
curvecalc now gets its curves from the rdf graph, and can persist their points there too (save is still an explicit command)
Drew Perttula <drewp@bigasterisk.com>
parents:
1036
diff
changeset
|
406 log.info("saving curves") |
86732ba7d9ae
curvecalc now gets its curves from the rdf graph, and can persist their points there too (save is still an explicit command)
Drew Perttula <drewp@bigasterisk.com>
parents:
1036
diff
changeset
|
407 self.curveset.save() |
86732ba7d9ae
curvecalc now gets its curves from the rdf graph, and can persist their points there too (save is still an explicit command)
Drew Perttula <drewp@bigasterisk.com>
parents:
1036
diff
changeset
|
408 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
|
409 |
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
410 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
|
411 """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
|
412 for row, (signame, textfilter) in enumerate([ |
1858 | 413 ('input time', lambda t: "%.2fs" % t), |
414 ('output levels', lambda levels: textwrap.fill( | |
415 "; ".join([ | |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
416 "%s:%.2f" % (n, v) for n, v in list(levels.items())[:2] if v > 0 |
1858 | 417 ]), 70)), |
418 ('update period', lambda t: "%.1fms" % (t * 1000)), | |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
419 ('update status', lambda x: str(x)), |
1858 | 420 ]): |
1056
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
421 key = Gtk.Label("%s:" % signame) |
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
422 value = Gtk.Label("") |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
423 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
|
424 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
|
425 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
|
426 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
|
427 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
|
428 |
1858 | 429 dispatcher.connect(lambda val, value=value, tf=textfilter: value. |
430 set_text(tf(val)), | |
431 signame, | |
432 weak=False) | |
751
5656767ca025
first drop action of a sub successfully gets current music time
drewp@bigasterisk.com
parents:
745
diff
changeset
|
433 dispatcher.connect(lambda val: setattr(self, 'lastSeenInputTime', val), |
1858 | 434 'input time', |
435 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
|
436 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
|
437 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
438 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
|
439 wtree = self.wtree |
1858 | 440 mtimes = [ |
441 os.path.getmtime(f) for f in [ | |
442 'light9/curvecalc/curveview.py', | |
443 'light9/curvecalc/zoomcontrol.py', | |
444 ] | |
445 ] | |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
446 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
447 if (not hasattr(self, 'curvesetView') or |
1858 | 448 self.curvesetView._mtimes != mtimes): |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
449 print("reload curveview.py") |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
450 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
|
451 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
|
452 [curvesVBox.remove(c) for c in curvesVBox.get_children()] |
1858 | 453 [zoomControlBox.remove(c) for c in zoomControlBox.get_children()] |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
454 try: |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
455 linecache.clearcache() |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
456 imp.reload(curveview) |
716
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
457 |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
458 # old ones are not getting deleted right |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
459 if hasattr(self, 'curvesetView'): |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
460 self.curvesetView.live = False |
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
461 |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
462 # mem problem somewhere; need to hold a ref to this |
1858 | 463 self.curvesetView = curveview.Curvesetview( |
464 self.graph, curvesVBox, zoomControlBox, self.curveset) | |
701
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
465 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
|
466 |
417e23dc0af0
add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents:
700
diff
changeset
|
467 # 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
|
468 # 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
|
469 # 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
|
470 # 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
|
471 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
|
472 except Exception: |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
473 print("reload failed:") |
716
348b68723238
collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents:
715
diff
changeset
|
474 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
|
475 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
|
476 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
|
477 |
694
34dacd800505
eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents:
692
diff
changeset
|
478 |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
479 class MaxTime(object): |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
480 """ |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
481 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
|
482 """ |
1858 | 483 |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
484 def __init__(self, graph, session): |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
485 self.graph, self.session = graph, session |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
486 graph.addHandler(self.update) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
487 |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
488 def update(self): |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
489 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
|
490 if song is None: |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
491 self.maxtime = 0 |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
492 return |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
493 musicfilename = showconfig.songOnDisk(song) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
494 self.maxtime = wavelength(musicfilename) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
495 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
|
496 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
|
497 |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
498 def get(self): |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
499 return self.maxtime |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
500 |
1858 | 501 |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
502 def launch(args, graph, session, opts, startTime, music): |
691 | 503 |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
504 try: |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
505 song = URIRef(args[0]) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
506 graph.patchObject(context=session, |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
507 subject=session, |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
508 predicate=L9['currentSong'], |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
509 newObject=song) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
510 except IndexError: |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
511 pass |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
512 |
1097
f7618f29bb89
rewrite CurveSet. remove sliders support from curvecalc. curve edits now write quickly to the graph.
Drew Perttula <drewp@bigasterisk.com>
parents:
1082
diff
changeset
|
513 curveset = Curveset(graph=graph, session=session) |
1858 | 514 |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
515 log.debug("startup: output %s", time.time() - startTime) |
505 | 516 |
848
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
517 mt = MaxTime(graph, session) |
dacbb278d91d
curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents:
847
diff
changeset
|
518 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
|
519 |
892 | 520 start = Main(graph, opts, session, curveset, music) |
903
bca2e8d754aa
tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents:
901
diff
changeset
|
521 out = Output(graph, session, music, curveset, start.currentSubterms) |
692
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
522 |
1858 | 523 dispatcher.send("show all") |
1056
547d65ea9902
port curvecalc to gtk3. mostly worked, but there are severe bugs with redraws
Drew Perttula <drewp@bigasterisk.com>
parents:
1048
diff
changeset
|
524 |
692
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
525 if opts.startup_only: |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
526 log.debug("quitting now because of --startup-only") |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
527 return |
ccdd04f4ca7d
subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents:
691
diff
changeset
|
528 |
1061
f3f66dc32bd8
switch curvecalc web server to cyclone
Drew Perttula <drewp@bigasterisk.com>
parents:
1059
diff
changeset
|
529 def hoverTimeResponse(requestHandler): |
1059
7f5a9958095b
move curvecalc's web server to another file
Drew Perttula <drewp@bigasterisk.com>
parents:
1056
diff
changeset
|
530 results = dispatcher.send("onPlayPause") |
7f5a9958095b
move curvecalc's web server to another file
Drew Perttula <drewp@bigasterisk.com>
parents:
1056
diff
changeset
|
531 times = [t for listener, t in results if t is not None] |
7f5a9958095b
move curvecalc's web server to another file
Drew Perttula <drewp@bigasterisk.com>
parents:
1056
diff
changeset
|
532 if not times: |
1061
f3f66dc32bd8
switch curvecalc web server to cyclone
Drew Perttula <drewp@bigasterisk.com>
parents:
1059
diff
changeset
|
533 requestHandler.set_status(404) |
f3f66dc32bd8
switch curvecalc web server to cyclone
Drew Perttula <drewp@bigasterisk.com>
parents:
1059
diff
changeset
|
534 requestHandler.write("not hovering over any time") |
f3f66dc32bd8
switch curvecalc web server to cyclone
Drew Perttula <drewp@bigasterisk.com>
parents:
1059
diff
changeset
|
535 return |
1858 | 536 with graph.currentState(tripleFilter=(session, L9['currentSong'], |
537 None)) as g: | |
1059
7f5a9958095b
move curvecalc's web server to another file
Drew Perttula <drewp@bigasterisk.com>
parents:
1056
diff
changeset
|
538 song = g.value(session, L9['currentSong']) |
1858 | 539 json.dump({"song": song, "hoverTime": times[0]}, requestHandler) |
540 | |
1063
4e449d40f42c
inputdemo sends updates to curvecalc, which edits the curve. doesn't display right
Drew Perttula <drewp@bigasterisk.com>
parents:
1061
diff
changeset
|
541 serveCurveEdit(networking.curveCalc.port, hoverTimeResponse, start.curveset) |
763
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
542 |
1858 | 543 |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
544 def main(): |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
545 startTime = time.time() |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
546 parser = optparse.OptionParser() |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
547 parser.set_usage("%prog [opts] [songURI]") |
1858 | 548 parser.add_option("--debug", action="store_true", help="log at DEBUG") |
549 parser.add_option("--reload", | |
550 action="store_true", | |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
551 help="live reload of themes and code") |
1858 | 552 parser.add_option("--startup-only", |
553 action='store_true', | |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
554 help="quit after loading everything (for timing tests)") |
1167
5e905ff44e84
CC now suports statprof profiling, and every other profile() call is now broken
drewp@bigasterisk.com
parents:
1114
diff
changeset
|
555 parser.add_option("--profile", help='"hotshot" or "stat"') |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
556 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
|
557 opts, args = parser.parse_args() |
763
ffecebbdcc95
curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents:
761
diff
changeset
|
558 |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
559 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
|
560 |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
561 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
|
562 |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
563 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
|
564 |
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
565 music = Music() |
1114
a38955ba6f40
rdfdb port is now in the config
Drew Perttula <drewp@bigasterisk.com>
parents:
1106
diff
changeset
|
566 graph = SyncedGraph(networking.rdfdb.url, "curvecalc") |
887
4fe5612db2ed
curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents:
856
diff
changeset
|
567 |
1858 | 568 graph.initiallySynced.addCallback(lambda _: launch(args, graph, session, |
569 opts, startTime, music)) | |
1066
e71abaa857ed
curvecalc profile option
Drew Perttula <drewp@bigasterisk.com>
parents:
1065
diff
changeset
|
570 from light9 import prof |
e71abaa857ed
curvecalc profile option
Drew Perttula <drewp@bigasterisk.com>
parents:
1065
diff
changeset
|
571 prof.run(reactor.run, profile=opts.profile) |
505 | 572 |
1858 | 573 |
901
0dacbba70d06
remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents:
898
diff
changeset
|
574 main() |