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
- Sketch List (or File → Sketch underlay image…) import a PNG/JPEG with a light background and dark lines.
- Confirm White paper → transparent, Tint visible lines, and Opacity behave as expected.
- Adjust Center / Half width / Half height / Rotation, click Apply transform; confirm geometry aligns and Undo restores prior state.
- Settings → Sketch underlay → Highlight color: change color and confirm immediate update on existing underlays and correct default on new import.
- Save
.ezy, restart, reopen: underlay and options restore.
- (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)
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 newSketch_underlaypipeline, GUI, persistence, and global settings integration.Scope (vs
main)stb_image(decode_image_bytesinutl.cpp). Native file dialog + Emscripten file picker (_on_sketch_underlay_selectedinCMakeLists.txt).AIS_TexturedShape(mode 3), slight offset along −plane normal, selection deactivated.ezycad_settings.json(gui.underlay_highlight_color): default for new imports; changing it live-updates all sketches that already have an underlay.underlayobject on each sketch in.ezy(base64 RGBA, geometry, flags, tint, etc.).Occt_view::curr_sketch_shared()for GUI targeting the current sketch.Files touched (high level)
src/sketch_underlay.h,src/sketch_underlay.cppsketch.h/cpp,sketch_json.cpp,occt_view.h/cpp,utl.h/cppgui.h/cpp,gui_settings.cpp,res/ezycad_settings.jsonCMakeLists.txt(exportedon_sketch_underlay_selected)How to verify
.ezy, restart, reopen: underlay and options restore.Possible follow-ups (optional)