def on_button_release(self, event):
if event.button == 1: # left button
if self.cursor_mode == 'Zoom':
# this catches for the first click-release of a double-click
if (time.time() - self.zoom_start_timestamp) > self.max_doubleclick_sec:
# this catches for a long click-and-release without motion
x0,y0 = self.zoom_rect.get_x(),self.zoom_rect.get_y()
x1 = x0 + self.zoom_rect.get_width()
y1 = y0 + self.zoom_rect.get_height()
if hasattr(event, 'xdata') and event.xdata is not None:
x1 = event.xdata
if hasattr(event, 'ydata') and event.ydata is not None:
y1 = event.ydata
if abs(x0 - x1) >= 2 and abs(y0 - y1) >= 2:
self.center = wx.RealPoint((x0 + x1)/2., (y0 + y1)/2.)
panel_size = self.canvas.GetSize()
x_zoom_factor = panel_size.x / abs(x1 - x0)
y_zoom_factor = panel_size.y / abs(y1 - y0)
self.ztv_frame.zoom_factor = min(x_zoom_factor, y_zoom_factor)
self.set_and_get_xy_limits()
if self.zoom_rect in self.axes.patches:
self.axes.patches.remove(self.zoom_rect)
self.zoom_rect = None
self.figure.canvas.draw()
else:
if (self.available_cursor_modes.has_key(self.cursor_mode) and
self.available_cursor_modes[self.cursor_mode].has_key('on_button_release')):
self.available_cursor_modes[self.cursor_mode]['on_button_release'](event)
评论列表
文章目录