-
Notifications
You must be signed in to change notification settings - Fork 48
events refactor #456
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Just to clarify... Under this model we are completely revamping the interactivity abstraction layer to handle all interactivity using the What about for something where you are linking graphic features together? You would still need to pass a callable? For example:
We would be removing the
|
We would completely remove the Rudimentary ideas, the rest is up to you 😄 . Can probably be made more abstract and use arrays instead of lists to make it faster (instead of the for loop in You can play with this idea with some viz, and if it's fully generalizable we can just have it in fpl as a general "CollectiveGraphicsState" object that works for all graphic features. # let's say we have a few graphic collections, this could work with just regular Graphics too
# but you can worry about that later
image_graphic
contours_graphic # LineCollection
temporal_stack # LineStack
GraphicCollectionColorState:
"""stores state of a graphic collection's colors"""
def __init__(self, collection: GraphicCollection):
self._collection = collection
# used to store state of graphic prior to being selected
self._previous_states = [None] * len(self._collection)
def set_selected(self, index: int):
self.reset()
def add_to_selected(self, indices: np.ndarray[int]):
# not sure if this will work but we can make it work
self._previous_states[indices] = self._collection[indices].colors
# "highlight" these graphics
self._collection[indices].colors = "w"
def remove_from_selected(self, indices: np.ndarray[int]):
# reset them back to the original state
self._collection[indices].colors = self._previous_states[indices]
self._previous_states[indices] = None
def reset(self):
for i in range(len(self._previous_states)):
if self._previous_states[i] is not None:
self._collection[i].colors = self._previous_states[i]
self._previous_states[i] = None
contours_state = GraphicCollectionColorState(contours_graphic)
temporal_state = GraphicCollectionColorState(temporal_stack)
# simple
def image_clicked(ev):
# if shift key is held
if "Shift" in ev.modifiers
contours_state.add_to_selected(index_from_euclidean)
temporal_state.add_to_selected(index_from_euclidean)
else:
contours_state.set_selected(index_from_euclidean)
temporal_state.set_selected(index_from_euclidean)
# the repetitive code where the same state is set for contours and temporal could be removed by having
# GraphicCollectionColorState manage a list of GraphicCollection as well instead of just a single one
def temporal_stack_clicked(ev):
if "Shift" in ev.modifiers
contours_state.add_to_selected(index)
temporal_state.add_to_selected(index)
else:
contours_state.set_selected(index)
temporal_state.set_selected(index) A nice thing is this will also ultimately allow create a resizable box to select graphics and set their state (like clicking your mouse and selecting icons in a file manager). |
From today's meeting, superseeds #345, #182, #100. Much of the ideas from those issues either belong in examples or a neuro-widget library @clewis7
observ
and see whether it makes sense to incorporate it within fastplotlib or not. Otherwise we will make a very simple event system in fastplotlib and give users examples of how to use observ or other libs for more complex event handlingInteraction
class fromfastplotlib
and put it into a new neurowidgets that Caitlin will work on.Proposed basic API for adding event handlers suggested by Almar:
The text was updated successfully, but these errors were encountered: