Changeset - 8152b1dd8a2f
[Not reviewed]
default
0 3 0
drewp@bigasterisk.com - 12 years ago 2013-06-14 18:08:07
drewp@bigasterisk.com
focus on a subterm expression, and we'll bring any curves it mentions up to the top of the curvesetview
Ignore-this: f1a6456ed67a46cfdc7e0b8ba3f6fce7
3 files changed with 40 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/curvecalc/curveview.py
Show inline comments
 
@@ -1142,6 +1142,7 @@ class Curvesetview(object):
 
            self.add_curve(c) 
 

	
 
        dispatcher.connect(self.add_curve, "add_curve", sender=self.curveset)
 
        dispatcher.connect(self.set_featured_curves, "set_featured_curves")
 
        
 
        self.newcurvename = gtk.EntryBuffer("", 0)
 

	
 
@@ -1158,6 +1159,18 @@ class Curvesetview(object):
 
        dispatcher.send("all curves lose selection")
 
        self.curvesVBox.get_parent().grab_focus()
 

	
 
    def curveRow_from_name(self, name):
 
        for cr in self.allCurveRows:
 
            if cr.name == name:
 
                return cr
 
        raise ValueError("couldn't find curveRow named %r" % name)
 

	
 
    def set_featured_curves(self, curveNames):
 
        """bring these curves to the top of the stack"""
 
        for n in curveNames[::-1]:
 
            self.curvesVBox.reorder_child(self.curveRow_from_name(n).box,
 
                                          gtk.PACK_START)
 
        
 
    def onKeyPress(self, widget, event):
 
        if not self.live: # workaround for old instances living past reload()
 
            return
light9/curvecalc/subterm.py
Show inline comments
 
@@ -110,6 +110,17 @@ class Subterm(object):
 
                dispatcher.send("expr_error", sender=self.uri, exc=repr(e))
 
                return Submaster.Submaster(name='Error: %s' % str(e), levels={})
 

	
 
    def curves_used_by_expr(self):
 
        """names of curves that are (maybe) used in this expression"""
 

	
 
        with self.graph.currentState(tripleFilter=(self.uri, None, None)) as current:
 
            expr = current.value(self.uri, L9['expression'])
 

	
 
        used = []
 
        for name in self.curveset.curveNamesInOrder():
 
            if name in expr:
 
                used.append(name)
 
        return used
 

	
 
    def eval(self, current, t):
 
        """current graph is being passed as an optimization. It should be
light9/curvecalc/subtermview.py
Show inline comments
 
@@ -9,9 +9,10 @@ log = logging.getLogger()
 
keep = []
 

	
 
class Subexprview(object):
 
    def __init__(self, graph, ownerSubterm, saveContext):
 
    def __init__(self, graph, ownerSubterm, saveContext, curveset):
 
        self.graph, self.ownerSubterm = graph, ownerSubterm
 
        self.saveContext = saveContext
 
        self.curveset = curveset
 

	
 
        self.box = gtk.HBox()
 

	
 
@@ -27,9 +28,20 @@ class Subexprview(object):
 
        self.entryBuffer.connect("deleted-text", self.entry_changed)
 
        self.entryBuffer.connect("inserted-text", self.entry_changed)
 

	
 
        self.entry.connect("focus-in-event", self.onFocus)
 
        
 
        dispatcher.connect(self.exprError, "expr_error", sender=self.ownerSubterm)
 
        keep.append(self.__dict__)
 

	
 
    def onFocus(self, *args):
 
        curveNames = self.curveset.curveNamesInOrder()
 
        currentExpr = self.entryBuffer.get_text()
 

	
 
        usedCurves = [n for n in curveNames if n in currentExpr]
 
        usedCurves.sort()
 
        
 
        dispatcher.send("set_featured_curves", curveNames=usedCurves)
 
        
 
    def exprError(self, exc):
 
        self.error.set_text(str(exc))
 
        
 
@@ -51,7 +63,7 @@ class Subtermview(object):
 
    """
 
    has .label and .exprView widgets for you to put in a table
 
    """
 
    def __init__(self, st):
 
    def __init__(self, st, curveset):
 
        self.subterm = st
 
        self.graph = st.graph
 

	
 
@@ -63,7 +75,7 @@ class Subtermview(object):
 
                            actions=gtk.gdk.ACTION_COPY)
 
        self.label.connect("drag-data-received", self.onDataReceivedOnLabel)
 
        
 
        sev = Subexprview(self.graph, self.subterm.uri, self.subterm.saveContext)
 
        sev = Subexprview(self.graph, self.subterm.uri, self.subterm.saveContext, curveset)
 
        self.exprView = sev.box
 

	
 
    def onDataReceivedOnLabel(self, widget, context, x, y, selection,
 
@@ -87,7 +99,7 @@ class Subtermview(object):
 
        self.label.set_text(label)
 

	
 
def add_one_subterm(subterm, curveset, master, show=False):
 
    stv = Subtermview(subterm)
 
    stv = Subtermview(subterm, curveset)
 
    
 
    y = master.get_property('n-rows')
 
    master.attach(stv.label, 0, 1, y, y + 1, xoptions=0, yoptions=0)
0 comments (0 inline, 0 general)