annotate bin/curvecalc @ 994:304874a34934

support dropping an effect "uri" into the curve area Ignore-this: 6c50a98847311607d7a87ede16b0543f
author drewp@bigasterisk.com
date Sun, 16 Jun 2013 18:44:45 +0000
parents 17988053ee66
children a13eee92e60c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
686
a301a0039c66 buildout and rdflib updates
Drew Perttula <drewp@bigasterisk.com>
parents: 684
diff changeset
1 #!bin/python
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
62d83d456f2e curvecalc start gtk porting
drewp@bigasterisk.com
parents: 690
diff changeset
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
03453848ed4c refactor musicaccess
drewp@bigasterisk.com
parents: 688
diff changeset
20 import louie as dispatcher
897
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
21 from rdflib import URIRef, Literal, RDF, RDFS
319
2193eab0650b add startup logging to curvecalc
Drew Perttula <drewp@bigasterisk.com>
parents: 296
diff changeset
22 import logging
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
23
897
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
24 from run_local import log
901
0dacbba70d06 remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents: 898
diff changeset
25 from light9 import showconfig, networking
848
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
26 from light9.rdfdb import clientsession
688
97b028ed0e47 curvecalc package move
drewp@bigasterisk.com
parents: 687
diff changeset
27 from light9.curvecalc.curve import Curveset
696
929ccd4ec800 live reloading of curveview.py, very nice
Drew Perttula <drewp@bigasterisk.com>
parents: 695
diff changeset
28 from light9.curvecalc import curveview
897
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
29 from light9.curvecalc.musicaccess import Music
264
0f112a7dd6b3 fix window positoins for subcomposer and curvecalc. now saves geometry continuously
drewp@bigasterisk.com
parents: 248
diff changeset
30 from light9.wavelength import wavelength
335
8a1ec8aca432 more rdf updates
drewp@bigasterisk.com
parents: 332
diff changeset
31 from light9.namespaces import L9
897
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
32 from light9.curvecalc.subterm import Subterm
694
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
33 from light9.curvecalc.subtermview import add_one_subterm
690
847edbfe65c8 refactor subterms
drewp@bigasterisk.com
parents: 689
diff changeset
34 from light9.curvecalc.output import Output
708
10ee0756a119 new python console
Drew Perttula <drewp@bigasterisk.com>
parents: 707
diff changeset
35 from light9.gtkpyconsole import togglePyConsole
847
431ddd043b47 started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents: 789
diff changeset
36 from light9.rdfdb.syncedgraph import SyncedGraph
889
3b1a435a29b8 start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents: 887
diff changeset
37 from light9.rdfdb.patch import Patch
856
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
38 from light9.editchoicegtk import EditChoice
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
39 from light9.observable import Observable
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
40
737
3d1112a894df drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents: 736
diff changeset
41 class SubtermExists(ValueError):
3d1112a894df drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents: 736
diff changeset
42 pass
3d1112a894df drag subs from KC into CC to make a new subterm (if needed) and curve and some points that turn the sub on right now. some bugs about adding a subterm more than once
Drew Perttula <drewp@bigasterisk.com>
parents: 736
diff changeset
43
691
62d83d456f2e curvecalc start gtk porting
drewp@bigasterisk.com
parents: 690
diff changeset
44 class Main(object):
892
95e311bffbd9 working on curvecalc graph sync
drewp@bigasterisk.com
parents: 889
diff changeset
45 def __init__(self, graph, opts, session, curveset, music):
848
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
46 self.graph, self.opts, self.session = graph, opts, session
892
95e311bffbd9 working on curvecalc graph sync
drewp@bigasterisk.com
parents: 889
diff changeset
47 self.curveset, self.music = curveset, music
751
5656767ca025 first drop action of a sub successfully gets current music time
drewp@bigasterisk.com
parents: 745
diff changeset
48 self.lastSeenInputTime = 0
903
bca2e8d754aa tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents: 901
diff changeset
49 self.currentSubterms = [] # 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
50
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
51 wtree = self.wtree = gtk.Builder()
702
155c7bb9c948 window geom
Drew Perttula <drewp@bigasterisk.com>
parents: 701
diff changeset
52 wtree.add_from_file("light9/curvecalc/curvecalc.glade")
691
62d83d456f2e curvecalc start gtk porting
drewp@bigasterisk.com
parents: 690
diff changeset
53 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
54
d5692ab6bc2a fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents: 699
diff changeset
55 mainwin.connect("destroy", self.onQuit)
691
62d83d456f2e curvecalc start gtk porting
drewp@bigasterisk.com
parents: 690
diff changeset
56 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
57 gtk.rc_parse("theme/marble-ice/gtk-2.0/gtkrc")
993
17988053ee66 bigger CC font for small screen
drewp@bigasterisk.com
parents: 974
diff changeset
58 gtk.rc_parse_string("""style "default" {font_name = "sans 9"}""")
701
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
59 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
60 self.refreshTheme()
691
62d83d456f2e curvecalc start gtk porting
drewp@bigasterisk.com
parents: 690
diff changeset
61 mainwin.show_all()
62d83d456f2e curvecalc start gtk porting
drewp@bigasterisk.com
parents: 690
diff changeset
62
694
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
63 mainwin.connect("delete-event", lambda *args: reactor.crash())
847
431ddd043b47 started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents: 789
diff changeset
64 def updateTitle():
848
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
65 mainwin.set_title("curvecalc - %s" %
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
66 graph.label(
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
67 graph.value(session, L9['currentSong'])))
847
431ddd043b47 started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents: 789
diff changeset
68 graph.addHandler(updateTitle)
752
20d6884478bc fixes for machine swap
drewp@bigasterisk.com
parents: 751
diff changeset
69 mainwin.parse_geometry("1x1-0+0")
702
155c7bb9c948 window geom
Drew Perttula <drewp@bigasterisk.com>
parents: 701
diff changeset
70
155c7bb9c948 window geom
Drew Perttula <drewp@bigasterisk.com>
parents: 701
diff changeset
71 # this is the only one i found that would set the size right,
155c7bb9c948 window geom
Drew Perttula <drewp@bigasterisk.com>
parents: 701
diff changeset
72 # but it's a minimum size, which i don't really want
745
62f99e2a00ac updates for screen size
drewp@bigasterisk.com
parents: 737
diff changeset
73 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
74
856
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
75 songChoice = Observable(None) # to be connected with the session song
761
857aab04f7bd CC layout to fit more curves
drewp@bigasterisk.com
parents: 760
diff changeset
76
856
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
77 def setSong():
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
78 songChoice(graph.value(session, L9['currentSong']))
966
16c771461cde attempt to fix zoom corruption when CC song changes, but this didn't work
drewp@bigasterisk.com
parents: 964
diff changeset
79 dispatcher.send("song_has_changed")
856
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
80 graph.addHandler(setSong)
897
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
81 # next here, watch songChoice and patch the graph
964
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
82 def songToGraph(newSong):
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
83 graph.patchObject(context=session, subject=session,
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
84 predicate=L9['currentSong'], newObject=newSong)
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
85 songChoice.subscribe(songToGraph)
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
86 def current_player_song(song):
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
87 # (this is run on every frame)
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
88 ps = wtree.get_object("playerSong")
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
89 if URIRef(ps.get_uri()) != song:
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
90 print "update playerSong"
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
91 def setLabel():
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
92 ps.set_label(graph.label(song))
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
93 graph.addHandler(setLabel)
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
94 ps.set_uri(song)
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
95 if song != songChoice():
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
96 if wtree.get_object("followPlayerSongChoice").get_active():
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
97 songChoice(song)
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
98
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
99 self.current_player_song = current_player_song
ced2c5e5fb31 curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
drewp@bigasterisk.com
parents: 957
diff changeset
100 dispatcher.connect(current_player_song, "current_player_song")
856
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
101
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
102 ec = EditChoice(graph, songChoice, label="Editing song:")
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
103 wtree.get_object("currentSongEditChoice").add(ec)
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
104 ec.show()
a59d0f4563cc starting curvecalc editchoice
drewp@bigasterisk.com
parents: 848
diff changeset
105
725
e8f9f4815ab4 attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents: 717
diff changeset
106 wtree.get_object("subterms").connect("add", self.onSubtermChildAdded)
893
1b19038f42e2 tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents: 892
diff changeset
107
1b19038f42e2 tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents: 892
diff changeset
108
701
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
109 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
110
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
111 self.makeStatusLines(wtree.get_object("status"))
951
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
112 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
113 self.acceptDragsOnCurveViews()
951
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
114
761
857aab04f7bd CC layout to fit more curves
drewp@bigasterisk.com
parents: 760
diff changeset
115 # may not work
857aab04f7bd CC layout to fit more curves
drewp@bigasterisk.com
parents: 760
diff changeset
116 wtree.get_object("paned1").set_position(600)
857aab04f7bd CC layout to fit more curves
drewp@bigasterisk.com
parents: 760
diff changeset
117
951
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
118 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
119 self.wtree.get_object("newSubZone").drag_dest_set(
951
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
120 flags=gtk.DEST_DEFAULT_ALL,
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
121 targets=[('text/uri-list', 0, 0)],
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
122 actions=gtk.gdk.ACTION_COPY)
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
123
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
124 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
125 w = self.wtree.get_object("curves")
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
126 w.drag_dest_set(flags=gtk.DEST_DEFAULT_ALL,
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
127 targets=[('text/uri-list', 0, 0)],
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
128 actions=gtk.gdk.ACTION_COPY)
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
129 def recv(widget, context, x, y, selection,
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
130 targetType, time):
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
131 subUri = URIRef(selection.data.strip())
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
132 print "into curves", 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
133 with self.graph.currentState(
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
134 tripleFilter=(subUri, RDFS.label, None)) 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
135 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
136
994
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
137 if '?' in subUri:
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
138 subName = self.handleSubtermDrop(subUri)
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
139 else:
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
140 try:
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
141 self.makeSubterm(subName, withCurve=True,
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
142 sub=subUri,
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
143 expr="%s(t)" % subName)
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
144 except SubtermExists:
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
145 # 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
146 # correct-- user mihgt need to fix things
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
147 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
148 curveView = self.curvesetView.row(subName).curveView
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
149 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
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
150 print "time", t
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
151 curveView.add_points([(t - .5, 0),
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
152 (t, 1)])
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
153 w.connect("drag-data-received", recv)
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
154
951
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
155 def onDragDataInNewSubZone(self, widget, context, x, y, selection,
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
156 targetType, time):
951
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
157 data = URIRef(selection.data.strip())
778
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
158 if '?' in data:
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
159 self.handleSubtermDrop(data)
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
160 return
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
161 with self.graph.currentState(tripleFilter=(data, None, None)) as current:
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 subName = current.label(data)
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
163 self.makeSubterm(newname=subName, withCurve=True, sub=data,
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
164 expr="%s(t)" % subName)
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
165
778
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
166 def handleSubtermDrop(self, data):
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
167 params = parse_qsl(data.split('?')[1])
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
168 flattened = dict(params)
951
1e01727312f0 CC more drag support and code cleanup
drewp@bigasterisk.com
parents: 950
diff changeset
169 self.makeSubterm(Literal(flattened['subtermName']),
778
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
170 expr=flattened['subtermExpr'])
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
171
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
172 for cmd, name in params:
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
173 if cmd == 'curve':
a2c1dc358bb1 support dragging in a url to make curves and subterms
drewp@bigasterisk.com
parents: 773
diff changeset
174 self.curveset.new_curve(name)
994
304874a34934 support dropping an effect "uri" into the curve area
drewp@bigasterisk.com
parents: 993
diff changeset
175 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
176
705
ed50631cf333 new curve dialog
Drew Perttula <drewp@bigasterisk.com>
parents: 704
diff changeset
177 def onNewCurve(self, *args):
707
c4a38a247b26 cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents: 706
diff changeset
178 dialog = self.wtree.get_object("newCurve")
705
ed50631cf333 new curve dialog
Drew Perttula <drewp@bigasterisk.com>
parents: 704
diff changeset
179 entry = self.wtree.get_object("newCurveName")
ed50631cf333 new curve dialog
Drew Perttula <drewp@bigasterisk.com>
parents: 704
diff changeset
180 # if you don't have songx, that should be the suggested name
ed50631cf333 new curve dialog
Drew Perttula <drewp@bigasterisk.com>
parents: 704
diff changeset
181 entry.set_text("")
707
c4a38a247b26 cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents: 706
diff changeset
182 if dialog.run() == 1:
705
ed50631cf333 new curve dialog
Drew Perttula <drewp@bigasterisk.com>
parents: 704
diff changeset
183 self.curveset.new_curve(entry.get_text())
707
c4a38a247b26 cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents: 706
diff changeset
184 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
185
92bffc402b52 bring back the ability to redraw canvases, since they still get mangled coords sometimes
drewp@bigasterisk.com
parents: 966
diff changeset
186 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
187 dispatcher.send("all curves rebuild")
893
1b19038f42e2 tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents: 892
diff changeset
188
1b19038f42e2 tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents: 892
diff changeset
189 def onSubtermsMap(self, *args):
1b19038f42e2 tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents: 892
diff changeset
190 # 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
191 # 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
192 # 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
193 # just a wild guess.
1b19038f42e2 tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents: 892
diff changeset
194 self.graph.addHandler(self.set_subterms_from_graph)
1b19038f42e2 tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents: 892
diff changeset
195
706
16042667ab51 ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents: 705
diff changeset
196 def onNewSubterm(self, *args):
974
892a6ff719cf fix subterm 'add' button
drewp@bigasterisk.com
parents: 972
diff changeset
197 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
198 return
9ed01a562288 CC add subterm no longer has dialog; configure it after you make it
drewp@bigasterisk.com
parents: 915
diff changeset
199
9ed01a562288 CC add subterm no longer has dialog; configure it after you make it
drewp@bigasterisk.com
parents: 915
diff changeset
200 # 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
201 # what the UX should be to get the new curve.
9ed01a562288 CC add subterm no longer has dialog; configure it after you make it
drewp@bigasterisk.com
parents: 915
diff changeset
202
707
c4a38a247b26 cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents: 706
diff changeset
203 dialog = self.wtree.get_object("newSubterm")
706
16042667ab51 ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents: 705
diff changeset
204 # 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
205 # (but let you make one up, too)
16042667ab51 ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents: 705
diff changeset
206 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
207 entry.set_text("")
707
c4a38a247b26 cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents: 706
diff changeset
208 entry.grab_focus()
c4a38a247b26 cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents: 706
diff changeset
209 if dialog.run() == 1:
706
16042667ab51 ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents: 705
diff changeset
210 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
211 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
212 self.makeSubterm(newname, withCurve=wc)
707
c4a38a247b26 cleanup. 'create' menu
Drew Perttula <drewp@bigasterisk.com>
parents: 706
diff changeset
213 dialog.hide()
706
16042667ab51 ui for making a new subterm
Drew Perttula <drewp@bigasterisk.com>
parents: 705
diff changeset
214
915
5054d49ed44e rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents: 903
diff changeset
215 def currentSong(self):
5054d49ed44e rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents: 903
diff changeset
216
5054d49ed44e rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents: 903
diff changeset
217 with self.graph.currentState(
5054d49ed44e rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents: 903
diff changeset
218 tripleFilter=(self.session, L9['currentSong'], None)
5054d49ed44e rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents: 903
diff changeset
219 ) as current:
889
3b1a435a29b8 start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents: 887
diff changeset
220 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
221
915
5054d49ed44e rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents: 903
diff changeset
222 def songSubtermsContext(self):
5054d49ed44e rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents: 903
diff changeset
223 return self.currentSong()
889
3b1a435a29b8 start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents: 887
diff changeset
224
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
225 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
226 """
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
227 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
228 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
229 """
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
230 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
231 if withCurve:
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
232 self.curveset.new_curve(newname, renameIfExisting=False)
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
233 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
234 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
235 with self.graph.currentState() as current:
915
5054d49ed44e rework some CC currentGraph optimizations
drewp@bigasterisk.com
parents: 903
diff changeset
236 song = self.currentSong()
898
db265102f7b5 shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents: 897
diff changeset
237 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
238 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
239 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
240 break
db265102f7b5 shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents: 897
diff changeset
241 else:
db265102f7b5 shorter names on subterm uris. new sub zone ui padding.
Drew Perttula <drewp@bigasterisk.com>
parents: 897
diff changeset
242 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
243
3b1a435a29b8 start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents: 887
diff changeset
244 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
245 quads = [
889
3b1a435a29b8 start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents: 887
diff changeset
246 (uri, RDF.type, L9.Subterm, ctx),
3b1a435a29b8 start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents: 887
diff changeset
247 (uri, RDFS.label, Literal(newname), ctx),
3b1a435a29b8 start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents: 887
diff changeset
248 (self.currentSong(), L9['subterm'], uri, ctx),
897
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
249 ]
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
250 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
251 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
252 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
253 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
254 self.graph.patch(Patch(addQuads=quads))
889
3b1a435a29b8 start fixing curvecalc data model; not done yet
Drew Perttula <drewp@bigasterisk.com>
parents: 887
diff changeset
255
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
256 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
257
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
258 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
259 """
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
260 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
261 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
262 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
263 """
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
264 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
265 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
266 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
267 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
268 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
269 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
270 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
271 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
272 return 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
273
892
95e311bffbd9 working on curvecalc graph sync
drewp@bigasterisk.com
parents: 889
diff changeset
274 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
275 """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
276 self.currentSubterms list"""
bca2e8d754aa tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents: 901
diff changeset
277 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
278
bca2e8d754aa tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents: 901
diff changeset
279 newList = []
bca2e8d754aa tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents: 901
diff changeset
280 for st in set(self.graph.objects(song, L9['subterm'])):
917
e7d5f008b2fa push some subterm logging to debug
drewp@bigasterisk.com
parents: 916
diff changeset
281 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
282 term = Subterm(self.graph, st, self.songSubtermsContext(),
bca2e8d754aa tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents: 901
diff changeset
283 self.curveset)
bca2e8d754aa tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents: 901
diff changeset
284 newList.append(term)
bca2e8d754aa tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents: 901
diff changeset
285 self.currentSubterms[:] = newList
bca2e8d754aa tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs
Drew Perttula <drewp@bigasterisk.com>
parents: 901
diff changeset
286
847
431ddd043b47 started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents: 789
diff changeset
287 master = self.wtree.get_object("subterms")
917
e7d5f008b2fa push some subterm logging to debug
drewp@bigasterisk.com
parents: 916
diff changeset
288 log.debug("removing subterm widgets")
847
431ddd043b47 started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents: 789
diff changeset
289 [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
290 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
291 add_one_subterm(term, self.curveset, master)
847
431ddd043b47 started porting curvecalc to SyncedGraph
drewp@bigasterisk.com
parents: 789
diff changeset
292 master.show_all()
917
e7d5f008b2fa push some subterm logging to debug
drewp@bigasterisk.com
parents: 916
diff changeset
293 log.debug("%s table children showing" % len(master.get_children()))
893
1b19038f42e2 tricky fix for curvecalc not displaying subterms at launch
Drew Perttula <drewp@bigasterisk.com>
parents: 892
diff changeset
294
701
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
295 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
296 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
297 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
298
725
e8f9f4815ab4 attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents: 717
diff changeset
299 def onSubtermChildAdded(self, subtermsTable, *args):
e8f9f4815ab4 attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents: 717
diff changeset
300 # 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
301 log.info("onSubtermChildAdded")
725
e8f9f4815ab4 attempt at subtermview autoscroll but it doesn't work
Drew Perttula <drewp@bigasterisk.com>
parents: 717
diff changeset
302 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
303 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
304
700
d5692ab6bc2a fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents: 699
diff changeset
305 def onQuit(self, *args):
d5692ab6bc2a fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents: 699
diff changeset
306 reactor.crash()
d5692ab6bc2a fix quit and ctrl-q by using kill -9
Drew Perttula <drewp@bigasterisk.com>
parents: 699
diff changeset
307 # 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
308 # threads. I don't know whose they are.
901
0dacbba70d06 remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents: 898
diff changeset
309 # 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
310 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
311
715
9865cf5e07fd collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents: 711
diff changeset
312 def onCollapseAll(self, *args):
9865cf5e07fd collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents: 711
diff changeset
313 self.curvesetView.collapseAll()
9865cf5e07fd collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents: 711
diff changeset
314
9865cf5e07fd collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents: 711
diff changeset
315 def onCollapseNone(self, *args):
9865cf5e07fd collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents: 711
diff changeset
316 self.curvesetView.collapseNone()
9865cf5e07fd collapse and mute support. very hard
Drew Perttula <drewp@bigasterisk.com>
parents: 711
diff changeset
317
711
e94989da079c more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents: 708
diff changeset
318 def onDelete(self, *args):
e94989da079c more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents: 708
diff changeset
319 self.curvesetView.onDelete()
e94989da079c more curve editor bindings. delete signal isn't done
drewp@bigasterisk.com
parents: 708
diff changeset
320
708
10ee0756a119 new python console
Drew Perttula <drewp@bigasterisk.com>
parents: 707
diff changeset
321 def onPythonConsole(self, item):
773
24db623e2097 more vars in the python console
drewp@bigasterisk.com
parents: 772
diff changeset
322 ns = dict()
24db623e2097 more vars in the python console
drewp@bigasterisk.com
parents: 772
diff changeset
323 ns.update(globals())
24db623e2097 more vars in the python console
drewp@bigasterisk.com
parents: 772
diff changeset
324 ns.update(self.__dict__)
24db623e2097 more vars in the python console
drewp@bigasterisk.com
parents: 772
diff changeset
325 togglePyConsole(self, item, ns)
708
10ee0756a119 new python console
Drew Perttula <drewp@bigasterisk.com>
parents: 707
diff changeset
326
699
d12bc8919d6e ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents: 698
diff changeset
327 def onSeeCurrentTime(self, item):
d12bc8919d6e ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents: 698
diff changeset
328 dispatcher.send("see time")
d12bc8919d6e ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents: 698
diff changeset
329
d12bc8919d6e ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents: 698
diff changeset
330 def onSeeTimeUntilEnd(self, item):
d12bc8919d6e ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents: 698
diff changeset
331 dispatcher.send("see time until end")
d12bc8919d6e ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents: 698
diff changeset
332
d12bc8919d6e ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents: 698
diff changeset
333 def onZoomAll(self, item):
d12bc8919d6e ported the zoom control
Drew Perttula <drewp@bigasterisk.com>
parents: 698
diff changeset
334 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
335
698
2aac2ef23495 time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents: 697
diff changeset
336 def onPlayPause(self, item):
2aac2ef23495 time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents: 697
diff changeset
337 # 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
338 # 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
339 results = dispatcher.send("onPlayPause")
2aac2ef23495 time cursor, control-p over curveviews
Drew Perttula <drewp@bigasterisk.com>
parents: 697
diff changeset
340 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
341 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
342
694
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
343 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
344 # only doing curves still. I hope to eliminate all this.
848
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
345 with self.graph.currentState() as g:
897
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
346 song = g.value(self.session, L9['currentSong'])
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
347
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
348 log.info("saving curves for %r", song)
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
349 self.curveset.save(basename=os.path.join(
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
350 showconfig.curvesDir(),
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
351 showconfig.songFilenameFromURI(song)))
fc651955d6d9 curvecalc takes drops for new subterms and also to edit the sub of an existing one
Drew Perttula <drewp@bigasterisk.com>
parents: 894
diff changeset
352 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
353
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
354 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
355 """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
356 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
357 ('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
358 ('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
359 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
360 for n,v in
779
d3f6830f55a2 stop output entry box bouncing around
drewp@bigasterisk.com
parents: 778
diff changeset
361 levels.items()[:2]
694
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
362 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
363 ('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
364 ('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
365 ]):
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
366 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
367 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
368 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
369 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
370 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
371 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
372 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
373
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
374 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
375 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
376 signame, weak=False)
751
5656767ca025 first drop action of a sub successfully gets current music time
drewp@bigasterisk.com
parents: 745
diff changeset
377 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
378 '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
379 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
380
701
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
381 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
382 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
383 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
384 '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
385 '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
386 ]]
694
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
387
701
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
388 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
389 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
390 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
391 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
392 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
393 [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
394 [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
395 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
396 try:
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
397 linecache.clearcache()
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
398 reload(curveview)
716
348b68723238 collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents: 715
diff changeset
399
348b68723238 collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents: 715
diff changeset
400 # old ones are not getting deleted right
348b68723238 collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents: 715
diff changeset
401 if hasattr(self, 'curvesetView'):
348b68723238 collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents: 715
diff changeset
402 self.curvesetView.live = False
348b68723238 collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents: 715
diff changeset
403
701
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
404 # 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
405 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
406 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
407 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
408
417e23dc0af0 add marble-ice theme. use --reload to opt in to all autoreloading
Drew Perttula <drewp@bigasterisk.com>
parents: 700
diff changeset
409 # 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
410 # 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
411 # 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
412 # 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
413 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
414 except Exception:
716
348b68723238 collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents: 715
diff changeset
415 print "reload failed:"
348b68723238 collapse mode. reload() hacks. rebuild key
Drew Perttula <drewp@bigasterisk.com>
parents: 715
diff changeset
416 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
417 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
418 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
419
694
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
420
848
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
421 class MaxTime(object):
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
422 """
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
423 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
424 """
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
425 def __init__(self, graph, session):
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
426 self.graph, self.session = graph, session
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
427 graph.addHandler(self.update)
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
428
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
429 def update(self):
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
430 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
431 if song is None:
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
432 self.maxtime = 0
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
433 return
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
434 musicfilename = showconfig.songOnDisk(song)
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
435 self.maxtime = wavelength(musicfilename)
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
436 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
437 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
438
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
439 def get(self):
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
440 return self.maxtime
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
441
887
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
442 def launch(args, graph, session, opts, startTime, music):
691
62d83d456f2e curvecalc start gtk porting
drewp@bigasterisk.com
parents: 690
diff changeset
443
848
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
444 try:
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
445 song = URIRef(args[0])
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
446 graph.patchObject(context=session,
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
447 subject=session,
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
448 predicate=L9['currentSong'],
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
449 newObject=song)
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
450 except IndexError:
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
451 pass
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
452
505
cbc98de2ab06 refactor curveCalc toplevel
drewp@bigasterisk.com
parents: 493
diff changeset
453 curveset = Curveset(sliders=opts.sliders)
cbc98de2ab06 refactor curveCalc toplevel
drewp@bigasterisk.com
parents: 493
diff changeset
454
848
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
455 def curvesetReload():
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
456 # not sure if this clears right or not yet
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
457 song = graph.value(session, L9['currentSong'])
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
458 if song is None:
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
459 return
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
460 curveset.load(basename=os.path.join(
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
461 showconfig.curvesDir(),
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
462 showconfig.songFilenameFromURI(song)),
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
463 skipMusic=opts.skip_music)
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
464 graph.addHandler(curvesetReload)
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
465
680
ad17b0a09f5c CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents: 641
diff changeset
466 log.debug("startup: output %s", time.time() - startTime)
505
cbc98de2ab06 refactor curveCalc toplevel
drewp@bigasterisk.com
parents: 493
diff changeset
467
848
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
468 mt = MaxTime(graph, session)
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
469 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
470
892
95e311bffbd9 working on curvecalc graph sync
drewp@bigasterisk.com
parents: 889
diff changeset
471 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
472 out = Output(graph, session, music, curveset, start.currentSubterms)
692
ccdd04f4ca7d subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents: 691
diff changeset
473
694
34dacd800505 eval loop is running, music drives lights. started to add goocanvas curve view
Drew Perttula <drewp@bigasterisk.com>
parents: 692
diff changeset
474 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
475
692
ccdd04f4ca7d subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents: 691
diff changeset
476 if opts.startup_only:
ccdd04f4ca7d subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents: 691
diff changeset
477 log.debug("quitting now because of --startup-only")
ccdd04f4ca7d subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents: 691
diff changeset
478 return
ccdd04f4ca7d subterm display is working
Drew Perttula <drewp@bigasterisk.com>
parents: 691
diff changeset
479
763
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
480 from twisted.web import server, resource
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
481 class Hover(resource.Resource):
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
482 isLeaf = True
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
483 def render_GET(self, request):
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
484 if request.path == '/hoverTime':
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
485 results = dispatcher.send("onPlayPause")
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
486 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
487 if not times:
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
488 request.setResponseCode(404)
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
489 return "not hovering over any time"
940
183e3afea4cc curvecalc tripleFilter optimization
drewp@bigasterisk.com
parents: 917
diff changeset
490 with graph.currentState(
183e3afea4cc curvecalc tripleFilter optimization
drewp@bigasterisk.com
parents: 917
diff changeset
491 tripleFilter=(session, L9['currentSong'], None)) as g:
848
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
492 song = g.value(session, L9['currentSong'])
dacbb278d91d curvecalc port to SyncedGraph. starts up ok, saving is broken
drewp@bigasterisk.com
parents: 847
diff changeset
493 return json.dumps({"song": song, "hoverTime" : times[0]})
763
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
494 raise NotImplementedError()
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
495
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
496 reactor.listenTCP(networking.curveCalc.port,
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
497 server.Site(Hover()))
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
498
887
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
499 def main():
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
500 startTime = time.time()
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
501 parser = optparse.OptionParser()
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
502 parser.set_usage("%prog [opts] [songURI]")
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
503 parser.add_option("--sliders", action='store_true',
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
504 help='use hardware sliders')
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
505 parser.add_option("--skip-music", action='store_true',
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
506 help="ignore music and smooth_music curve files")
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
507 parser.add_option("--debug", action="store_true",
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
508 help="log at DEBUG")
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
509 parser.add_option("--reload", action="store_true",
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
510 help="live reload of themes and code")
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
511 parser.add_option("--startup-only", action='store_true',
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
512 help="quit after loading everything (for timing tests)")
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
513 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
514 opts, args = parser.parse_args()
763
ffecebbdcc95 curvecalc serves the time you're hovering over
drewp@bigasterisk.com
parents: 761
diff changeset
515
887
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
516 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
517
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
518 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
519
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
520
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
521 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
522
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
523 music = Music()
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
524 graph = SyncedGraph("curvecalc")
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
525
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
526 graph.initiallySynced.addCallback(
4fe5612db2ed curvecalc don't start doing graph work until our first sync
Drew Perttula <drewp@bigasterisk.com>
parents: 856
diff changeset
527 lambda _: launch(args, graph, session, opts, startTime, music))
901
0dacbba70d06 remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents: 898
diff changeset
528
0dacbba70d06 remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents: 898
diff changeset
529 reactor.run()
505
cbc98de2ab06 refactor curveCalc toplevel
drewp@bigasterisk.com
parents: 493
diff changeset
530
901
0dacbba70d06 remove some broken profiler attempts
Drew Perttula <drewp@bigasterisk.com>
parents: 898
diff changeset
531 main()
789
ea8ca6502255 refactor to prepare for submasters to work out of the main graph
drewp@bigasterisk.com
parents: 779
diff changeset
532