Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More responsive line inspector #205

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions chaco/tools/line_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -113,16 +114,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
Expand All @@ -138,20 +140,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
Expand Down