Skip to content

Fix move to pointer for selectors again #601

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

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions fastplotlib/graphics/_features/_selection_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ def __init__(self, axis: str, value: float, limits: tuple[float, float]):
self._value = value

@property
def value(self) -> float:
def value(self) -> np.float32:
"""
selection, data x or y value
"""
return self._value

def set_value(self, selector, value: float):
# clip value between limits
value = np.clip(value, self._limits[0], self._limits[1])
value = np.clip(value, self._limits[0], self._limits[1], dtype=np.float32)

# set position
if self._axis == "x":
Expand Down
11 changes: 10 additions & 1 deletion fastplotlib/graphics/selectors/_base_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,16 @@ def _move_to_pointer(self, ev):
elif self.axis == "y":
offset = self.offset[1]

current_pos_world: np.ndarray = self.selection + offset
if self.selection.size > 1:
# linear region selectors
# TODO: get center for rectangle and polygon selectors
center = self.selection.mean(axis=0)

else:
# linear selectors
center = self.selection

current_pos_world: np.ndarray = center + offset

world_pos = self._plot_area.map_screen_to_world(ev)

Expand Down
3 changes: 3 additions & 0 deletions fastplotlib/graphics/selectors/_rectangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,6 @@ def _move_graphic(self, delta: np.ndarray):
self._selection.set_value(self, (xmin, xmax, ymin_new, ymax))
if self._move_info.source == self.edges[3]:
self._selection.set_value(self, (xmin, xmax, ymin, ymax_new))

def _move_to_pointer(self, ev):
pass
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy