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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colordata #897

Merged
merged 6 commits into from
Dec 29, 2021
Merged

Colordata #897

merged 6 commits into from
Dec 29, 2021

Conversation

fredludlow
Copy link
Collaborator

This is partly in response to #892, Adds a colorData parameter to representations, that colormakers may make use of, and a new builtin structuredata colormaker will make use of this where colorData is of shape

{ atomData?: { [atomIndex: number]: number}, 
  bondData?: { [bondIndex: number]: number}
}

See the examples color/atom-data and color/bond-data for usage.

I'm open to alternative ways to achieve this. One obvious alternative would be to allow arbitrary (atom-based?) data to be added to Structure objects. The main reason I didn't do this is that I couldn't think of a clean way to connect updates in the extra data to updating coloring of representations without some objects knowing more about others than they ought to. (If Structure sends a signal saying that indicates the data with attribute name "_some_fancy_model_output" has been updated, should a representation trigger a re-color?)

Note that at runtime there's no check that you're passing in colorData of the shape described above, so it could be used to pass any data through to your custom colormaker - if that's preferable as a general method we could update the typing info to support it.

Comments (major changes as well as naming/nitpick etc) very welcome!

…gh to a StructuredataColormaker class. It also provides a mechanism for passing arbitrary data through to a Colormaker instance - see nglviewer#892
@fredludlow fredludlow marked this pull request as ready for review December 15, 2021 09:43
Copy link
Collaborator

@ppillot ppillot left a comment

Choose a reason for hiding this comment

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

These are minor suggestions.

Maybe a major concern would be about the expected format as using an array should be favored to an inlined object.

src/color/structuredata-colormaker.ts Outdated Show resolved Hide resolved
src/color/colormaker.ts Outdated Show resolved Hide resolved
examples/scripts/color/atom-data.js Outdated Show resolved Hide resolved
src/color/structuredata-colormaker.ts Outdated Show resolved Hide resolved
Fix issue with manageColor introduced earlier in this branch (decorating bondColor with manageColor did not pass through the fromTo flag).
Update examples
@fredludlow
Copy link
Collaborator Author

Thank you very much @ppillot for the review! I think all the issues you raised are fixed in 7505d9e, plus a bug I'd overlooked with how bondColor interacts with the manageColor decorator.

@ppillot
Copy link
Collaborator

ppillot commented Dec 21, 2021

I'll have a look when I can. Thanks for the hard work @fredludlow!

Copy link
Collaborator

@ppillot ppillot left a comment

Choose a reason for hiding this comment

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

Thanks! Great additions, and clear examples.
Tested and approved

@ppillot ppillot merged commit b2e0588 into nglviewer:master Dec 29, 2021
@fredludlow fredludlow deleted the colordata branch May 11, 2022 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants