Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9605d06

Browse filesBrowse files
authored
Fix move to pointer for selectors again (#601)
* LinearSelectionFeature uses np.float32 for selection type * move_to_pointer which works for both linear and linear region selectors * skip move_to_pointer for rectangle selector for now
1 parent 4170de6 commit 9605d06
Copy full SHA for 9605d06

File tree

Expand file treeCollapse file tree

3 files changed

+15
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+15
-3
lines changed

‎fastplotlib/graphics/_features/_selection_features.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/_features/_selection_features.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ def __init__(self, axis: str, value: float, limits: tuple[float, float]):
4848
self._value = value
4949

5050
@property
51-
def value(self) -> float:
51+
def value(self) -> np.float32:
5252
"""
5353
selection, data x or y value
5454
"""
5555
return self._value
5656

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

6161
# set position
6262
if self._axis == "x":

‎fastplotlib/graphics/selectors/_base_selector.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_base_selector.py
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,16 @@ def _move_to_pointer(self, ev):
280280
elif self.axis == "y":
281281
offset = self.offset[1]
282282

283-
current_pos_world: np.ndarray = self.selection + offset
283+
if self.selection.size > 1:
284+
# linear region selectors
285+
# TODO: get center for rectangle and polygon selectors
286+
center = self.selection.mean(axis=0)
287+
288+
else:
289+
# linear selectors
290+
center = self.selection
291+
292+
current_pos_world: np.ndarray = center + offset
284293

285294
world_pos = self._plot_area.map_screen_to_world(ev)
286295

‎fastplotlib/graphics/selectors/_rectangle.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_rectangle.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,3 +515,6 @@ def _move_graphic(self, delta: np.ndarray):
515515
self._selection.set_value(self, (xmin, xmax, ymin_new, ymax))
516516
if self._move_info.source == self.edges[3]:
517517
self._selection.set_value(self, (xmin, xmax, ymin, ymax_new))
518+
519+
def _move_to_pointer(self, ev):
520+
pass

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.