GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — beginning base logic for interactivity impl by clewis7 · Pull Request #61 · fastplotlib/fastplotlib

Conversation

@clewis7

@clewis7 clewis7 commented Dec 12, 2022

Copy link
Copy Markdown
Member

starting #39

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Caitlin Lewis added 2 commits December 11, 2022 21:25
Caitlin Lewis
beginning base logic for interactivity impl
2c00596
Caitlin Lewis
further changes and ideas
10aeca8
@kushalkolar

kushalkolar commented Dec 12, 2022

Copy link
Copy Markdown
Member

maybe an even simpler way to implement this:

Interaction.link is just a very simple method that sets the "feature" at the given indices with the new data for any Graphic that is passed, not just self.

def link(
  self,
  event: str, 
  target: Graphic, 
  feature: str, 
  new_data: Any, 
  indices_mapper: callable = None
):
    # event picks subset of self.indices -> indices_mapper() -> indices_subset -> target._set_feature(new_data, indices_subset)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar kushalkolar mentioned this pull request Dec 13, 2022
workshop todo #63
Closed
11 of 14 tasks
Caitlin Lewis
wip
f19c9c1
kushalkolar
kushalkolar requested changes Dec 14, 2022
View reviewed changes
Comment thread fastplotlib/graphics/line.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/line.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/line.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Caitlin Lewis added 3 commits December 14, 2022 21:18
Caitlin Lewis
grrrrr
ac6c67a
Caitlin Lewis
oops
ad6a8d6
Caitlin Lewis
reorg
95e77a1
kushalkolar
kushalkolar requested changes Dec 15, 2022
View reviewed changes
Comment thread fastplotlib/graphics/_base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/line.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Caitlin Lewis
small changes and reorg
71eb48f
kushalkolar
kushalkolar requested changes Dec 15, 2022
View reviewed changes
Comment thread fastplotlib/graphics/_base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/line.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar requested changes Dec 15, 2022
View reviewed changes

@kushalkolar kushalkolar left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

almost there :D

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/line.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/line.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Caitlin Lewis
updates to line, works w previous example
e203cff
@clewis7
clewis7 force-pushed the interaction branch from f1672d6 to e203cff Compare December 17, 2022 17:25
@clewis7

clewis7 commented Dec 17, 2022

Copy link
Copy Markdown
Member Author

Made the changes that you requested, I'm sure there are further changes needed to be made

going to move on to linecollection and try to get that up and running!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar reviewed Dec 18, 2022
View reviewed changes
Comment thread fastplotlib/graphics/_base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/line.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Caitlin Lewis added 2 commits December 18, 2022 13:31
Caitlin Lewis
small changes
0f22531
Caitlin Lewis
git is so agitating sometimes
16922e7
@clewis7
clewis7 force-pushed the interaction branch from f486561 to 16922e7 Compare December 18, 2022 18:36
kushalkolar
kushalkolar reviewed Dec 18, 2022
View reviewed changes
Comment thread fastplotlib/graphics/line.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/linecollection.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Caitlin Lewis
fixing z_position
70a3be6
@clewis7
clewis7 force-pushed the interaction branch from 40a59cd to 70a3be6 Compare December 19, 2022 16:20
clewis7 and others added 7 commits December 19, 2022 11:24
@clewis7
Merge branch 'master' into interaction
a999094
Caitlin Lewis
implementing reset_feature
bc688fc
Caitlin Lewis
blah
24fb5a5
Caitlin Lewis
blah
7667224
@clewis7
Delete event_handler.ipynb
b3767ff
@clewis7
Delete event_linecollection.ipynb
462f098
@clewis7
Delete event_single_contour.ipynb
7099783
Caitlin Lewis added 2 commits December 19, 2022 12:22
Caitlin Lewis
accidentally deleted heatmap file
c523c28
Caitlin Lewis
Merge branch 'interaction' of https://github.com/kushalkolar/fastplotlib
38a3f3a
 into interaction
@clewis7

clewis7 commented Dec 19, 2022

Copy link
Copy Markdown
Member Author

sorry for all of the commits, git was not my friend for a moment but everything should be fine now I hope

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar reviewed Dec 20, 2022
View reviewed changes
Comment thread fastplotlib/graphics/image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Caitlin Lewis
ugly but functional
9309b41
@clewis7

clewis7 commented Dec 20, 2022

Copy link
Copy Markdown
Member Author

So, I got it to work with line collection

things are not perfect by any means but got a nice dopamine rush...hopefully indicative of things moving in the right direction

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar reviewed Dec 21, 2022
View reviewed changes

@kushalkolar kushalkolar left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

great work! you can continue playing with it, once #78 is ready (very soon!) it'll be much easier to do the rest

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/_base.py
if event_type in self.registered_callbacks.keys():
self.registered_callbacks[event_type].append(
CallbackData(target=target, feature=feature, new_data=new_data, old_data=getattr(target, feature).copy()))
CallbackData(target=target, feature=feature, new_data=new_data, old_data=old_data, indices_mapper=indices_mapper))

