Skip to content

Implement edit mode menu with periodic table plugin#5

Merged
Roy-Kid merged 8 commits into
devfrom
implement-edit-mode-menu
Jun 11, 2025
Merged

Implement edit mode menu with periodic table plugin#5
Roy-Kid merged 8 commits into
devfrom
implement-edit-mode-menu

Conversation

@Roy-Kid
Copy link
Copy Markdown
Owner

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

Summary

  • add PeriodicTablePlugin under gui folder
  • create EditModeMenu to choose element and bond order
  • integrate menu in EditMode with optional initialization
  • mock tweakpane in tests

Testing

  • npm test --silent --workspace=core

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

@Roy-Kid Roy-Kid merged commit d35dc9b 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 Roy-Kid deleted the implement-edit-mode-menu branch August 22, 2025 19:56
Roy-Kid added a commit that referenced this pull request Oct 27, 2025
* 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
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 #3 (partial) of multi-data-source-pipeline spec.

`MolvisApp.setTrajectory(trajectory)` now wraps the trajectory in a
fresh `TrajectoryDataSource` and installs it at the head of the
pipeline, replacing any prior `DataSourceModifier`. Provenance fields
(`sourceType`, `filename`, `contributedBlocks`) carry forward so
existing call sites (`ensureDataSource` followed by `setTrajectory` in
io loaders / RPC handlers / state_sync) keep their meta-update
semantics intact.

This is the *push* side of the spec's "system.trajectory derives from
pipeline DSs" invariant: every trajectory swap routes through the
pipeline, so the DS is always the data of record. The pull side
(System listens for DS removal and updates derived state) is task #5,
where the addDataSource / removeDataSource lifecycle lands.

Replacement strategy: find existing DS, removeModifier it, add new
TrajectoryDataSource, reorder to position 0 if needed. Disposes the
old trajectory only when the predecessor was a `TrajectoryDataSource`
— `FrameDataSource` placeholders installed by `ensureDataSource`
wrap a transient empty Frame that the molrs FinalizationRegistry
will GC; explicit `free()` here would race with consumers holding
references between events.

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

Two new public methods on MolvisApp:

- `addDataSource(ds)`: appends a DataSourceModifier to the pipeline.
  TrajectoryDataSource frame counts must match every existing
  TrajectoryDataSource (throws with concrete numbers otherwise);
  FrameDataSource is always safe to append (it broadcasts across the
  system's frame count). When the new DS is the first
  TrajectoryDataSource, System adopts its trajectory so navigation
  events keep flowing. applyAutoAttach runs against the DS's frame 0
  to install default Draw modifiers (DrawAtom / DrawBond / DrawBox)
  for new block kinds the source contributes.

- `removeDataSource(id)`: cascade-removes via the existing
  pipeline.removeModifier path, calls dispose() on each removed DS to
  free WASM resources. Removing a TrajectoryDataSource re-derives
  System: if another TrajectoryDataSource remains, System adopts it;
  otherwise System collapses to a single empty frame so navigation
  state stays consistent. Per the spec's 1a "delete = rebuild"
  semantics, applyPipeline runs after.

Both methods route through applyPipeline at the end so the rendered
scene stays in sync. The pipeline's phase A handles the actual block
merge; these methods just manage DS lifecycle around it.

Task #6 wires the io loaders to use addDataSource for
second-and-later file loads (the multi-DS user flow). For now,
existing legacy paths (setTrajectory + ensureDataSource) remain
untouched and keep producing single-DS pipelines.

All 445 core tests pass.
Roy-Kid added a commit that referenced this pull request Apr 29, 2026
…s, append on drop

Phase 3 of multi-data-source-pipeline spec.

Sidebar / pipeline list:
- New "Add Data Source" button next to the "Add modifier" dropdown.
  Opens the format picker (same as drag-drop / per-DS panel) and calls
  loadFileSmart in append mode if the pipeline already has a DS,
  replace otherwise. First-load case routes through replace transparently.
- Each pipeline tree row for a DataSourceModifier now shows
  `<filename> · Trajectory · N frames` or `<filename> · Topology · 1 frame`
  so the user can tell trajectory vs topology DSs at a glance.

Drag-drop:
- MolvisWrapper drag-drop handler checks whether any DataSourceModifier
  is already in the pipeline and switches between replace (empty
  system, first load) and append (additive) automatically.

Per-DS panel (DataSourceModifier.tsx):
- Removed the deprecated showAtoms/showBonds/showBox visibility
  toggles. Their job is now done by the auto-attached DrawAtom /
  DrawBond / DrawBox children's `enabled` checkboxes (phase 2 nests
  them under the DS in the pipeline tree).
- New compact summary card shows kind badge, sourceType label,
  filename, and the contributedBlocks list ("atoms, bonds (default)"
  fallback when not explicitly set).
- New per-DS Remove button calls `app.removeDataSource(modifier.id)`
  via the lifecycle method introduced in phase 1 task #5 (cascade-
  removes child Draws, disposes WASM, re-derives system trajectory).

Plumbing:
- `loadFileSmart` / `loadFileWithFormatPrompt` /
  `loadFileStreamWithFormatPrompt` gain a `mode: "replace" | "append"`
  parameter, default `"replace"`. Threads through to the core io
  loaders' append branch (introduced in phase 1 task #6).

No core test changes — page UI doesn't have a unit-test harness.
Page typecheck clean (the pre-existing `FileSystemSyncAccessHandle`
errors in OPFS streaming code are unrelated). Core 474 tests still 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