Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Added function to split datasets on selection.

This commit is contained in:
Einar Ryeng 2008-02-06 19:54:17 +00:00
parent b37ebe568f
commit e6a671a8c0
1 changed files with 23 additions and 0 deletions

View File

@ -199,6 +199,11 @@ class NavigatorMenu(gtk.Menu):
self.append(self.delete_item)
self.delete_item.show()
self.split_item = gtk.MenuItem('Split on selection')
self.split_item.connect('activate', self.on_split, navigator)
self.append(self.split_item)
self.split_item.show()
# Build transform sub menu
self.trans_menu = gtk.Menu()
@ -419,3 +424,21 @@ class NavigatorMenu(gtk.Menu):
icon = fluents.icon_factory.get(ds)
ds._name = ds._name + ".log"
project.data_tree_insert(self.tree_iter, ds.get_name(), ds, None, "black", icon)
def on_split(self, item, navigator):
if self.dataset is None:
logger.warn("Only datasets can be split.")
return
dim = self.dataset.get_dim_name(0)
project = main.project
sel_ids = set(project.get_selection()[dim])
sel_ds = self.dataset.subdata(dim, sel_ids)
unsel_ids = set(self.dataset.get_identifiers(dim)) - set(sel_ids)
unsel_ds = self.dataset.subdata(dim, unsel_ids)
icon = fluents.icon_factory.get(self.dataset)
project.data_tree_insert(self.tree_iter, 'Selected', sel_ds, None, "black", icon)
project.data_tree_insert(self.tree_iter, 'Unselected', unsel_ds, None, "black", icon)