Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Allow moving polygon selectors independently#29027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ericpre wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromericpre:fix_polygon_ignore_event

Conversation

ericpre
Copy link
Member

PR summary

Allow moving polygon selectors independently:

importmatplotlib.pyplotaspltfrommatplotlib.widgetsimportPolygonSelectorfig,ax=plt.subplots()fig.show()selector=PolygonSelector(ax,lambda*args:None)# Add three verticesselector.verts= [(0.1,0.4), (0.5,0.9), (0.3,0.2)]selector2=PolygonSelector(ax,lambda*args:None)# Add three verticesselector2.verts= [(0.5,0.4), (1.0,0.9), (0.8,0.2)]# Press shift and move selector when pointer is on the selector

PR checklist

@ericpreericpre changed the titleMove polygon only when the pointer is on the polygonAllow moving polygon selectors independentlyOct 27, 2024
@ericpreericpre mentioned this pull requestOct 27, 2024
7 tasks
@ericpreericpreforce-pushed thefix_polygon_ignore_event branch from28fac64 to0d10940CompareOctober 27, 2024 18:17
'move_all' in self._state and self._eventpress and
# Allow `move_all` when not completed
# or if the event is contained in the polygon
(not self._selection_completed or self._contains(event))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does this work? If I have an inner an an outer polygon on top of each other, I assume, shift-click dragging somewhere in the inner polygon will still move both polygons?

Also, I have slight concerns thatself._contains can be expensive and_onmove is called often, which may lead to noticable lag during dragging.

Overall, I suspect that the approach should be slightly different, e.g. determine the polygon to manipulate on mouse press - likely you should click a node or edge, and store that information for the subsequent _onmove.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does this work? If I have an inner an an outer polygon on top of each other, I assume, shift-click dragging somewhere in the inner polygon will still move both polygons?

When the pointer is over two overlapping polygons and on both of them, both will move - if the pointer is only over only one of them, then only that one will move. Not the best, but better than the current behaviour, where all selectors will regardless of where the pointer is.

Also, I have slight concerns thatself._contains can be expensive and_onmove is called often, which may lead to noticable lag during dragging.

When I run the example above this is fine, but it may not scale well with the number of selectors... This could be moved tokey_press handler but the potential performance issue may occur when pressing key.

Overall, I suspect that the approach should be slightly different, e.g. determine the polygon to manipulate on mouse press - likely you should click a node or edge, and store that information for the subsequent _onmove.

I don't think that the selector have a "selected" state, and once they are drawn, they are always selected. This may be the best approach in this case. Will it be appetite to use this approach?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not the best, but better than the current behaviour, where all selectors will regardless of where the pointer is.

Agreed. One could do better, but it's an improvement over the current state.

When I run the example above this is fine, but it may not scale well with the number of selectors... This could be moved to key_press handler but the potential performance issue may occur when pressing key.

I'm more concerned on complex selector shapes. The point is thatkey_press is only executed once, but_onmove is a continuously updating function - it should be in the low-10ms regime, whereas, it would be ok in complex scenarios whenkey_press takes some 100ms.
Note: a quick timing of a path with 100 points takes ~ 70µs to contains-check, so this might be fast enough. Though I feel a "selected" state is architecturally cleaner than always checking whether the move event is in the polygon? (e.g. can it happen through glitches/fast movements that mouse and Polygon get out of sync and the mouse slips out of the polygon, which would result in loosing the grip).

I don't think that the selector have a "selected" state, and once they are drawn, they are always selected. This may be the best approach in this case. Will it be appetite to use this approach?

What isthis? A "selected" state - yes I belive this makes sense.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I added the "selected" state to the polygon selector - the handle are visible only when the polygon is selected.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ericpre@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp