Playback & Controllers¶
TrajControllers¶
codemol/traj_controllers.py provides UI controls for trajectory playback:
- Play/pause button
- Frame slider
- Speed control
- Current frame display
- Recording toggle
Playback Commands¶
| Command | Description |
|---|---|
/traj play |
Start forward playback |
/traj stop |
Pause playback |
/traj frame N |
Jump to frame N |
/traj speed X |
Set playback speed (frames/sec) |
Timer-Based Playback¶
Playback uses a QTimer to advance frames at controlled intervals:
self._traj_timer = QTimer()
self._traj_timer.timeout.connect(self._advance_frame)
def _advance_frame(self):
current = cmd.get_frame()
cmd.frame(current + 1)
The timer interval controls playback speed — shorter intervals = faster playback.
Recording¶
The recording feature captures each frame as an image for video export:
/traj record start # Begin recording frames
# ... playback runs ...
/traj record stop # Stop recording
/movie export my_traj # Export as video
Analysis During Playback¶
You can run analysis tools on trajectory frames:
/traj rmsd backbone # RMSD over trajectory for backbone
/traj align backbone # Align all frames to first frame
These tools iterate over all frames and return per-frame values.
Movie System¶
For more complex animations, codemol wraps the built-in movie system: