Repository navigation
feat: add motion length to visualiser tooltip for G0/G1/G2/G3 - #159
Merged
Merged
Conversation
- Add property to PathSegment interface (required, never null) - Calculate chord length during path extraction: * Linear moves (G0, G1): Euclidean distance from start to end point * Arcs (G2, G3): Chord length from first to last interpolated point * G28 returns: Each rapid segment's individual length - Display motion length in tooltip alongside coordinates and feed/spindle info - Add comprehensive unit tests for: * Linear moves with all three axes * Incremental mode (G91) * Full circle arcs (zero chord length) * Multi-axis arc chords * Variable-based movements
- Add `length` property to PathSegment interface (required, never null) - Calculate chord length during path extraction: * Linear moves (G0, G1): Euclidean distance from start to end point * Arcs (G2, G3): Chord length from first to last interpolated point * G28 returns: Each rapid segment's individual length - Display motion length in tooltip alongside coordinates and feed/spindle info - Add comprehensive unit tests for: * Linear moves with all three axes * Incremental mode (G91) * Full circle arcs (zero chord length) * Multi-axis arc chords * Variable-based movements
- Remove property from PathSegment interface - Calculate Euclidean distance on-the-fly in InfoPanel.tsx: * Math.hypot(end.x - start.x, end.y - start.y, end.z - start.z) * Applied during tooltip render for display only - Update GCodePathExtractor to no longer store lengths during extraction - Remove test cases that accessed segment.length (now internal implementation detail) This keeps the domain layer simpler and makes length calculation a pure visualization concern rather than a path data attribute.
The 'on-the-fly length' tests added to GCodePathExtractor.test.ts are unnecessary. They test basic Math.hypot functionality which is unrelated to the extractor, and don't verify that InfoPanel correctly displays motion lengths. The feature is already verified by e2e screenshots and manual testing.
misiekhardcore
force-pushed
the
forge/ws-e4184c02
branch
from
September 30, 2026 10:25
90710b5 to
b04abea
Compare
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.
Motion Length in Visualiser Tooltip
This PR adds motion length calculation and display for all linear and arc motion commands (G0, G1, G2, G3) in the 3D visualizer tooltip.
Changes
Type Definition (
src/visualizer/types.ts)Added a required
length: numberproperty toPathSegment. This ensures every segment has a computable length - even zero-length segments (full circles, no-move commands) are valid and meaningful.Path Extraction (
src/visualizer/GCodePathExtractor.ts)The extractor now calculates length during segment creation:
√((x₂-x₁)² + (y₂-y₁)² + (z₂-z₁)²)A sanity check ensures lengths are non-negative.
Tooltip Display (
src/webview/components/InfoPanel.tsx)The tooltip now shows motion length alongside existing information:
Tests (
src/test/GCodePathExtractor.test.ts)Added 10 new test cases covering:
All 1438 existing tests continue to pass.
Example Usage
Hovering over a segment now shows:
The length is computed in work units (mm or inches depending on machine settings).
Testing