Skip to content
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 our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Shape selection event #6886

Open
OnionKiller opened this issue May 2, 2024 · 1 comment
Open

add Shape selection event #6886

OnionKiller opened this issue May 2, 2024 · 1 comment
Labels
feature New feature or request

Comments

@OnionKiller
Copy link

馃殌 Feature

selected event for shapes in Shape layer

Motivation

When selecting a shape (Poligon, Line, etc.) it is uesful if there is an event which can capture the fact this happend.

Pitch

I am trying to implement a segmentation visualization where the generated segments are displayed as Polygon shapes in a Layer.
I would like to create a visualization, which displays specific information of a single Polygon, selected by the user.

Alternatives

Mouse click event, especially the doubleclick event can be captured, and by finding if the ursor position is inside a Shape, te event can be possibly deduced, but it is not ideal.

Additional context

The request was mentioned here originally.
I'll try to implement this feature, @brisvag could you please help where to start?

@OnionKiller OnionKiller added the feature New feature or request label May 2, 2024
@brisvag
Copy link
Contributor

brisvag commented May 2, 2024

Hi @OnionKiller, thanks for giving it a go! There are a few ways to go about it.

The "best" way (=harder lift and requires more discussion) would be refactor the Shapes layer to use our Selection object just like Points already do (see

self._selected_data: Selection[int] = Selection()
and all the lines there that refer to self._selected_data). This way you'd contribute to unifying our layers and get "for free" the Shapes.selection.events to connect to.

The quicker way is to instead add an event to here:

self.events.add(
edge_width=Event,
edge_color=Event,
face_color=Event,
properties=Event,
current_edge_color=Event,
current_face_color=Event,
current_properties=Event,
highlight=Event,
features=Event,
feature_defaults=Event,
)

and fire it whenever selected_data is changed. In fact, this makes me notice that you can technically use the highlight event as a stand-in for a selection event, now that I think about it... it won't work when the layer invisible maybe, but that probably won't matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants