Skip to content
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