-
Notifications
You must be signed in to change notification settings - Fork 153
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
Support dynamic components #2446
Support dynamic components #2446
Conversation
glue/core/layer_artist.py
Outdated
@@ -228,6 +228,12 @@ def _check_subset_state_changed(self): | |||
self._changed = True | |||
self._state = state | |||
|
|||
def update_component_limits(self, components_changed): |
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.
Can you give a real life example of what this method would do? I wonder if this should be a more general method such as on_component_change
or something similar that could be more versatile?
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.
Sure -- in glue genes we have a SyncComponent which is a component that is added to a dataset when a subset is created and is updated as that subset is updated. For instance, we can calculate gene expression levels in a spatial dataset for a given subset of genes; as we change the subset of genes, we update the values in the SyncComponent on the spatial dataset, but we need to prompt the cmap_lim_helpers so that they display the full range of values in the new component.
Thus, a Viewer can add something like this:
@defer_draw
def update_component_limits(self, components_changed):
for limit_helper in [self.state.cmap_lim_helper]:
if limit_helper.attribute in components_changed:
limit_helper.update_values(force=True)
self.redraw()
And the user experience is nice because changing the subset automatically scales the color to show the range of values.
This could definitely be called something more general; I just had the one example and I thought a more specific name would be more readable in that case.
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.
Perhaps the main 'hook' that gets called could be called with a more general name, and in your case it could then call from there update_component_limits
?
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.
Yeah, sounds good. I've updated to this approach.
@astrofrog -- are we good to merge this now? |
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 sorry for dropping the ball on this - thanks!
Pull Request Template
Description
This is basically behind-the-scenes stuff to enable some functionality in glue-genes whereby some components update their values automatically in response to subset definitions changing and we want viewers to be able to react to these updated values. This should have no impact on existing glue viewers/etc.