Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

No selections in scatter marker now updates to no selection instead of last selection

This commit is contained in:
Arnar Flatberg 2007-02-26 12:11:28 +00:00
parent a6fbef9cfa
commit c0bbe24c39
1 changed files with 27 additions and 24 deletions

View File

@ -677,25 +677,29 @@ class ScatterMarkerPlot(Plot):
self.selection_listener(self.current_dim, ids)
def set_current_selection(self, selection):
index = self.get_index_from_selection(self.dataset_1, selection)
if not len(index)>0:
return
xdata_new = self.xaxis_data.take(index) #take data
ydata_new = self.yaxis_data.take(index)
#remove old selection
if self._selection_line:
self.axes.lines.remove(self._selection_line)
index = self.get_index_from_selection(self.dataset_1, selection)
if len(index)==0:
# no selection
self.canvas.draw()
self._selection_line = None
return
xdata_new = self.xaxis_data.take(index) #take data
ydata_new = self.yaxis_data.take(index)
self._selection_line = Line2D(xdata_new, ydata_new
,marker='o', markersize=self.ms,
linewidth=0, markerfacecolor='r',
markeredgewidth=1.0)
self.axes.add_line(self._selection_line)
if self.use_blit:
if self._background is None:
self._background = self.canvas.copy_from_bbox(self.axes.bbox)
self.canvas.restore_region(self._background)
if self.selection_line:
self.axes.draw_artist(self._selection_line)
self.canvas.blit()
else:
@ -1762,11 +1766,9 @@ class Selector:
return
self.eventrelease = event
self._show_selector(False)
if self.verts is not None:
self.verts.append((event.xdata, event.ydata))
self.line.set_visible(False)
self.polygon.set_visible(False)
self.canvas.blit(self.axes.bbox)
if self.select_type == 'lasso':
if len(self.verts)>2:
self.callback(self.verts, event.key)
@ -1813,11 +1815,7 @@ class Selector:
def _onpress(self, event):
# Is the event to be ignored?
if self._ignore(event): return
if self._background == None:
self._background = self.canvas.copy_from_bbox(self.axes.bbox)
self.polygon.set_visible(True)
self.line.set_visible(True)
self._show_selector(True)
self.eventpress = event
self.verts = [(event.xdata, event.ydata)]
return False
@ -1838,18 +1836,23 @@ class Selector:
if ignore:
# remove poly + line if they are visible
if self.polygon._visible or self.line._visible:
self.polygon.set_visible(False)
self.line.set_visible(False)
self.canvas.restore_region(self._background)
self.canvas.blit()
self._show_selector(False)
else:
if not self.polygon._visible or not self.line._visible:
# put poly + line back if we event is ok
self.polygon.set_visible(True)
self.line.set_visible(True)
self._show_selector(True)
return ignore
def _show_selector(self, bool):
if self.polygon and self.line:
self.polygon.set_visible(bool)
self.line.set_visible(bool)
if self._background == None:
self._background = self.canvas.copy_from_bbox(self.axes.bbox)
self.canvas.restore_region(self._background)
self.canvas.blit()
# Create a view-changed signal that should be emitted every time
# the active view changes.