The navigator now displays the plots and data in a tree that shows the ancestry information.
This commit is contained in:
@@ -58,7 +58,10 @@ class LogView(gtk.TreeView):
|
||||
#self.connect('button_release_event', None)
|
||||
|
||||
# Make sure tree view displays bottom entry when entered
|
||||
self.model.connect('row-changed', lambda model, path, iter : self.scroll_to_cell(path))
|
||||
def scroll_to_last(model, path, it):
|
||||
if path:
|
||||
self.scroll_to_cell(path)
|
||||
self.model.connect('row-changed', scroll_to_last)
|
||||
|
||||
def set_level(self, level):
|
||||
self.level = level
|
||||
|
@@ -161,13 +161,17 @@ class LargeView (gtk.Frame):
|
||||
|
||||
class Plot (gtk.Frame):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, title):
|
||||
gtk.Frame.__init__(self)
|
||||
self.mark_active(False)
|
||||
self.connect('button_press_event', self.on_button_press)
|
||||
self.sel_obj = None
|
||||
self.active = False
|
||||
|
||||
self.title = title
|
||||
|
||||
def get_title(self):
|
||||
return self.title
|
||||
|
||||
def on_button_press(self, *rest):
|
||||
# logger.log('debug', 'button pressed in plot')
|
||||
self.mark_active(True)
|
||||
@@ -188,7 +192,7 @@ class Plot (gtk.Frame):
|
||||
|
||||
class EmptyView (Plot):
|
||||
def __init__(self):
|
||||
Plot.__init__(self)
|
||||
Plot.__init__(self, 'Empty view')
|
||||
|
||||
label = gtk.Label('No view')
|
||||
ebox = gtk.EventBox()
|
||||
@@ -213,20 +217,22 @@ class EmptyView (Plot):
|
||||
|
||||
class SinePlot(Plot):
|
||||
def __init__(self):
|
||||
Plot.__init__(self)
|
||||
Plot.__init__(self, 'Sine plot')
|
||||
|
||||
fig = Figure(figsize=(5,4), dpi=72)
|
||||
ax = fig.add_subplot(111)
|
||||
t = arange(0.0,3.0,0.01)
|
||||
s = sin(2*pi*t)
|
||||
ax.plot(t,s)
|
||||
|
||||
self.canvas = FigureCanvas(fig)
|
||||
self.add(self.canvas)
|
||||
self.canvas.show()
|
||||
|
||||
|
||||
class ScatterPlot(Plot):
|
||||
def __init__(self, dataset, id_dim, sel_dim, id_1, id_2):
|
||||
Plot.__init__(self)
|
||||
def __init__(self, dataset,id_dim, sel_dim,id_1,id_2):
|
||||
Plot.__init__(self, 'Scatter plot')
|
||||
fig = Figure(figsize=(5,4), dpi=72)
|
||||
self.ax = ax = fig.add_subplot(111)
|
||||
self.current_dim = id_dim
|
||||
|
@@ -45,28 +45,42 @@ class Project:
|
||||
def get_selection(self):
|
||||
"""Returns the current selection object"""
|
||||
return self.sel_obj.current_selection
|
||||
|
||||
|
||||
def get_data_iter(self, obj):
|
||||
"""Retuns an iterator to data."""
|
||||
retval = [None]
|
||||
def is_obj(m, p, i, d):
|
||||
if obj == m.get_value(i, 2):
|
||||
d.append(i)
|
||||
return True
|
||||
|
||||
self.data_tree.foreach(is_obj, retval)
|
||||
return retval[-1]
|
||||
|
||||
def add_data(self, parent, data):
|
||||
"""Adds a set of data and plots to the navigator.
|
||||
|
||||
This method is usually called after a Function in a workflow
|
||||
has finished and returns its output."""
|
||||
|
||||
parent_iter = self.get_data_iter(parent)
|
||||
|
||||
for d in data:
|
||||
if isinstance(d, dataset.Dataset):
|
||||
self.add_dataset(d)
|
||||
self.data_tree_insert(None, d.get_name(), d)
|
||||
self.data_tree_insert(parent_iter, d.get_name(), d)
|
||||
elif isinstance(d, plots.Plot):
|
||||
# self.add_view(d)
|
||||
self.data_tree_insert(None, 'view', d)
|
||||
self.data_tree_insert(parent_iter, d.get_title(), d)
|
||||
d.set_project(self)
|
||||
self.attach(d, 'selection_update')
|
||||
|
||||
def data_tree_insert(self, parent, text, data):
|
||||
tree = self.data_tree
|
||||
iter = tree.append(parent)
|
||||
tree.set_value(iter, 0, text)
|
||||
tree.set_value(iter, 1, type(data))
|
||||
tree.set_value(iter, 2, data)
|
||||
it = tree.append(parent)
|
||||
tree.set_value(it, 0, text)
|
||||
tree.set_value(it, 1, type(data))
|
||||
tree.set_value(it, 2, data)
|
||||
|
||||
def add_dataset(self,dataset):
|
||||
"""Appends a new Dataset to the project."""
|
||||
|
@@ -116,9 +116,12 @@ class WorkflowView (gtk.VBox):
|
||||
def run_function(self, function):
|
||||
logger.log('debug', 'Starting function: %s' % function.name)
|
||||
project = self.workflow.app.project
|
||||
parent_data = project.current_data
|
||||
|
||||
new_data = function.run(project.current_data)
|
||||
if new_data != None:
|
||||
project.add_data(None, new_data)
|
||||
project.add_data(parent_data, new_data)
|
||||
|
||||
logger.log('debug', 'Function ended: %s' % function.name)
|
||||
|
||||
def button_click_handler(self, button):
|
||||
|
Reference in New Issue
Block a user