-
Notifications
You must be signed in to change notification settings - Fork 7
MolecularViewer refactor and optimisations #1078
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
Conversation
0710a6d to
f4914c5
Compare
c03bc04 to
5e876ba
Compare
MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewerExtended.py
Outdated
Show resolved
Hide resolved
MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewerWithPicking.py
Outdated
Show resolved
Hide resolved
oerc0122
left a comment
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.
Looks good. Couple of stylistic and defensive things.
MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewerExtended.py
Outdated
Show resolved
Hide resolved
MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewerWithPicking.py
Outdated
Show resolved
Hide resolved
MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewerWithPicking.py
Outdated
Show resolved
Hide resolved
I think that "from file" also has a fairly good claim to be the default option. But if you want to make sure that the users see the bonds immediately, then it should be "every frame", because it avoids glitches with bonds stretching across the entire box. Side note: should we extend the labels to say something like "calculate every frame", so the users realise that this will be a slower option, as opposed to "read from file"? If it doesn't fit, you could always change the grid layout to be: |
|
Overall, the performance is greatly improved, as demonstrated in my tests yesterday with 4,000,000 atoms in a trajectory. However, on my computer the performance becomes bad even for small trajectories if I turn on the labels, e.g. atom indices. |
… adjusted bond calc description
|
I've change the bond calc description, increased the unpicked opacity from 0.20 to 0.30, and reverted the text label to use followers again. Not sure why it was so slow on the Mac, the performance of the newer implementation of the atom labels seemed similar to the follower version on windows. Let me know if the opacity change is better or if I needs to be increased further. |
|
Thanks for the changes. The speed is back to normal when using labels. The opacity is better. Even though I find some atoms still hard to see, it can be easily fixed by changing the colour of the background. I noticed one more problem that may need fixing.
At the same time, the animation progress bar is still moving and changing the frame numbers. |
Probably want |
Thanks, this should be fixed now. For the opacity, 0.2 was the value on protos for unpicked. It was set that way because so that it was easier to see picked atoms, if unpicked opacity becomes too large then it can be more difficult to determine what is and isn't picked. Probably need to add some opacity setting, but this will have to be done in another PR I think. |
|
In the molecular viewer, there are a few unused functions that I have chosen to leave in the code. Did you still want these here? Do you have some plans to update the molecule viewer to use them at some point? def change_atom_trace_opacity(self, surface_index: int, opacity: float):
"""This method should allow changing the opacity of an already existing
isosurface. Updates the renderer.
Currently not connected to any widgets.
Parameters
----------
surface_index : int
index of the isosurface in self._surfaces
opacity : float
new opacity value for the isosurface
"""
if surface_index >= len(self.surface_actors):
return
self.surface_actors[surface_index].GetProperty().SetOpacity(opacity)
self.update_renderer()
def change_atom_trace_isocontour_level(self, surface_index: int, level: float):
"""This method should allow changing the isocontour level for an already existing
isosurface. Updates the renderer.
Currently not connected to any widgets.
Parameters
----------
surface_index : int
index of the isosurface in self._surfaces
level : float
new value of isocontour level
"""
if surface_index >= len(self.surface_actors):
return
self.isocontours[surface_index].SetValue(0, level)
self.isocontours[surface_index].Update()
self.update_renderer()
def change_atom_trace_rendering_type(self, surface_index: int, rendering_type: str):
"""Method for changing the rendering style of an existing isosurface.
Updates the renderer.
Currently not connected to any widgets.
Parameters
----------
surface_index : int
index of the isosurface in self._surfaces
rendering_type : str
one of the following: wireframe, surface, points
"""
if surface_index >= len(self.surface_actors):
return
surface = self.surface_actors[surface_index]
if rendering_type == "wireframe":
surface.GetProperty().SetRepresentationToWireframe()
elif rendering_type == "surface":
surface.GetProperty().SetRepresentationToSurface()
elif rendering_type == "points":
surface.GetProperty().SetRepresentationToPoints()
surface.GetProperty().SetPointSize(3)
else:
return
self.update_renderer() |
I think that it is becoming increasingly unlikely that we will use these methods. If they are not used at the moment, you are welcome to remove them. |
MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewerWithPicking.py
Outdated
Show resolved
Hide resolved
oerc0122
left a comment
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.
Looks good, just one instance of == where there should be is then I'm happy.






Description of work
Refactored the molecule viewer code.
Improved bond and atom trace calculation performance.
Changed the bonds setting so that it can be calculated from the first, last, or every frame, or it can be taken from the file; the default is every frame.
Improved performance, larger systems should run faster. I think after this change the performances are probably good enough to be able implement #500 and not have it slow down too much. Here is the before and after on my old Mac with a 61K atom trajectory.
Before

After

To test
All aspects of the 3D viewer including atom selection, and atom tracing plotting. Test the different bond settings. 3D viewer should be much faster, test with a large trajectory.