The navigator now displays the plots and data in a tree that shows the ancestry information.
This commit is contained in:
@@ -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."""
|
||||
|
Reference in New Issue
Block a user