diff --git a/fastplotlib/graphics/_features/_selection_features.py b/fastplotlib/graphics/_features/_selection_features.py index e499e72c9..c385f820f 100644 --- a/fastplotlib/graphics/_features/_selection_features.py +++ b/fastplotlib/graphics/_features/_selection_features.py @@ -48,7 +48,7 @@ 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 """ @@ -56,7 +56,7 @@ def value(self) -> float: 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": diff --git a/fastplotlib/graphics/selectors/_base_selector.py b/fastplotlib/graphics/selectors/_base_selector.py index 3729adda5..30643bbe4 100644 --- a/fastplotlib/graphics/selectors/_base_selector.py +++ b/fastplotlib/graphics/selectors/_base_selector.py @@ -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) diff --git a/fastplotlib/graphics/selectors/_rectangle.py b/fastplotlib/graphics/selectors/_rectangle.py index aae99803e..38bb0d2f9 100644 --- a/fastplotlib/graphics/selectors/_rectangle.py +++ b/fastplotlib/graphics/selectors/_rectangle.py @@ -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