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

Changing active molecule from within API #244

Open
joegilkes opened this issue Aug 31, 2022 · 5 comments
Open

Changing active molecule from within API #244

joegilkes opened this issue Aug 31, 2022 · 5 comments

Comments

@joegilkes
Copy link

Hi all,

I'm just having a first play around with chemiscope so apologies if there is a very simple answer I'm missing. I've currently got the library running through Flask and I'm trying to find a way to use the API to change the selected molecule in the EnvironmentInfo, the PropertiesMap and the ViewersGrid simultaneously, such that the server can say "now show structure no. 24" and it can push that to the client.

I've got this working already for the EnvironmentInfo and ViewersGrid by directly firing the DefaultVisualizer.map.onselect() callback with the structure ID I want to change to, but this doesn't update the active point in PropertiesMap. From what I can tell, I want to be using DefaultVisualizer.map.activeChanged() to do this all in one, but that requires a GUID as well as a structure ID.

Is this the correct way to go about this? If so, how do I find the GUID of the point within the Plotly plot to change to? I've been combing through the source code but so far haven't figured out how GUIDs are mapped to their respective points.

Thanks in advance,
Joe

@ceriottm
Copy link
Contributor

Hi Joe, I think @Luthaf is much more likely to be able to help. If you succeed in this, it would be really cool to also expose this functionality for the jupyter widget. There is already the possibility of changing the visualizer settings with a traitlet-style mechanism, I think that being able to set the active point would open up some interesting use cases.

@Luthaf
Copy link
Contributor

Luthaf commented Sep 1, 2022

So activeChanged is used when there are multiple structure viewers, to change the active one (bigger marker on the map). Theoretically, calling DefaultVisualizer.map.onselect() and then DefaultVisualizer.map.select() with the same arguments should work, but looks like it fails to update the marker. I'll try to fix it!

@joegilkes
Copy link
Author

Ahh I see, yeah I've given the select() + onselect() combo a go on my end and it also fails to update the map. Thanks, looking forward to the fix!

@Luthaf
Copy link
Contributor

Luthaf commented Sep 2, 2022

select() should work now! I'll leave this open to add a nicer API to do this kind of things.

@joegilkes
Copy link
Author

Excellent, thank you!

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 a pull request may close this issue.

3 participants