feat(ui): options panel with an IndexedDB-backed lineweight display scale

Set the default lineweight scale to 11 px/mm: the value the user matched
against AutoCAD on the actual screen. The 20 px/mm derived from their
screenshot was too heavy in practice - the capture and the monitor do
not share a DPI - so the constant is now only a starting point.

Move the lineweight controls off the toolbar into an Options panel:
display toggle, scale slider plus number box, a readout of what the
drawing's own weights come out to, grid toggle, zoom speed, and a reset.
Settings persist in IndexedDB (hmw-viewer/options) rather than
localStorage, so values keep their type and the store has room to grow
per-drawing later; every call degrades quietly if storage is blocked.

Scale changes still apply to the live materials - each fat batch now
remembers its weight in mm - so dragging the slider retunes a 37MB
drawing instantly.

Verified headless: 0.35mm renders 3-4px at scale 11 and 8-9px at 25,
matching the readout, and the value survives a reload via IndexedDB.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
minsung
2026-08-05 09:00:37 +09:00
co-authored by Claude Opus 5
parent a924b1ec34
commit 1f80442f6c
8 changed files with 6310 additions and 102 deletions
+5 -5
View File
@@ -25,11 +25,11 @@ const CLICK_THRESHOLD_PX = 14;
// ── Lineweight (AutoCAD LWDISPLAY) ─────────────────────────────────────────
// DWG stores lineweight as an i16 in 1/100 mm (-1 ByLayer, -2 ByBlock,
// -3 Default). AutoCAD shows it in *screen* pixels — the width does not grow
// when you zoom in — at one pixel per 0.05 mm on the default display-scale
// slider (0.50 mm = 10 px, 2.11 mm = 42 px). Measured against an AutoCAD
// capture of the 노면 drawing: its 0.50 mm road edge is ~10 px, so 20 px/mm.
// Host apps can retune this with setLineweightScale().
const LW_PX_PER_MM = 20;
// when you zoom in. The px-per-mm factor is AutoCAD's "Adjust Display Scale"
// slider and depends on the monitor, so it is only a default: 11 px/mm is the
// value that matched an AutoCAD reference side by side (0.35 mm ≈ 4 px,
// 0.50 mm ≈ 5.5 px). Retune per host/monitor with setLineweightScale().
const LW_PX_PER_MM = 11;
// LWDEFAULT: what -3 (and a layer that never set one) resolves to.
const LW_DEFAULT_MM = 0.25;
// At or below the CAD default the line stays in the 1-px hairline batch: a