Refactor tool state into SimModel and add DataTableNode - #6
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 newDataTableNodecomponent 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, andcalibUnitPropertyfrom individual tool nodes intoSimModel. This eliminates the need for the view to manage and synchronize these properties.Model-view transform as DerivedProperty: Converted
modelViewTransformPropertyfrom a manually-updated property to aDerivedPropertythat automatically recomputes whenever any of the tool state properties change. The transform builder function was moved fromSimScreenViewtoSimModel.New DataTableNode component: Added
DataTableNodethat 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:
CoordinateSystemNodeandCalibrationToolNodenow read/write directly to model properties instead of maintaining their own statereset()methods from tool nodes since model reset handles all stateSimModelinstead of individual initial valuesAuto-tracker integration: Updated
AutoTrackerNodeto 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
SimModelfor consistencySimModelfor use by other componentsDataTableNodefilters tracks to show only those with digitized points at or before the current frameVideoPlayerNodenow includestrackIdto properly handle track deletionhttps://claude.ai/code/session_01BomKebzDTMC2wNohChtjpG