mainly overhaul of observers, and removal of project singleton
This commit is contained in:
@@ -163,12 +163,14 @@ class LargeView (gtk.Frame):
|
||||
|
||||
class Plot (gtk.Frame):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self,project):
|
||||
gtk.Frame.__init__(self)
|
||||
self.project = project
|
||||
self.mark_active(False)
|
||||
self.connect('button_press_event', self.on_button_press)
|
||||
self.sel_obj = None
|
||||
project.c_p.attach(self)
|
||||
if project!=None: #its not an Emptyview
|
||||
project.attach(self,'selection_update')
|
||||
|
||||
def on_button_press(self, *rest):
|
||||
logger.log('debug', 'button pressed in plot')
|
||||
@@ -183,12 +185,12 @@ class Plot (gtk.Frame):
|
||||
else:
|
||||
self.set_shadow_type(gtk.SHADOW_OUT)
|
||||
|
||||
def update_selection(self,project):
|
||||
def update(self,project,key):
|
||||
pass
|
||||
|
||||
class EmptyView (Plot):
|
||||
def __init__(self):
|
||||
Plot.__init__(self)
|
||||
Plot.__init__(self,None)
|
||||
|
||||
label = gtk.Label('No view')
|
||||
ebox = gtk.EventBox()
|
||||
@@ -210,10 +212,10 @@ class EmptyView (Plot):
|
||||
self.ebox.hide()
|
||||
Plot.hide(self)
|
||||
|
||||
class SinePlot (Plot):
|
||||
class SinePlot(Plot):
|
||||
|
||||
def __init__(self):
|
||||
Plot.__init__(self)
|
||||
def __init__(self,project):
|
||||
Plot.__init__(self,project)
|
||||
fig = Figure(figsize=(5,4), dpi=72)
|
||||
ax = fig.add_subplot(111)
|
||||
t = arange(0.0,3.0,0.01)
|
||||
@@ -228,15 +230,14 @@ class SinePlot (Plot):
|
||||
self.toolbar.set_property('show-arrow', False)
|
||||
return self.toolbar
|
||||
|
||||
class ScatterPlot (Plot):
|
||||
def __init__(self):
|
||||
Plot.__init__(self)
|
||||
class ScatterPlot(Plot):
|
||||
def __init__(self,project):
|
||||
Plot.__init__(self,project)
|
||||
fig = Figure(figsize=(5,4), dpi=72)
|
||||
self.ax = ax = fig.add_subplot(111)
|
||||
|
||||
# testing testing
|
||||
self.c_p = project.c_p
|
||||
self.x_dataset = self.c_p.datasets[0]
|
||||
self.x_dataset = project.datasets[0]
|
||||
x = self.x_dataset._data
|
||||
self.xaxis_data = xaxis_data = x[:,0] + scipy.randn(scipy.shape(x)[0])
|
||||
self.yaxis_data = yaxis_data = x[:,1]
|
||||
@@ -286,15 +287,16 @@ class ScatterPlot (Plot):
|
||||
logger.log('debug','Selected:\n%s'%index)
|
||||
ids = self.x_dataset.extract_id_from_index('samples',index)
|
||||
#update selection object
|
||||
self.c_p.set_selection(self.current_dim,ids)
|
||||
self.project.set_selection(self.current_dim,ids)
|
||||
logger.log('debug','Selected identifiers:\n%s'%ids)
|
||||
|
||||
def update_selection(self,project):
|
||||
def update(self,project,key):
|
||||
curr_sel = project.get_selection() # get selection object
|
||||
ids = curr_sel[self.current_dim] # current identifiers
|
||||
index = self.x_dataset.extract_index_from_id(self.current_dim,ids) #conversion to index
|
||||
xdata_new = scipy.take(self.xaxis_data,index) #take data
|
||||
ydata_new = scipy.take(self.yaxis_data,index)
|
||||
self.ax.plot(self.xaxis_data,self.yaxis_data,'ob')
|
||||
self.ax.plot(xdata_new,ydata_new,'or')
|
||||
self.canvas.draw()
|
||||
|
||||
|
Reference in New Issue
Block a user