Repository navigation
Report OpenSCAD callout anchors as pixel positions for diagram callouts - #112
Merged
Merged
Conversation
…ojected pixel positions in the library and 'render --json' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Active moderate and critical findings remain, including inconsistent anchor handling, an unconditional traversal regression, and a help example referencing a nonexistent resource.
3 open issues
What changed in this PR
Adds end-to-end OpenSCAD callout-anchor support, exposing transformed 3D anchor points and projected pixel positions through the Scad API and CLI JSON output.
Changes:
- Adds anchor declaration parsing, validation, transformation tracking, diagnostics, and public reporting.
- Adds camera projection and image-pipeline mapping through crop, resize, fit, padding, flipping, rotation, and deskew operations.
- Adds tests, documentation, examples, requirements, verification records, and architecture metadata.
- Review findings include a broken help-example path, projection and transform-consistency issues, an unnecessary anchor traversal for existing builds, and documentation discrepancies.
| File | Description |
|---|---|
test/DemaConsulting.CanvasNet.Viewer.Tests/CanvasNetViewerSystemIntegrationTests.cs |
Verifies anchored SCAD embedding preserves rendered output. |
test/DemaConsulting.CanvasNet.Tool.Tests/Imaging/SourceLoaderScadTests.cs |
Tests loading anchors and their initial pixel positions. |
test/DemaConsulting.CanvasNet.Tool.Tests/CanvasNetToolTests.cs |
Tests JSON output, diagnostics, pipeline mapping, and text behavior. |
test/DemaConsulting.CanvasNet.Scad.Tests/ScadImageSourceTests.cs |
Verifies anchors do not affect embedded rendering. |
test/DemaConsulting.CanvasNet.Scad.Tests/ScadAnchorTests.cs |
Tests public anchor value semantics and defaults. |
test/DemaConsulting.CanvasNet.Scad.Tests/Geometry/ScadTransformsTests.cs |
Tests shared transform-matrix behavior. |
test/DemaConsulting.CanvasNet.Scad.Tests/Geometry/ScadGeometryTestSupport.cs |
Exposes resolved anchors in geometry test results. |
test/DemaConsulting.CanvasNet.Scad.Tests/Geometry/ScadGeometryBuilderAnchorTests.cs |
Tests anchor transforms, ordering, unsupported contexts, and geometry invariance. |
test/DemaConsulting.CanvasNet.Scad.Tests/Evaluation/ScadEvaluatorTestSupport.cs |
Adds anchor formatting to evaluator test output. |
test/DemaConsulting.CanvasNet.Scad.Tests/Evaluation/ScadEvaluatorAnchorTests.cs |
Tests anchor declaration parsing and validation. |
test/DemaConsulting.CanvasNet.Render3D.Tests/SceneRendering/CameraTests.cs |
Tests camera projection across supported view modes. |
src/DemaConsulting.CanvasNet.Tool/Imaging/SourceModels.cs |
Adds loaded-source and tool-level anchor models. |
src/DemaConsulting.CanvasNet.Tool/Imaging/SourceLoader.Scad.cs |
Collects anchors while rendering SCAD sources. |
src/DemaConsulting.CanvasNet.Tool/Imaging/ImagePipeline.cs |
Makes the pipeline extensible for anchor mapping. |
src/DemaConsulting.CanvasNet.Tool/Imaging/ImagePipeline.Anchors.cs |
Maps anchor pixels through image operations. |
src/DemaConsulting.CanvasNet.Tool/Commands/RenderCommand.cs |
Emits anchor data in JSON results. |
src/DemaConsulting.CanvasNet.Tool/Commands/Help/scad.json |
Documents SCAD anchors and the example command. |
src/DemaConsulting.CanvasNet.Tool/Commands/Help/json.json |
Documents the JSON anchors field. |
src/DemaConsulting.CanvasNet.Tool/Commands/Help/Examples/scad-anchors.scad |
Adds a runnable SCAD anchor example. |
src/DemaConsulting.CanvasNet.Scad/ScadRenderOptions.cs |
Adds the public anchor callback option. |
src/DemaConsulting.CanvasNet.Scad/ScadDocument.Render.cs |
Resolves, projects, and reports anchors during rendering. |
src/DemaConsulting.CanvasNet.Scad/ScadAnchor.cs |
Defines the public anchor record. |
src/DemaConsulting.CanvasNet.Scad/Geometry/ScadTransforms.cs |
Shares transform computation between geometry and anchors. |
src/DemaConsulting.CanvasNet.Scad/Geometry/ScadGeometryContext.cs |
Carries resolved anchor data through scene construction. |
src/DemaConsulting.CanvasNet.Scad/Geometry/ScadGeometryBuilder.Walk.cs |
Keeps anchor instances out of generated geometry. |
src/DemaConsulting.CanvasNet.Scad/Geometry/ScadGeometryBuilder.cs |
Integrates anchor collection into scene building. |
src/DemaConsulting.CanvasNet.Scad/Geometry/ScadGeometryBuilder.Anchors.cs |
Resolves transformed anchor world points. |
src/DemaConsulting.CanvasNet.Scad/Evaluation/ScadInstance.cs |
Adds the anchor instance kind. |
src/DemaConsulting.CanvasNet.Scad/Evaluation/ScadEvaluator.Statements.cs |
Parses and validates anchor declarations. |
src/DemaConsulting.CanvasNet.Scad/Evaluation/ScadEvaluator.Expressions.cs |
Preserves expression-form echo behavior. |
src/DemaConsulting.CanvasNet.Scad/Evaluation/ScadEvaluator.Calls.cs |
Preserves non-statement echo behavior. |
src/DemaConsulting.CanvasNet.Render3D/SceneRendering/Camera.cs |
Adds world-point-to-pixel projection. |
README.md |
Briefly documents the anchor API and CLI feature. |
docs/verification/canvas-net-tool/imaging/source-loader.md |
Documents source-loader anchor verification. |
docs/verification/canvas-net-tool/imaging/image-pipeline.md |
Documents anchor mapping verification. |
docs/verification/canvas-net-tool/commands/render-command.md |
Documents CLI anchor verification. |
docs/verification/canvas-net-tool/commands/help-topics.md |
Covers help-example verification. |
docs/verification/canvas-net-tool.md |
Adds tool-level anchor verification. |
docs/verification/canvas-net-scad/scad-geometry/scad-transforms.md |
Documents transform verification. |
docs/verification/canvas-net-scad/scad-geometry/scad-geometry-builder.md |
Documents geometry-builder anchor verification. |
docs/verification/canvas-net-scad/scad-evaluation/scad-evaluator.md |
Documents evaluator anchor verification. |
docs/verification/canvas-net-scad/scad-document.md |
Documents rendering and callback verification. |
docs/verification/canvas-net-scad.md |
Adds system-level SCAD anchor verification. |
docs/verification/canvas-net-render3d/scene-rendering/camera.md |
Documents camera projection verification. |
docs/user_guide/canvas-net-tool.md |
Documents CLI anchor JSON and pixel mapping. |
docs/user_guide/canvas-net-scad.md |
Documents SCAD anchor declarations and callbacks. |
docs/user_guide/canvas-net-render3d.md |
Documents the camera projection API. |
docs/sysml2/model/canvas-net-tool/imaging/image-pipeline.sysml |
Updates pipeline traceability. |
docs/sysml2/model/canvas-net-tool/commands/render-command.sysml |
Updates render-command traceability. |
docs/sysml2/model/canvas-net-scad/scad-geometry/scad-geometry-builder.sysml |
Updates geometry-builder traceability. |
docs/sysml2/model/canvas-net-scad/scad-evaluation/scad-evaluator.sysml |
Updates evaluator traceability. |
docs/sysml2/model/canvas-net-scad/scad-document.sysml |
Adds anchor API and test artifact references. |
docs/reqstream/canvas-net-tool/imaging/source-loader.yaml |
Adds source-loader anchor requirements. |
docs/reqstream/canvas-net-tool/imaging/image-pipeline.yaml |
Adds pipeline anchor-mapping requirements. |
docs/reqstream/canvas-net-tool/commands/render-command.yaml |
Adds CLI anchor-output requirements. |
docs/reqstream/canvas-net-tool.yaml |
Adds tool-level anchor requirements. |
docs/reqstream/canvas-net-scad/scad-geometry/scad-transforms.yaml |
Adds shared transform requirements. |
docs/reqstream/canvas-net-scad/scad-geometry/scad-geometry-builder.yaml |
Adds geometry-builder anchor requirements. |
docs/reqstream/canvas-net-scad/scad-evaluation/scad-evaluator.yaml |
Adds evaluator anchor requirements. |
docs/reqstream/canvas-net-scad/scad-document.yaml |
Adds public anchor-reporting requirements. |
docs/reqstream/canvas-net-scad.yaml |
Adds system-level SCAD anchor requirements. |
docs/reqstream/canvas-net-render3d/scene-rendering/camera.yaml |
Adds camera projection requirements. |
docs/reqstream/canvas-net-render3d/scene-rendering.yaml |
Includes projection in scene-rendering scope. |
docs/design/canvas-net-tool/imaging/source-loader.md |
Describes loaded-source anchor data. |
docs/design/canvas-net-tool/imaging/image-pipeline.md |
Specifies anchor-coordinate mapping. |
docs/design/canvas-net-tool/imaging.md |
Adds anchor mapping to the imaging design. |
docs/design/canvas-net-tool/commands/render-command.md |
Describes JSON anchors and output behavior. |
docs/design/canvas-net-scad/scad-geometry/scad-transforms.md |
Describes shared transform handling. |
docs/design/canvas-net-scad/scad-geometry/scad-geometry-builder.md |
Describes anchor traversal and world-point resolution. |
docs/design/canvas-net-scad/scad-geometry.md |
Adds anchor behavior to the geometry design. |
docs/design/canvas-net-scad/scad-evaluation/scad-evaluator.md |
Defines anchor declaration semantics. |
docs/design/canvas-net-scad/scad-evaluation.md |
Updates the evaluation data model. |
docs/design/canvas-net-scad/scad-document.md |
Describes the public anchor API and render flow. |
docs/design/canvas-net-scad.md |
Adds anchors to the SCAD system design. |
docs/design/canvas-net-render3d/scene-rendering/camera.md |
Describes Camera.TryProject. |
.reviewmark.yaml |
Registers anchor-related source and test files. |
.cspell.yaml |
Adds deskew to the project dictionary. |
Review effort: Lite
…els without anchors Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Approval should wait until the conflicting singular-transform anchor semantics are resolved and the full cross-package build, test, lint, and integration behavior receive human validation.
No open issues 🎉
3 resolved since last review
Review effort: Lite
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.


Pull Request
Description
Adds callout anchors to OpenSCAD renders. A diagram can now point leader lines at features of a rendered 3D model, whether it is drawn by hand or by an AI agent, and whether it embeds the model through SVG
<image href>(#110) or places the rendered image itself.echo("anchor", "name", [x, y, z]);. This is OpenSCAD-compatible: plain OpenSCAD just prints the line, and CanvasNet still prints it too.translate,rotate,scale,mirrorandmultmatrix, using the same matrices as the geometry, so it lands in world space.scad-anchor-invalid:and is skipped.resize, an extrusion,projectionoroffsetis skipped with a warning, and one under a singular transform is dropped, as the geometry is.Camera.TryProject(point, width, height, out pixel), which uses exactly the rasterizer's view transform, projection and fit margins.ScadAnchor(Name, Point, Pixel?, IsInsideImage, Location)record and theScadRenderOptions.AnchorHandleroption.canvasnet render model.scad -o out.png --jsonadds"anchors": [{ "name", "point": [x,y,z], "pixel": [x,y], "inside" }].--deskewthe pixel is null.scadtopic, thejsonfield and anExamples/scad-anchors.scadexample.Demo: an SVG diagram that embeds
part.scad, with callouts placed from the anchors incanvasnet render part.scad --json:Type of Change
Related Issues
User request: embed 3D OpenSCAD visualizations in 2D diagrams with callouts. This is the follow-up to #110.
Pre-Submission Checklist
Before submitting this pull request, ensure you have completed the following:
Build and Test
pwsh ./build.ps1ran 49,161 tests with 0 failed and 33 skipped (existing symlink and platform skips).Code Quality
Quality Checks
Please run the following checks before submitting:
pwsh ./lint.ps1passed, along with the Pandoc harness andrender-images.ps1 -CheckTesting
TryProjectagainst rendered pixels in orthographic, perspective and auto-fit viewsDocumentation
Additional Notes
inspectresizeand the extrusionsCodefield onScadDiagnostic(today the code is a message prefix)echo("anchor", ...)for something else now gets a warning.