From e6a671a8c0429e95a2d1d4e0b47d173deaefdb05 Mon Sep 17 00:00:00 2001 From: einarr Date: Wed, 6 Feb 2008 19:54:17 +0000 Subject: [PATCH] Added function to split datasets on selection. --- fluents/navigator.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fluents/navigator.py b/fluents/navigator.py index d710b68..e7fb5cc 100644 --- a/fluents/navigator.py +++ b/fluents/navigator.py @@ -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)