Skip to content

Sketch image underlay for tracing — raster import, white key, line tint, and settings #68

Description

@trailcode

Sketch image underlay for tracing — raster import, white key, line tint, and settings

(Shorter option: Sketch underlay: import PNG/JPEG, align to scale, highlight color in settings)


Summary

This branch adds 2D raster underlays on the sketch plane so users can import reference images (e.g. scans of drawings), align them to model dimensions, and trace geometry in EzyCad. Compared to main, it introduces a new Sketch_underlay pipeline, GUI, persistence, and global settings integration.

Scope (vs main)

Area Change
Import PNG, JPEG, BMP via stb_image (decode_image_bytes in utl.cpp). Native file dialog + Emscripten file picker (_on_sketch_underlay_selected in CMakeLists.txt).
Rendering Textured quad on the sketch plane using OCCT AIS_TexturedShape (mode 3), slight offset along −plane normal, selection deactivated.
Transform Affine mapping from image UV to plane 2D: center, half width/height, rotation; Apply transform + undo snapshots.
White paper → transparent Luminance-based alpha (Rec. 601) so bright backgrounds drop out; dark linework stays visible. Toggle in Sketch List.
Line tint Recolor non-transparent texels (default yellow) for contrast on dark views; per-sketch Line color in Sketch List.
Settings Sketch underlay → Highlight color in ezycad_settings.json (gui.underlay_highlight_color): default for new imports; changing it live-updates all sketches that already have an underlay.
Persistence Optional underlay object on each sketch in .ezy (base64 RGBA, geometry, flags, tint, etc.).
API Occt_view::curr_sketch_shared() for GUI targeting the current sketch.

Files touched (high level)

  • New: src/sketch_underlay.h, src/sketch_underlay.cpp
  • Core: sketch.h/cpp, sketch_json.cpp, occt_view.h/cpp, utl.h/cpp
  • UI / settings: gui.h/cpp, gui_settings.cpp, res/ezycad_settings.json
  • Wasm: CMakeLists.txt (exported on_sketch_underlay_selected)

How to verify

  1. Sketch List (or File → Sketch underlay image…) import a PNG/JPEG with a light background and dark lines.
  2. Confirm White paper → transparent, Tint visible lines, and Opacity behave as expected.
  3. Adjust Center / Half width / Half height / Rotation, click Apply transform; confirm geometry aligns and Undo restores prior state.
  4. Settings → Sketch underlay → Highlight color: change color and confirm immediate update on existing underlays and correct default on new import.
  5. Save .ezy, restart, reopen: underlay and options restore.
  6. (Emscripten) Import underlay via browser file picker.

Possible follow-ups (optional)

  • PDF / vector import path
  • Per-sketch “unlink from settings default” if product wants settings to stop overwriting manual line colors
  • Flip-V / invert options for odd scans
  • Undo granularity for tint-only changes (currently full document snapshot stack)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions