Changeset - fa78048a3240
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 12 years ago 2013-06-15 07:06:59
drewp@bigasterisk.com
new sub zone now makes a curve/sub pair named after the sub, but doesn't make any curve pts
Ignore-this: cb012de849b4c8915f94c67a0254c987
1 file changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -75,88 +75,91 @@ class Main(object):
 
        songChoice = Observable(None) # to be connected with the session song
 

	
 
        def setSong():
 
            songChoice(graph.value(session, L9['currentSong']))
 
        graph.addHandler(setSong)
 
        # next here, watch songChoice and patch the graph
 
        
 
        ec = EditChoice(graph, songChoice, label="Editing song:")
 
        wtree.get_object("currentSongEditChoice").add(ec)
 
        ec.show()
 
        
 
        wtree.get_object("subterms").connect("add", self.onSubtermChildAdded)
 
        
 

	
 
        self.refreshCurveView()       
 
        
 
        self.makeStatusLines(wtree.get_object("status"))
 
        self.setupNewSubZone()
 
        self.acceptDragsOnCurveViews()
 
                
 
        # may not work
 
        wtree.get_object("paned1").set_position(600)
 

	
 
    def setupNewSubZone(self):
 
        wtree.get_object("newSubZone").drag_dest_set(
 
        self.wtree.get_object("newSubZone").drag_dest_set(
 
            flags=gtk.DEST_DEFAULT_ALL,
 
            targets=[('text/uri-list', 0, 0)],
 
            actions=gtk.gdk.ACTION_COPY)
 
        
 
    def acceptDragsOnCurveViews(self):
 
        w = self.wtree.get_object("curves")
 
        w.drag_dest_set(flags=gtk.DEST_DEFAULT_ALL,
 
                        targets=[('text/uri-list', 0, 0)],
 
                        actions=gtk.gdk.ACTION_COPY)
 
        def recv(widget, context, x, y, selection,
 
                       targetType, time):
 
            subUri = URIRef(selection.data.strip())
 
            print "into curves", subUri
 
            with self.graph.currentState(
 
                    tripleFilter=(subUri, RDFS.label, None)) as current:
 
                subName = current.label(subUri)
 

	
 
            try:
 
                self.makeSubterm(subName, withCurve=True,
 
                                 sub=subUri,
 
                                 expr="%s(t)" % subName)
 
            except SubtermExists:
 
                # we're not making sure the expression/etc are
 
                # correct-- user mihgt need to fix things
 
                pass
 
            curveView = self.curvesetView.row(subName).curveView
 
            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
 
            print "time", t
 
            curveView.add_points([(t - .5, 0),
 
                                  (t, 1)])
 
        w.connect("drag-data-received", recv)
 
        
 
    def onDragDataInNewSubZone(self, widget, context, x, y, selection,
 
                       targetType, time):
 
        data = URIRef(selection.data.strip())
 
        if '?' in data:
 
            self.handleSubtermDrop(data)
 
            return
 
        self.makeSubterm(newname="cx", withCurve=True, sub=data)
 
        with self.graph.currentState(tripleFilter=(data, None, None)) as current:
 
            subName = current.label(data)
 
        self.makeSubterm(newname=subName, withCurve=True, sub=data,
 
                         expr="%s(t)" % subName)
 
        
 
    def handleSubtermDrop(self, data):
 
        params = parse_qsl(data.split('?')[1])
 
        flattened = dict(params)
 
        self.makeSubterm(Literal(flattened['subtermName']),
 
                         expr=flattened['subtermExpr'])
 

	
 
        for cmd, name in params:
 
            if cmd == 'curve':
 
                self.curveset.new_curve(name)
 

	
 
    def onNewCurve(self, *args):
 
        dialog = self.wtree.get_object("newCurve")
 
        entry = self.wtree.get_object("newCurveName")
 
        # if you don't have songx, that should be the suggested name
 
        entry.set_text("")
 
        if dialog.run() == 1:
 
            self.curveset.new_curve(entry.get_text())
 
        dialog.hide()
 
        
 
    def onSubtermsMap(self, *args):
 
        # if this was called too soon, like in __init__, the gtktable
 
        # would get its children but it wouldn't lay anything out that
 
        # I can see, and I'm not sure why. Waiting for map event is
0 comments (0 inline, 0 general)