From fc2891bad832804f03dcc18ac0e10333f4322939 Mon Sep 17 00:00:00 2001 From: flatberg Date: Wed, 30 Aug 2006 13:21:08 +0000 Subject: [PATCH] removed SinePlot and and added general selection sensitive function thingy --- system/plots.py | 54 +++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/system/plots.py b/system/plots.py index 7ad233d..16dbe4a 100644 --- a/system/plots.py +++ b/system/plots.py @@ -253,7 +253,9 @@ class Plot (gtk.Frame): return self.title def selection_changed(self, selection): - pass + if not self._sel_sensitive or not self.get_property('visible'): + return + self.set_current_selection(selection) def set_selection_listener(self, listener): """Allow project to listen to selections. @@ -267,6 +269,7 @@ class Plot (gtk.Frame): def get_toolbar(self): return None + class EmptyView (Plot): def __init__(self): Plot.__init__(self, 'Empty view') @@ -391,25 +394,6 @@ class PlotToolbar(NavToolbar): self.insert(toolitem, -1) self.show_all() self.message.hide() - -class SinePlot(Plot): - def __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._toolbar = NavToolbar(self.canvas, None) - self._toolbar.set_property('show-arrow', False) - self.add(self.canvas) - self.canvas.show() - - def get_toolbar(self): - return self._toolbar class LineViewPlot(Plot): @@ -461,9 +445,7 @@ class LineViewPlot(Plot): def clear_background(self,event): self._background = None - def selection_changed(self, selection): - if not self._sel_sensitive: - return + def set_current_selection(self, selection): ids = selection[self.current_dim] # current identifiers index = self.dataset.get_indices(self.current_dim, ids) if self.use_blit: @@ -548,9 +530,7 @@ has no color and size options.""" ids = self.dataset_1.get_identifiers(self.current_dim, index) self.selection_listener(self.current_dim, ids) - def selection_changed(self, selection): - if not self._sel_sensitive: - return + def set_current_selection(self, selection): ids = selection[self.current_dim] # current identifiers index = self.dataset_1.get_indices(self.current_dim, ids) xdata_new = scipy.take(self.xaxis_data, index) #take data @@ -568,27 +548,23 @@ has no color and size options.""" def __init__(self, dataset_1, dataset_2, id_dim, sel_dim, id_1, id_2,c='b',s=30, name="Scatter plot"): Plot.__init__(self, name) self.ax = ax = self.fig.add_subplot(111) - #self.ax.set_position([0.01,0.01,.99,.99]) self.current_dim = id_dim self.dataset_1 = dataset_1 - x_index = dataset_1[sel_dim][id_1] y_index = dataset_2[sel_dim][id_2] - self.xaxis_data = dataset_1._array[:,x_index] self.yaxis_data = dataset_2._array[:,y_index] - - ax.scatter(self.xaxis_data,self.yaxis_data,s=s,c=c,faceted=False,edgecolor='k',alpha=.6,cmap = cm.Set1) + lw = scipy.zeros(self.xaxis_data.shape,'f') + ax.scatter(self.xaxis_data,self.yaxis_data,s=s,c=c,linewidth=lw,edgecolor='k',alpha=.6,cmap = cm.Set1) ax.set_title(self.get_title()) - #ax.set_xlabel("%s - %s" % (sel_dim, id_1)) - #ax.set_ylabel("%s - %s" % (sel_dim, id_2)) - # collection self.coll = ax.collections[0] - ### + + # add canvas to widget self.add(self.canvas) self.canvas.show() + # create toolbar self._toolbar = PlotToolbar(self.canvas, None) self._toolbar.chk.connect ('toggled' ,self.set_selection_sensitive) self._toolbar.set_select_callback(self.rectangle_select_callback) @@ -613,14 +589,12 @@ has no color and size options.""" ids = self.dataset_1.get_identifiers(self.current_dim, index) self.selection_listener(self.current_dim, ids) - def selection_changed(self, selection): - if not self._sel_sensitive: - return + def set_current_selection(self, selection): ids = selection[self.current_dim] # current identifiers index = self.dataset_1.get_indices(self.current_dim, ids) lw = scipy.zeros(self.xaxis_data.shape,'f') - zo = lw.copy() + 1 #z-order scipy.put(lw,index,2.) + zo = lw.copy() + 1 #z-order, selected on top self.coll.set_linewidth(lw) self.coll.set_zorder(zo) self._toolbar.forward() #update data lims before draw @@ -711,7 +685,7 @@ class NetworkPlot(Plot): ids = [node_ids[i] for i in index] self.selection_listener(self.dataset.get_dim_name(0), ids) - def selection_changed(self, selection): + def set_current_selection(self, selection): ids = selection[self.dataset.get_dim_name(0)] # current identifiers node_set = set(self.graph.nodes())