Skip to content

Commit 2f91111

Browse files
committed
Fix SelectTool: enable direct shape-to-shape selection (#29)
Users can now click directly between shapes without intermediate deselection step. Preserves multi-selection and manipulation features. Fixes #29
1 parent bd20a56 commit 2f91111

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242

4343
* Fixed plot update after inserting a point using the `EditPointTool` on non-Windows platforms
4444
* [Issue #46](https://github.com/PlotPyStack/PlotPy/issues/46) - Contrast adjustment with 'Eliminate outliers' failed for float images with high dynamic range
45+
* [Issue #29](https://github.com/PlotPyStack/PlotPy/issues/29) - SelectTool: Selecting Another Shape Without Unselection
46+
* Fixed direct selection between different shapes without requiring intermediate click on empty space
47+
* Users can now click directly from one shape to another for immediate selection
48+
* Maintains all existing functionality including multi-selection (Ctrl+click), moving, and resizing
4549
* Fixed `ErrorBarCurveItem` handling of all-NaN data:
4650
* Fixed `ValueError: zero-size array to reduction operation minimum which has no identity` when error bar curves contain only NaN values
4751
* Added proper checks in `boundingRect()` and `draw()` methods to handle empty arrays gracefully

plotpy/events.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,9 +1497,25 @@ def start_tracking(self, filter: StatefulEventFilter, event: QC.QEvent) -> None:
14971497
self.inside = inside
14981498
break
14991499
else:
1500-
self.__unselect_objects(filter)
1501-
filter.set_state(self.start_state, event)
1502-
return
1500+
# Check if user clicked on a different selectable object
1501+
if nearest is not None and nearest.can_select():
1502+
# Direct selection of a different object
1503+
plot.unselect_all()
1504+
plot.select_item(nearest)
1505+
plot.set_active_item(nearest)
1506+
self.active = nearest
1507+
self.handle = nearest_handle
1508+
self.inside = nearest_inside
1509+
# Clear unselection pending since we've switched to a new object
1510+
self.unselection_pending = False
1511+
# No need to process further - we've completed the selection
1512+
plot.replot()
1513+
return
1514+
else:
1515+
# Clicked on empty space - unselect everything
1516+
self.__unselect_objects(filter)
1517+
filter.set_state(self.start_state, event)
1518+
return
15031519
else:
15041520
# No item is selected
15051521
self.active = nearest

0 commit comments

Comments
 (0)