From a3121d7baee80dcd4451b9561ac2fb5081c342fe Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Mon, 7 Jul 2014 16:56:40 -0500 Subject: [PATCH 1/2] Use current pointer position when setting position. --- chaco/tools/line_inspector.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/chaco/tools/line_inspector.py b/chaco/tools/line_inspector.py index e760169b5..3f5918517 100644 --- a/chaco/tools/line_inspector.py +++ b/chaco/tools/line_inspector.py @@ -113,16 +113,17 @@ def normal_mouse_move(self, event): return plot = self.component if plot is not None: - self._last_position = (event.x, event.y) + x, y = event.current_pointer_position() + self._last_position = (x, y) if isinstance(plot, BaseXYPlot): if self.write_metadata: if self.inspect_mode == "space": index_coord, value_coord = \ - self._map_to_data(event.x, event.y) + self._map_to_data(x, y) plot.index.metadata[self.metadata_name] = index_coord plot.value.metadata[self.metadata_name] = value_coord else: - ndx = plot.map_index((event.x, event.y), + ndx = plot.map_index((x, y), threshold=5.0, index_only=True) if ndx: plot.index.metadata[self.metadata_name] = ndx @@ -138,20 +139,20 @@ def normal_mouse_move(self, event): if self.inspect_mode == "space": if plot.orientation == "h": x_coord, y_coord = \ - plot.map_data([(event.x, event.y)])[0] + plot.map_data([(x, y)])[0] else: y_coord, x_coord = \ - plot.map_data([(event.x, event.y)])[0] + plot.map_data([(x, y)])[0] if self.axis == "index_x": metadata = x_coord, old_y_data elif self.axis == "index_y": metadata = old_x_data, y_coord else: if plot.orientation == "h": - x_ndx, y_ndx = plot.map_index((event.x, event.y), + x_ndx, y_ndx = plot.map_index((x, y), threshold=5.0) else: - y_ndx, x_ndx = plot.map_index((event.x, event.y), + y_ndx, x_ndx = plot.map_index((x, y), threshold=5.0) if self.axis == "index_x": metadata = x_ndx, old_y_data From 7bf8fef37b73926e7b0954cc32602057779f677f Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Mon, 7 Jul 2014 17:01:59 -0500 Subject: [PATCH 2/2] Draw at the location of the mouse pointer. --- chaco/tools/line_inspector.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chaco/tools/line_inspector.py b/chaco/tools/line_inspector.py index 3f5918517..ecac31123 100644 --- a/chaco/tools/line_inspector.py +++ b/chaco/tools/line_inspector.py @@ -78,7 +78,8 @@ def draw(self, gc, view_bounds=None): if self.is_listener: tmp = self._get_screen_pts() elif self.is_interactive: - tmp = self._last_position + global_pos = self.window.get_pointer_position() + tmp = self.get_relative_coordinates(*global_pos) if tmp: sx, sy = tmp