@kushalkolar kushalkolar Dec 21, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

old_data shouldn't be in CallbackData, old_data should be managed by the target graphic event time it handles an event. When the target graphic handles an event, it should have a copy of the feature data at the indices that are being modified and reset the feature at those indices, and then set the feature w.r.t. to the new CallbackData.

To elaborate:

  1. The target graphic keeps a private dict of (features, orig_vals) that were modified at certain indices from the previous callback, something in the form {"feature": (indices, orig_vals_at_indices)}, you could call it self._previous_modified. And with the new GraphicFeature class from indexable graphic attributes #78 we won't even need a dict for it, we can just add _modified_indices and _orig_vals_at_modified_indices as private attributes to GraphicFeature 😄 .

  2. In _set_feature() it first uses the information from above to reset the feature at those indices to their original values

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kushalkolar kushalkolar Dec 21, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

with #78 it might be possible for us to just pass the GraphicFeature instance directly instead of the string name when calling link, for example:

graphic.link(event_type, target=some_graphic, feature=some_graphic.color...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@clewis7 clewis7 Dec 23, 2022

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If info for resetting feature is moved to _set_feature() graphic, then we will no longer need method for _reset_feature()?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kushalkolar kushalkolar Dec 23, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

we should still have a _reset_feature() to separate functionality

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/_base.py
indices = target_info.indices_mapper(target=target_info.target, indices=click_info)
else:
indices = None
# reset feature of target using stored old data

@kushalkolar kushalkolar Dec 21, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

ah I see you've done it like this, but it's better for the target graphic to handle old data because we want the "feature resetting at previously modified indices" to happen regardless of the event type. For example, if we've registered different types of callbacks to keyboard events, and different mouse events, we want the same reset to happen regardless of what previous event.type triggered the previous feature data to change.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@clewis7 clewis7 Dec 23, 2022

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I agree! Just wasn't sure at the time the best way to implement, but now that graphic features exist it should be a lot easier to store old data!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/linecollection.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/linecollection.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/linecollection.py
update_func = getattr(self, f"update_{feature}")
self.collection[indices].update_func(new_data)
if feature in self.features:
update_func = getattr(self.data[indices], f"update_{feature}")

@kushalkolar kushalkolar Dec 21, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

the way it's written it'll only work with single integer indices, we can chat about it

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kushalkolar kushalkolar Dec 21, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

once we implement this it'll be much easier #76 (comment)

it would become getattr(self, feature)[indices] = new_data

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/linecollection.py
pass
return ["colors", "data"]

def _set_feature(self, feature: str, new_data: Any, indices: Any):

@kushalkolar kushalkolar Dec 21, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think that for the _set_feature method in each Graphic or GraphicCollection we can replace Any for the indices to the indices that are appropriate for that graphic type.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kushalkolar
kushalkolar reviewed Dec 21, 2022
View reviewed changes
Comment thread fastplotlib/graphics/_base.py
for target_info in self.registered_callbacks[event.type]:
# need to map the indices to the target using indices_mapper
if target_info.indices_mapper is not None:
indices = target_info.indices_mapper(target=target_info.target, indices=click_info)

@kushalkolar kushalkolar Dec 21, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

an indices_mapper function should be given source and target, something like this:

indices_mapper(source=self, target=target_info.target, event_indices=click_info

And the user can write their function to take in all 3 and do whatever they want.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@clewis7 clewis7 Dec 23, 2022

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

yes, I assumed that some general form would need to be established

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kushalkolar
LineCollection has @world_object, fix float64 bug in LineGraphic
a6b53ee
This was referenced Dec 21, 2022
handling colors and other modifiable attributes #77
Closed
indexable graphic attributes #78
Merged
@kushalkolar

kushalkolar commented Dec 22, 2022

Copy link
Copy Markdown
Member

Now that #78 brings events to GraphicFeatures we want to make link() work seamlessly for both pygfx events and GraphicFeature events. Something like this should work:

def link(self, event_type: str, target: Any, ...):
  pygfx_events = ["click", ...]
  graphic_feature_events = ["colors", "data", "present", ...]

  if event_type in pygfx_events:
    self.world_object.add_event_handler(...)

  elif event_type in graphic_feature_events:
    feature = getattr(self, event_type)
    feature.add_event_handler(...)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Dec 22, 2022

Copy link
Copy Markdown
Member

should probably also generalize the indices_mapper to just be an event mapper that get access to the source, target, and all event info. For example if we want click events on a contour to toggle the present feature of some other graphic it's diff from indices mapping.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar
Merge branch 'master' into interaction
0cb73ca
@clewis7 clewis7 closed this Dec 24, 2022
@kushalkolar kushalkolar mentioned this pull request Dec 24, 2022
Interactivity #84
Closed
@kushalkolar
kushalkolar deleted the interaction branch January 7, 2023 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kushalkolar kushalkolar kushalkolar requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@clewis7 @kushalkolar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.