Skip to content

Refactor tool state into SimModel and add DataTableNode - #6

Merged
veillette merged 3 commits into
mainfrom
claude/review-architecture-b2LcQ
Feb 18, 2026
Merged

Refactor tool state into SimModel and add DataTableNode#6
veillette merged 3 commits into
mainfrom
claude/review-architecture-b2LcQ

Conversation

@veillette

Copy link
Copy Markdown
Collaborator

Summary

This PR refactors the coordinate system and calibration tool state management by moving their properties into SimModel, making them centralized and easier to access throughout the application. It also introduces a new DataTableNode component that displays digitized position data for tracks, and updates the auto-tracker to record positions to the model.

Key Changes

  • Centralized tool state in SimModel: Moved coordOriginProperty, coordAngleProperty, calibPoint1Property, calibPoint2Property, calibDistanceProperty, and calibUnitProperty from individual tool nodes into SimModel. This eliminates the need for the view to manage and synchronize these properties.

  • Model-view transform as DerivedProperty: Converted modelViewTransformProperty from a manually-updated property to a DerivedProperty that automatically recomputes whenever any of the tool state properties change. The transform builder function was moved from SimScreenView to SimModel.

  • New DataTableNode component: Added DataTableNode that displays a table of digitized positions for all tracks at the current video frame. Shows x/y coordinates in the selected calibration unit, with color-coded track badges. Automatically updates as the video plays or tracks are modified.

  • Tool node refactoring:

    • CoordinateSystemNode and CalibrationToolNode now read/write directly to model properties instead of maintaining their own state
    • Removed reset() methods from tool nodes since model reset handles all state
    • Simplified constructor signatures to accept SimModel instead of individual initial values
  • Auto-tracker integration: Updated AutoTrackerNode to record detected positions to the active track in the model, converting from video-pixel coordinates to model coordinates using the transform.

  • Simplified SimScreenView: Removed manual transform computation and tool state management. The view now focuses on layout and composition rather than state synchronization.

Implementation Details

  • Layout constants (video dimensions, initial tool positions) are now defined in SimModel for consistency
  • Calibration units and distance range are exported from SimModel for use by other components
  • The DataTableNode filters tracks to show only those with digitized points at or before the current frame
  • Mark data in VideoPlayerNode now includes trackId to properly handle track deletion

https://claude.ai/code/session_01BomKebzDTMC2wNohChtjpG

claude and others added 3 commits February 18, 2026 13:43
1. View→Model violation (high): modelViewTransformProperty removed from
   SimModel. It is now a local Property<Transform3> in SimScreenView,
   computed by the existing Multilink, and threaded to VideoPlayerNode
   and AutoTrackerNode as a TReadOnlyProperty constructor parameter.
   The model no longer holds view-derived state.

2. markData[] stale on delete/reset (high): added `trackId` field to the
   MarkData type in VideoPlayerNode. rebuildMarks() now subscribes to
   model.tracksProperty and prunes entries whose track no longer exists,
   so dots are correctly cleared when a track is deleted or reset.

3. Auto-tracker data not persisted (high): AutoTrackerNode now receives
   the model and modelViewTransformProperty. On each tracking frame it
   converts the video-pixel position to model coordinates via
   localToGlobalPoint + inversePosition2 and calls model.addPointToTrack,
   guarded by a per-frame deduplication check so playback does not produce
   duplicate points.

4. Missing DataTableNode (critical): created DataTableNode.ts. The panel
   sits below TrackListPanel, shows the digitized position (x, y in the
   calibration unit) for each track at the current frame, and updates
   reactively on tracksProperty, currentTimeProperty, and unitProperty
   changes. Hides until a video is loaded.

https://claude.ai/code/session_01BomKebzDTMC2wNohChtjpG
The model-view transform is now a true DerivedProperty computed entirely
inside SimModel. No view code writes to the model to produce it.

SimModel changes:
- Add coordOriginProperty (Property<Vector2>) and coordAngleProperty
  (NumberProperty) for the coordinate system tool.
- Add calibPoint1Property, calibPoint2Property (Property<Vector2>),
  calibDistanceProperty (NumberProperty with range), and calibUnitProperty
  (Property<CalibrationUnit>) for the calibration tool.
- Export CalibrationUnit, CALIBRATION_UNITS, and CALIBRATION_DISTANCE_RANGE
  so view files can type the combo-box items without duplication.
- Compute modelViewTransformProperty as a DerivedProperty<Transform3> from
  the five tool-state properties above. buildModelViewTransform() moves here
  from SimScreenView.
- reset() resets all new properties back to their initial values; the
  initial positions are computed from layout constants (1024×618 default
  ScreenView bounds, 640×360 video, matching SimScreenView's positioning).

CoordinateSystemNode changes:
- Constructor drops initialPosition param; accepts model instead.
- Links directly to model.coordOriginProperty and model.coordAngleProperty.
- RichDragListeners read/write model properties directly.
- No longer owns or exposes viewPositionProperty / rotationAngleProperty.
- reset() removed; model.reset() handles state.

CalibrationToolNode changes:
- Constructor drops initialCenter param; accepts model instead.
- All four tool properties replaced by model.calibPoint1/2/DistanceProperty
  and model.calibUnitProperty.
- Imports CalibrationUnit and CALIBRATION_UNITS from SimModel.
- reset() removed; model.reset() handles state.

SimScreenView changes:
- Removes local Property<Transform3>, Multilink, Matrix3, Transform3,
  Vector2 imports, and buildModelViewTransform (moved to SimModel).
- Tool nodes constructed with model; no initial positions passed.
- DataTableNode receives model.calibUnitProperty directly.
- VideoPlayerNode constructed with (model, this) — no MVT param.
- reset() override removed; model.reset() suffices.

VideoPlayerNode + AutoTrackerNode:
- Drop modelViewTransformProperty constructor parameter.
- Both now read model.modelViewTransformProperty directly.

https://claude.ai/code/session_01BomKebzDTMC2wNohChtjpG
@veillette
veillette merged commit b355b22 into main Feb 18, 2026
1 check failed
@veillette
veillette deleted the claude/review-architecture-b2LcQ branch February 19, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants