Appearance
CAD Architecture Philosophy
Goal
Daedalus CAD migration follows an incremental architecture split so behavior remains stable while responsibilities move out of D_Daedalus.vue.
Layered Direction
- External format layer
- DXF parser/serializer (
D_dxfIO.ts) handles only low-level DXF tokens/entities.
- DXF parser/serializer (
- Adapter layer
- DXF adapter (
cad-core/adapters/dxf/dxfAdapter.ts) converts between DXF entities and internal CAD entities.
- DXF adapter (
- Internal model layer
- CAD model (
cad-core/model/cadTypes.ts) is the canonical geometry contract.
- CAD model (
- Document state layer
- CAD document store (
stores/cadDocumentStore.ts) holds entities, viewport, active tool, layers, and selection.
- CAD document store (
- Renderer layer
- Renderer adapters (
cad-core/renderers/*) convert CAD model to screen primitives.
- Renderer adapters (
- UI orchestration layer
D_Daedalus.vuecomposes commands, tool flows, and interaction state.
Rules For Incremental Migration
- Keep existing UX and command behavior unchanged during each step.
- First mirror data from UI state to the CAD store (read-only connection).
- Then replace template math with renderer-produced primitives in small areas.
- Keep low-level file format details out of UI components.
- Keep renderer stateless and deterministic from
document + viewportinputs.
Current Practical Contract
- DXF import/export in
D_Daedalus.vuegoes through the DXF adapter, not direct low-level mapping. - ARC is supported end-to-end in DXF low-level and adapter mapping.
- Store integration currently starts from these read-only paths:
- entities
- viewport
- active tool
- Screen-coordinate preview calculations are being moved from template
worldToScreencalls toSvgRendererAdapteroutput. - QuickDraw snap is now in a hybrid phase:
- Existing domain-specific quick candidates remain for compatibility.
- Core
snapEnginecandidates are merged in parallel and ranked together. - Snap tolerance is passed from EditorState-style settings (
tolerancePx) in screen pixels. - In hover/commit resolution, legacy basic object snap branches are selectively suppressed and replaced by core candidates for compatible entities.
- Legacy-only branches remain for symbol/ellipse-specific snapping behavior.
Snap Design Contract
- Snap resolves against generated candidates, not entity types directly.
- Candidate coordinates are always world-space; acceptance is screen-space distance based.
resolveSnapCandidatesis the preferred integration entry for UI layers that need candidate cycling/preview.resolveSnapis a convenience wrapper returning the top-ranked candidate only.
Why This Shape
- Risk reduction: large monolith can be decomposed without a full rewrite.
- Testability: adapters and renderers can be verified independently of UI events.
- Extensibility: 3D renderer abstraction can evolve without touching DXF or command logic.
- Portability: CAD model contracts are framework-agnostic.
Next Steps
- Continue shrinking legacy candidate generation by moving remaining compatible nearest/arc paths to core entities.
- Promote store from mirrored read-only source to authoritative document source.
- Introduce command-side operations over CAD entities directly.
- Add targeted tests for adapter round-trip and snap candidate ranking behavior.
