def callback_rect(self, eclick, erelease):
xmin, xmax, ymin, ymax = eclick.xdata, erelease.xdata, eclick.ydata, erelease.ydata
if xmin > xmax:
xmin, xmax = xmax, xmin
if ymin > ymax:
ymin, ymax = ymax, ymin
x, y = self.x_position, self.y_position
in_selection = ((x >= xmin) & (x <= xmax) &
(y >= ymin) & (y <= ymax))
indices = np.nonzero(in_selection)[0]
add_or_remove = None
if erelease.key == 'shift':
add_or_remove = 'add'
elif erelease.key == 'control':
add_or_remove = 'remove'
self.update_inspect(indices, add_or_remove)
评论列表
文章目录