Skip to content

Commit

Permalink
3d viewer fix trajectory switching fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiCheng45 committed Oct 28, 2024
1 parent 3e1d53b commit 9745f5c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,11 @@ def set_coordinates(self, frame: int):
# Update the view.
self.update_renderer()

def set_reader(self, reader, frame=0):
def set_reader(self, reader):
"""Set the trajectory at a given frame
Args:
reader (IReader): the trajectory object
frame (int): the selected frame
"""

if (self._reader is not None) and (reader.filename == self._reader.filename):
Expand All @@ -619,8 +618,7 @@ def set_reader(self, reader, frame=0):

self._n_atoms = self._reader.n_atoms
self._n_frames = self._reader.n_frames

self.new_max_frames.emit(self._n_frames - 1)
self._current_frame = min(self._current_frame, self._n_frames - 1)

self._atoms = self._reader.atom_types

Expand Down Expand Up @@ -648,17 +646,17 @@ def set_reader(self, reader, frame=0):
self.reset_all_polydata()
self._polydata.GetPointData().SetScalars(scalars)

self._current_frame = frame
self._colour_manager.onNewValues()
self.new_max_frames.emit(self._n_frames - 1)

@Slot(object)
def take_atom_properties(self, data):
colours, radii, numbers = data
scalars = ndarray_to_vtkarray(colours, radii, numbers)
self._polydata = vtk.vtkPolyData()
self._polydata.GetPointData().SetScalars(scalars)
self.set_coordinates(self._current_frame)

self.update_all_polydata()
self.update_renderer()
# self._datamodel.setReader(reader)

def update_renderer(self):
Expand Down

0 comments on commit 9745f5c

Please sign in to comment.