Skip to content

Implement trajectory indicator#4

Merged
Roy-Kid merged 4 commits into
devfrom
codex/implement-trajectory-view-with-single-frame-mode
Jun 11, 2025
Merged

Implement trajectory indicator#4
Roy-Kid merged 4 commits into
devfrom
codex/implement-trajectory-view-with-single-frame-mode

Conversation

@Roy-Kid
Copy link
Copy Markdown
Owner

@Roy-Kid Roy-Kid commented Jun 11, 2025

Summary

  • support single frame mode via System flag
  • add Ovito-like frame indicator bar
  • hook ViewMode to update the indicator and switch frames
  • redraw selected frame when timeline changes

Testing

  • npm run test

https://chatgpt.com/codex/tasks/task_e_6849653e8ce08324a430cb3b6ea6f7be

@Roy-Kid Roy-Kid merged commit 83a05ef into dev Jun 11, 2025
Roy-Kid added a commit that referenced this pull request Jun 11, 2025
* [feat] add edite mode

* Add edit mode and tests

* Refine edit mode and rename manager

* Add magnetic bond snapping in edit mode

* Refine view mode menu (#3)

* Implement trajectory indicator (#4)

* Add trajectory view and frame indicator

* Use Tweakpane slider for frame indicator

* Refine frame indicator

* Refine frame indicator layout

* Implement edit mode menu (#5)

* Add edit mode menu with periodic table plugin

* Show menu only when no mesh is picked

* Fix periodic table plugin registration and set menu title

* Fix tweakpane plugin registration

* fix plugin compatibility

* Remove periodic table plugin and use list

* Implement multi-order bonds

* Fix multi-bond offsets and click behavior

* feat: enable select mode (#7)
Roy-Kid added a commit that referenced this pull request Jun 27, 2025
[feat] add edite mode
@Roy-Kid Roy-Kid deleted the codex/implement-trajectory-view-with-single-frame-mode branch August 22, 2025 19:56
Roy-Kid added a commit that referenced this pull request Apr 29, 2026
…FrameDataSource

Phase 1, task #1 of multi-data-source-pipeline spec.

DataSourceModifier becomes an abstract base. Two concrete subclasses:

- TrajectoryDataSource(trajectory): owns a multi-frame Trajectory.
  frameCount = trajectory.length; getFrame(i) = trajectory.frame(i)
  (async). preload(i) caches the i-th frame for sync access during
  pipeline phase A. dispose() forwards to trajectory.dispose().

- FrameDataSource(frame): owns a single Frame. frameCount = 1;
  getFrame(_) returns the same frame regardless of index — this is the
  static-topology broadcast mechanism. preload() is a no-op;
  cachedFrame is always available. dispose() calls frame.free().

Both retain the existing identity apply() semantics (block injection
will move to ModifierPipeline.compute phase A in task #2). Visibility
flags showAtoms/showBonds/showBox are kept on the abstract base
@deprecated for the existing UI panel — will be removed in phase 3
when per-DS Draw modifier toggles take over.

DataSourceModifier no longer registers itself in ModifierRegistry —
DSs enter the pipeline only via file ingress (`io/loadFileContent`,
`io/loadFileStream`) or RPC. Users cannot add a bare DS from the
modifier picker. Existing call sites that constructed `new
DataSourceModifier()` now construct `new FrameDataSource(...)` as a
transitionary placeholder; tasks #4#5 replace those with proper
addDataSource flows.

All 445 core tests pass. Core typecheck clean.
Roy-Kid added a commit that referenced this pull request Apr 29, 2026
Phase 1, task #2 of multi-data-source-pipeline spec.

ModifierPipeline.compute() drops its FrameSource argument and now
runs in two phases:

  Phase A — DS merge: walk every enabled DataSourceModifier in array
  order, await preload(frameIndex) in parallel, then insertBlock each
  DS's contributedBlocks (or the default {atoms, bonds} fallback)
  into a fresh working Frame. Last-wins on block-name and simbox
  conflict. molrs Block::clone is an Arc::clone (refcount bump), so
  this merge is O(num_columns) per DS.

  Phase B — modifier apply: walk every enabled non-DS modifier,
  preserving the existing parent/selection-resolution and
  validation logic. DSs are skipped (their identity apply() is a
  no-op).

The new signature accepts an optional `overrideFrame` that
short-circuits phase A, used as a transitional bridge by
`MolvisApp.applyPipeline({ sourceFrame })` until tasks #3#4 retire
the legacy "pass a frame to the pipeline" path.

Removed:
- `FrameSource` interface (pipeline.ts)
- `ArrayFrameSource` / `SingleFrameSource` / `AsyncFrameSource` /
  `ZarrFrameSource` classes (commands/sources.ts deleted)
- `ZarrReaderLike` type (no consumer left)
- Dead `MolvisApp.computeFrame` method (no callers)
- Re-exports through commands/index.ts and core/src/index.ts

Updated:
- `dag_pipeline.test.ts` switched its inline FrameSource helper to
  the override-bridge form. State-transition tests for phase A live
  in task #7.

All 445 core tests pass. Core typecheck clean.
Roy-Kid added a commit that referenced this pull request Apr 29, 2026
Phase 1, task #6 of multi-data-source-pipeline spec.

`loadFileContent` and `loadFileStream` gain an optional `mode`
parameter (`"replace" | "append"`, default `"replace"` to preserve
existing UX). In append mode they apply the spec's load decision tree:

- Single-frame file (`N_file === 1`) → wrap as `FrameDataSource` and
  broadcast across whatever trajectory length the pipeline already has
  (or stay at 1 if there's no trajectory yet).
- Multi-frame file matching the existing trajectory length (or no
  existing trajectory) → wrap as `TrajectoryDataSource` so phase A
  index-aligns frame-by-frame.
- Frame-count mismatch → throw `Cannot append "<filename>": file has
  N frame(s); existing trajectory has M. File must be single-frame
  (topology) or match existing frame count.`

A new internal helper `appendTrajectoryAsDataSource` runs the decision
tree and adds an atom-count consistency check: if both the existing
system and the new file contribute an `atoms` block, their atom
counts must match (otherwise downstream bonds/selection indices would
dangle). Then forwards to `MolvisApp.addDataSource`, which performs
the redundant frame-count check and runs auto-attach.

Trajectory disposal on error stays correct: append mode disposes the
trajectory if validation throws, so failed loads don't leak WASM.

Replace mode is unchanged — keeps using `ensureDataSource` +
`setTrajectory`, which after task #3+#4 also routes through a
TrajectoryDataSource transparently. Page UI stays single-DS until the
phase-3 "Add Data Source" button passes `mode: "append"`.

All 445 core tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant