diff --git a/bin/curvecalc b/bin/curvecalc --- a/bin/curvecalc +++ b/bin/curvecalc @@ -30,7 +30,7 @@ from light9.curvecalc import curveview from light9.curvecalc.musicaccess import Music, currentlyPlayingSong from light9.wavelength import wavelength from light9.namespaces import L9 -from light9.curvecalc.subterm import savekey, graphPathForSubterms +from light9.curvecalc.subterm import savekey, graphPathForSubterms, Subterm from light9.curvecalc.subtermview import add_one_subterm from light9.curvecalc.output import Output from light9.gtkpyconsole import togglePyConsole @@ -43,9 +43,9 @@ class SubtermExists(ValueError): pass class Main(object): - def __init__(self, graph, opts, session, curveset, subterms, music): + def __init__(self, graph, opts, session, curveset, music): self.graph, self.opts, self.session = graph, opts, session - self.curveset, self.subterms, self.music = curveset, subterms, music + self.curveset, self.music = curveset, music self.lastSeenInputTime = 0 wtree = self.wtree = gtk.Builder() @@ -83,7 +83,7 @@ class Main(object): ec.show() wtree.get_object("subterms").connect("add", self.onSubtermChildAdded) - graph.addHandler(self.add_subterms_for_song) + graph.addHandler(self.set_subterms_from_graph) self.refreshCurveView() self.makeStatusLines(wtree.get_object("status")) @@ -97,6 +97,8 @@ class Main(object): # that's not enough- deeper windows don't accept the # event. mainwin.forall(connect) # not very effective + + # this probably isn't rerunning often enough to catch new data connect(wtree.get_object("subterms")) # works for that area # may not work @@ -166,10 +168,7 @@ class Main(object): return self.currentSong() def makeSubterm(self, newname, withCurve=False, expr=None): - uri = L9['sub/%s' % newname] - with self.graph.currentState() as current: - if (uri, RDF.type, L9.Subterm) in current: - raise SubtermExists("already have a subterm named %r" % newname) + uri = self.currentSong() + "/sub/%f" % time.time() ctx = self.songSubtermsContext() self.graph.patch(Patch(addQuads=[ @@ -181,20 +180,18 @@ class Main(object): if withCurve: self.curveset.new_curve(newname) - def add_subterms_for_song(self): + def set_subterms_from_graph(self): master = self.wtree.get_object("subterms") + log.info("removing subterm widgets") [master.remove(c) for c in master.get_children()] song = self.graph.value(self.session, L9['currentSong']) - for st in self.graph.objects(song, L9['subterm']): + for st in set(self.graph.objects(song, L9['subterm'])): log.info("song %s has subterm %s", song, st) - add_one_subterm(self.graph, - self.graph.value(st, L9['sub']), - self.curveset, - self.subterms, - master, - self.graph.value(st, L9['expression'])) + #term = Subterm(self.graph, st, self.songSubtermsContext()) + #add_one_subterm(term, self.curveset, master) + master.show_all() def refreshTheme(self): @@ -246,7 +243,7 @@ class Main(object): def onSave(self, *args): with self.graph.currentState() as g: savekey(g.value(self.session, L9['currentSong']), - self.subterms, self.curveset) + self.curveset) def makeStatusLines(self, master): """various labels that listen for dispatcher signals""" @@ -348,7 +345,6 @@ def launch(args, graph, session, opts, s pass curveset = Curveset(sliders=opts.sliders) - subterms = [] def curvesetReload(): # not sure if this clears right or not yet @@ -362,12 +358,12 @@ def launch(args, graph, session, opts, s graph.addHandler(curvesetReload) log.debug("startup: output %s", time.time() - startTime) - out = Output(subterms, music) + out = Output(music) mt = MaxTime(graph, session) dispatcher.connect(lambda: mt.get(), "get max time", weak=False) - start = Main(graph, opts, session, curveset, subterms, music) + start = Main(graph, opts, session, curveset, music) dispatcher.send("show all") @@ -410,7 +406,6 @@ def main(): clientsession.add_option(parser) opts, args = parser.parse_args() - logging.basicConfig(format="%(asctime)s %(levelname)-5s %(name)s %(filename)s:%(lineno)d: %(message)s") log.setLevel(logging.DEBUG if opts.debug else logging.INFO) log.debug("startup: music %s", time.time() - startTime)