Optimized plot selection.
This commit is contained in:
parent
359903c5ab
commit
9d7a5ba769
|
@ -187,7 +187,7 @@ class Plot (gtk.Frame):
|
|||
|
||||
def set_project(self, project):
|
||||
self.project = project
|
||||
|
||||
|
||||
|
||||
class EmptyView (Plot):
|
||||
def __init__(self):
|
||||
|
@ -260,6 +260,8 @@ class ScatterPlot(Plot):
|
|||
x2, y2 = event2.xdata, event2.ydata
|
||||
ydata = self.yaxis_data
|
||||
xdata = self.xaxis_data
|
||||
|
||||
# find indices of selected area
|
||||
if x1>x2:
|
||||
if y1<y2:
|
||||
index =scipy.nonzero((xdata<x1) & (xdata>x2) & (ydata>y1) & (ydata<y2))
|
||||
|
@ -274,7 +276,14 @@ class ScatterPlot(Plot):
|
|||
#logger.log('debug','Selection y_start bigger than y_end')
|
||||
index =scipy.nonzero((xdata>x1) & (xdata<x2) & (ydata<y1) & (ydata>y2))
|
||||
|
||||
ids = [id for id,ind in self.dataset[self.current_dim].items() if ind in index]
|
||||
# generate ids for selected indices
|
||||
reverse = {}
|
||||
for key, value in self.dataset[self.current_dim].items():
|
||||
reverse[value] = key
|
||||
ids = []
|
||||
for ind in index:
|
||||
ids.append(reverse[ind])
|
||||
|
||||
self.project.set_selection(self.current_dim,ids)
|
||||
|
||||
def update(self, key):
|
||||
|
|
Reference in New Issue