Skip to content

fix(canvas): make line and two-point linestrip selectable by click - #2107

Merged
wkentaro merged 1 commit into
mainfrom
fix/line-linestrip-selectable
May 27, 2026
Merged

wkentaro merged 1 commit into
mainfrom
fix/line-linestrip-selectable

Conversation

@wkentaro

@wkentaro wkentaro commented May 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • line and 2-point linestrip shapes had no interior, so the old _shape.contains_point always returned False and _find_shape_at_point never picked them up — clicking on them did nothing, making it hard to select or delete them.
  • Rename _shape.contains_point_shape.is_hit_by_point (now takes epsilon) and route line / linestrip through nearest_edge_index, so clicks within epsilon of an edge select the shape. Polygon, point, circle, and mask branches are unchanged; points (plural) stays unselectable.

Re-addresses the gap left after #1502 (the point case was already handled there; line and 2-point linestrip still needed work).

Test plan

  • uv run pytest tests/e2e/canvas_interaction_test.py — 25 passed, including new test_select_nonpolygon_shape[line] and [two-point-linestrip] cases
  • uv run ruff check + uv run ruff format --check on changed files
  • uv run ty check labelme/_shape.py labelme/widgets/canvas.py

Rename _shape.contains_point to is_hit_by_point and route line/linestrip
through nearest_edge_index so clicks on (or near) an edge select the
shape. Polygon, point, circle, and mask branches keep their existing
behavior; "points" shapes remain unselectable.
@wkentaro wkentaro self-assigned this May 27, 2026
@wkentaro wkentaro added this to the v6.4.0 milestone May 27, 2026
@wkentaro wkentaro added the fix label May 27, 2026
@wkentaro
wkentaro force-pushed the fix/line-linestrip-selectable branch from e5c49cc to 910bd3a Compare May 27, 2026 12:40
@wkentaro
wkentaro merged commit 6035ac7 into main May 27, 2026
8 checks passed
@wkentaro
wkentaro deleted the fix/line-linestrip-selectable branch May 27, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant