Skip to content

Commit 215ce2c

Browse files
author
DavidQ
committed
Normalize Object Preview coordinate display without changing visual grid scale - PR_26133_005-object-preview-coordinate-display-normalization
1 parent c2dae5e commit 215ce2c

4 files changed

Lines changed: 45 additions & 17 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PR_26133_004 Playwright V8 Coverage Report
1+
# PR_26133_005 Playwright V8 Coverage Report
22

33
Coverage source: `docs/dev/reports/playwright_v8_coverage_report.txt`, refreshed by the final `npm run test:workspace-v2` run.
44

@@ -7,7 +7,7 @@ Coverage source: `docs/dev/reports/playwright_v8_coverage_report.txt`, refreshed
77
- Coverage is advisory only; no thresholds are enforced.
88
- Workspace Manager V2 entry point: 91%.
99
- Object Vector Studio V2 runtime coverage entries from the generated report:
10-
- `tools/object-vector-studio-v2/js/ToolStarterApp.js`: 91%, executed lines 3304/3304, executed functions 346/381.
10+
- `tools/object-vector-studio-v2/js/ToolStarterApp.js`: 91%, executed lines 3313/3313, executed functions 349/384.
1111
- `tools/object-vector-studio-v2/js/bootstrap.js`: 80%, executed lines 99/99, executed functions 4/5.
1212
- The generated report lists `tools/object-vector-studio-v2/js/ToolStarterApp.js` as a changed JS file with browser V8 coverage.
1313

@@ -16,4 +16,4 @@ Coverage source: `docs/dev/reports/playwright_v8_coverage_report.txt`, refreshed
1616
- Main command: `npm run test:workspace-v2`.
1717
- Result: 46 passed.
1818
- Focused Object Vector Studio V2 layout and preview-coordinate scenarios also passed.
19-
- Manual Object Preview probe confirmed restored 10-unit grid spacing, 10x object drawing scale, zoom/pan/reset behavior, and no console/runtime errors.
19+
- Manual Object Preview probe confirmed logical pointer/origin display, unchanged visual scale, and no console/runtime errors.
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# PR_26133_004 Workspace V2 Results
1+
# PR_26133_005 Workspace V2 Results
22

33
## Command Results
44

55
- `node --check tools/object-vector-studio-v2/js/ToolStarterApp.js`: passed.
66
- `node --check tests/playwright/tools/WorkspaceManagerV2.spec.mjs`: passed.
7-
- `npx playwright test tests/playwright/tools/WorkspaceManagerV2.spec.mjs --grep "Object Vector Studio V2 (layout shell|preview coordinates)"`: 2 passed.
7+
- `npx playwright test tests/playwright/tools/WorkspaceManagerV2.spec.mjs --grep "Object Vector Studio V2 (layout shell|preview coordinates)"`: 2 passed after correcting the pointer-event test probe.
88
- `npm run test:workspace-v2`: 46 passed.
99
- `git diff --check`: passed with the existing LF-to-CRLF working-copy warning for `tests/playwright/tools/WorkspaceManagerV2.spec.mjs`.
1010

1111
## Targeted Object Preview Verification
1212

1313
- Standalone Playwright manual probe reported `consoleErrors: []` and `pageErrors: []`.
14-
- Object Preview grid rendered with 10-unit visible spacing.
15-
- Object Preview shape drawing used 10x preview scale while preserving persisted object coordinates.
16-
- Asteroids ship source points `0,-18`, `14,16`, `0,8`, `-14,16` rendered as `0,-180`, `140,160`, `0,80`, `-140,160`.
17-
- At 25% zoom, the Asteroids ship measured 18 visible grid lines above origin and 16 visible grid lines below origin.
18-
- Object Preview canvas filled available horizontal work-area width and kept the SVG viewBox aspect ratio stable.
19-
- Zoom, pan, and reset view remained functional: panned viewBox `-620 -440 1280 880`, reset viewBox `-160 -110 320 220`.
14+
- Object Preview visuals remained unchanged: grid step `10`, viewBox `-640 -440 1280 880` at 25% zoom, and Asteroids ship drawn points `0,-180`, `140,160`, `0,80`, `-140,160`.
15+
- Pointer display now reports logical coordinates: grid-space `-140,-160` displays as `Pointer -14, -16 | Canvas origin 0,0 centered | Zoom 25%`.
16+
- Canvas origin display now reports logical coordinates: panning right displays `Origin: 2, 0 | Canvas 0,0 centered | Zoom 25%`.
17+
- Reset view displays `Origin: 0, 0 | Canvas 0,0 centered | Zoom 100%`.
18+
- Zoom display remains logical viewport zoom and is not multiplied by `GRID_STEP`.
2019

2120
## Contract Checks
2221

23-
- `const GRID_STEP = 10;` is restored in Object Preview.
24-
- Canvas side-to-side fit and aspect-ratio behavior from the prior PR are preserved.
25-
- No sample JSON files were modified.
22+
- `const GRID_STEP = 10;` remains unchanged.
23+
- Object rendering scale was not changed.
24+
- Grid rendering was not changed.
25+
- Canvas sizing was not changed.
2626
- No unrelated tool/runtime files were changed.
2727
- No fallback behavior was added.

tests/playwright/tools/WorkspaceManagerV2.spec.mjs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,9 +1842,10 @@ test.describe("Workspace Manager V2 bootstrap", () => {
18421842
await expect(page.locator("#objectVectorStudioV2RenderSurface")).toHaveAttribute("viewBox", "-145.455 -100 290.909 200");
18431843
await page.locator("#objectVectorStudioV2PanRightButton").click();
18441844
await expect(page.locator("#objectVectorStudioV2RenderSurface")).toHaveAttribute("viewBox", "-125.455 -100 290.909 200");
1845+
await expect(page.locator("#objectVectorStudioV2CoordinateDisplay")).toHaveText("Origin: 2, 0 | Canvas 0,0 centered | Zoom 110%");
18451846
await page.locator("#objectVectorStudioV2ResetViewButton").click();
18461847
await expect(page.locator("#objectVectorStudioV2RenderSurface")).toHaveAttribute("viewBox", "-160 -110 320 220");
1847-
await expect(page.locator("#objectVectorStudioV2CoordinateDisplay")).toContainText("Origin: 0, 0");
1848+
await expect(page.locator("#objectVectorStudioV2CoordinateDisplay")).toHaveText("Origin: 0, 0 | Canvas 0,0 centered | Zoom 100%");
18481849
await expect(page.locator("#statusLog")).toHaveValue(/OK Viewport reset to 100% at origin 0,0\./);
18491850
await page.locator("#objectVectorStudioV2RenderSurface").hover();
18501851
for (let index = 0; index < 40; index += 1) {
@@ -2206,8 +2207,23 @@ test.describe("Workspace Manager V2 bootstrap", () => {
22062207

22072208
await page.locator("#objectVectorStudioV2PanRightButton").click();
22082209
await expect(page.locator("#objectVectorStudioV2RenderSurface")).toHaveAttribute("viewBox", "-620 -440 1280 880");
2210+
await expect(page.locator("#objectVectorStudioV2CoordinateDisplay")).toHaveText("Origin: 2, 0 | Canvas 0,0 centered | Zoom 25%");
22092211
await page.locator("#objectVectorStudioV2PanLeftButton").click();
22102212
await expect(page.locator("#objectVectorStudioV2RenderSurface")).toHaveAttribute("viewBox", "-640 -440 1280 880");
2213+
await expect(page.locator("#objectVectorStudioV2CoordinateDisplay")).toHaveText("Origin: 0, 0 | Canvas 0,0 centered | Zoom 25%");
2214+
const examplePointerScreen = await page.locator("#objectVectorStudioV2RenderSurface").evaluate((surface) => {
2215+
const point = surface.createSVGPoint();
2216+
point.x = -140;
2217+
point.y = -160;
2218+
const transformed = point.matrixTransform(surface.getScreenCTM());
2219+
return { x: transformed.x, y: transformed.y };
2220+
});
2221+
await page.locator("#objectVectorStudioV2RenderSurface").dispatchEvent("mousemove", {
2222+
bubbles: true,
2223+
clientX: examplePointerScreen.x,
2224+
clientY: examplePointerScreen.y
2225+
});
2226+
await expect(page.locator("#objectVectorStudioV2CoordinateDisplay")).toHaveText("Pointer -14, -16 | Canvas origin 0,0 centered | Zoom 25%");
22112227
await page.setViewportSize({ width: 1040, height: 720 });
22122228
const resizedPreviewScale = await readPreviewScale();
22132229
expect(resizedPreviewScale.aspectRatioStable).toBe(true);

tools/object-vector-studio-v2/js/ToolStarterApp.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,14 +1867,26 @@ export class ToolStarterApp {
18671867
const viewX = this.formatViewportNumber(this.viewport.x - width / 2);
18681868
const viewY = this.formatViewportNumber(this.viewport.y - height / 2);
18691869
this.elements.renderSurface.setAttribute("viewBox", `${viewX} ${viewY} ${this.formatViewportNumber(width)} ${this.formatViewportNumber(height)}`);
1870-
this.elements.coordinateDisplay.textContent = `Origin: ${this.formatViewportNumber(this.viewport.x)}, ${this.formatViewportNumber(this.viewport.y)} | Canvas 0,0 centered | Zoom ${Math.round(this.viewport.zoom * 100)}%`;
1870+
this.elements.coordinateDisplay.textContent = `Origin: ${this.formatLogicalCoordinate(this.viewport.x)}, ${this.formatLogicalCoordinate(this.viewport.y)} | Canvas 0,0 centered | Zoom ${this.formatZoomPercentage()}%`;
18711871
}
18721872

18731873
formatViewportNumber(value) {
18741874
const normalized = Number(Number(value).toFixed(3));
18751875
return Object.is(normalized, -0) ? 0 : normalized;
18761876
}
18771877

1878+
formatLogicalCoordinate(value) {
1879+
return this.formatViewportNumber(value / GRID_STEP);
1880+
}
1881+
1882+
formatLogicalPointerCoordinate(value) {
1883+
return Math.round(this.formatLogicalCoordinate(value));
1884+
}
1885+
1886+
formatZoomPercentage() {
1887+
return Math.round(this.viewport.zoom * 100);
1888+
}
1889+
18781890
zoomViewportByStep(step) {
18791891
const nextZoom = Number((this.viewport.zoom + step).toFixed(3));
18801892
this.zoomViewport(nextZoom);
@@ -1913,7 +1925,7 @@ export class ToolStarterApp {
19131925
const viewHeight = DEFAULT_VIEWPORT.height / this.viewport.zoom;
19141926
const x = this.viewport.x - viewWidth / 2 + ((event.clientX - bounds.left) / bounds.width) * viewWidth;
19151927
const y = this.viewport.y - viewHeight / 2 + ((event.clientY - bounds.top) / bounds.height) * viewHeight;
1916-
this.elements.coordinateDisplay.textContent = `Pointer ${Math.round(x)}, ${Math.round(y)} | Canvas origin 0,0 centered | Zoom ${Math.round(this.viewport.zoom * 100)}%`;
1928+
this.elements.coordinateDisplay.textContent = `Pointer ${this.formatLogicalPointerCoordinate(x)}, ${this.formatLogicalPointerCoordinate(y)} | Canvas origin 0,0 centered | Zoom ${this.formatZoomPercentage()}%`;
19171929
}
19181930

19191931
selectObject(objectId, sourceLabel) {

0 commit comments

Comments
 (0)