Commit graph cad-editor/src/app/commands/draw.rs
Author SHA1 Message Date
Hakan Seven
343b6cda7d feat(mline): align creation and editing 2026-08-23 00:30:41 +03:00
ramox81
2263168a2a Complete multiline command and properties behavior 2026-08-22 20:20:34 +03:00
ramox81
ac99942519 Align single and continuous point commands 2026-08-22 17:18:29 +03:00
Hakan Seven
a87ca09fa4 Merge pull request #854 from ramox81/codex/align-arc-behavior 2026-08-21 21:41:24 +03:00
Hakan Seven
bd5f9436ea Merge pull request #852 from ramox81/codex/complete-hatch-workflow 2026-08-21 21:02:14 +03:00
Hakan Seven
4bc02b6b4a fix: correct hatch geometry workflow 2026-08-21 20:52:03 +03:00
ramox81
5f9d8a9e0e Align arc creation and editing behavior 2026-08-21 14:03:58 +03:00
ramox81
f83037271c Complete hatch creation and editing workflow 2026-08-21 12:57:19 +03:00
ramox81
ff09fc7800 Implement associative center mark workflow 2026-08-21 12:05:18 +03:00
ramox81
eba4fb87a8 Complete associative centerline workflow 2026-08-21 11:01:18 +03:00
Hakan Seven
464971969c feat: complete freehand sketch workflow
Co-authored-by: ramox81 <184937705+ramox81@users.noreply.github.com>
2026-08-21 00:17:44 +03:00
Hakan Seven
44efb8fd53 feat(frame): complete frame controls
Preserve frame geometry for selection while separating viewport and plot visibility across supported reference entities.

Refs #642
2026-08-20 23:37:02 +03:00
Hakan Seven
2a852f4479 feat(gradient): align editing and rendering 2026-08-20 21:17:10 +03:00
Hakan Seven
667f20d604 feat(revcloud): complete editing workflow
Keep source planes intact and stored Mline offsets in sync.

Refs #626
2026-08-20 20:33:57 +03:00
ramox81
b7819481f0 Complete wipeout workflow and editing 2026-08-20 17:56:11 +03:00
ramox81
e3bfbf1590 Complete freehand sketch workflow 2026-08-20 16:31:22 +03:00
ramox81
aee3397f5d fix(gradient): align properties and editing 2026-08-20 15:33:09 +03:00
ramox81
4f375da191 feat(revcloud): complete creation and editing workflow 2026-08-20 14:16:43 +03:00
ramox81
4923e4c9da feat(boundary): complete region creation workflow 2026-08-20 13:14:48 +03:00
Hakan Seven
7c818d15e9 fix(geometry): honor polyline OCS in commands
Route editing and derived geometry through kernel world-space curves.\n\nRefs #797\nRefs #798\nRefs #799
2026-08-18 22:09:48 +03:00
Hakan Seven
1d2f0a09c1 feat(hatch): add associative boundaries 2026-08-13 23:47:50 +03:00
Hakan Seven
7a8da58d55 feat(hatch): add multi-region selection
Refs #532
2026-08-13 17:16:29 +03:00
Hakan Seven
0be9c41773 fix(layers): protect locked entities
Keep locked-layer objects selectable for inspection while suppressing grips, property edits, command mutations, and stale editor writes.
2026-08-12 12:46:41 +03:00
gianlucafiore
7d5818d5e0 Add internal-point hatch boundary detection 2026-08-08 09:09:43 -03:00
Hakan Seven
de2707a23e fix(styles): apply active creation defaults
Resolve style properties before editors and previews open.
Use absolute annotation multipliers for style-driven objects.

Refs #401

Refs #431
2026-08-03 16:43:58 +03:00
Hakan Seven
3e6693b93f feat(locale): localize full interface 2026-08-02 22:09:25 +03:00
Hakan Seven
b629dc32de feat(wipeout): add polygon creation modes
Closes #528
2026-07-27 21:50:50 +03:00
Hakan Seven
ea93e169ea perf: make edit history incremental
Replace full-document snapshots with Arc first-touch deltas and batch cache invalidation. Reuse interaction and GPU category caches across unrelated edits.
2026-07-24 23:25:33 +03:00
Hakan Seven
e85e2aeb78 feat(commands): step POLYSOLID (select polyline, then width + height)
Add SelectThenTwoValueCommand (gather a selection, then two values) and use it
for POLYSOLID: bare POLYSOLID gathers the polyline if none is selected, prompts
for wall width then height, and dispatches POLYSOLID <width> <height>.
2026-07-16 14:47:45 +03:00
Hakan Seven
49c10bc806 feat(commands): step the remaining inquiry / solid commands (bucket E)
- ValuePromptCommand: CAL/QUICKCALC/QC (expression), FIND, FINDALL (search).
- SelectThenKeywordCommand (select the solid, then axis + value): SECTION,
  SLICE, 3DMIRROR, 3DROTATE. SLICE's optional TOP/BOTTOM stays typeable.
- TwoValuePromptCommand: PYRAMID (radius + height; sides typeable).

Left as-is by design: UNDO (bare already undoes one step — a correct default,
not a usage line); POLYSOLID (select a polyline then width + height — needs a
two-value-after-selection form) and 3DALIGN (six 3-D points) stay typeable.
2026-07-16 14:43:34 +03:00
Hakan Seven
4fa6c49445 feat(commands): prompt ATTDISP and LAYERSTATE by keyword
Add KeywordCommand, a generic stepped front-end for keyword sub-verb
commands: bare NAME shows the sub-verbs as clickable buttons, and picking
one either dispatches `NAME <verb>` (action verbs like ATTDISP On/Off/Normal)
or prompts for an argument and dispatches `NAME <verb> <value>` (LAYERSTATE
Save/Restore/Delete <name>). It delegates to the existing inline handler, so
the logic stays in one place. First two of bucket B converted; the rest
(VIEW, LINETYPE, SCALELISTEDIT, SETVAR, LAYDEL/LAYMRG, and the selection-first
XDATA/UNDERLAY/ADJUST/DRAWORDER/CHPROP) can follow the same pattern.
2026-07-16 13:19:04 +03:00
Hakan Seven
1490fe4ea9 perf(undo): record entity deltas instead of cloning the whole document
Frequent entity-only edits (MOVE/ROTATE/SCALE/MIRROR/ALIGN, COPY/ARRAY,
draw-add, ERASE) captured a full ~800k-entity CadDocument clone (~46ms) on
every edit — the last big per-edit cost after the incremental-render work.

They now record only the touched entities' before/after images:

- Scene self-records through the five mutation primitives when a recording is
  open (UndoRecording + is_recording_undo guard, zero cost off-path).
- apply_entity_delta installs one side per handle (in-place / re-insert with
  the original handle / remove) plus a per-handle cache reseed, then a single
  bump_entities so the incremental caches patch instead of a full re-tess —
  undo/redo of a small edit is fast too, not just the edit.
- HistorySnapshot is now Full | Delta; a Delta is self-inverting and moves
  between the undo/redo stacks without re-capturing. Commands that touch
  non-entity state (new layer, group, *D block, viewport) fall back to the
  full snapshot via per-command predicates, and a poison flag debug-asserts
  any mis-scope.

remove_entity leaves the handle dangling in its owner block record's
entity_handles (harmless on its own, a lookup miss is skipped), so a
re-insert strips stale entries first — otherwise add_entity would list the
handle twice and the DXF/DWG writer would emit the entity twice.

Round-trip tests cover transform/erase/add/copy (do->undo->redo equality,
handle preservation, no duplication).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-15 11:11:17 +03:00
Hakan Seven
91ba9f7699 feat(alias): centralize command aliases in user-editable ocad.pgp (#286/#288)
Command aliases (L→LINE, CC→COPYCLIP) were scattered across dispatch match
arms and CommandRegistration name arrays. Move them all into a single
user-editable file:

- assets/ocad.pgp: shipped default alias table (ALIAS,*COMMAND format),
  embedded and copied to config/ocad.pgp on first launch; only that user
  copy is read after. AA→AREA default closes #286.
- resolve_alias() rewrites the leading command token at the top of
  dispatch_command_inner, so aliases resolve for every path (families,
  plugins, Repeat menu). Args after the first space are untouched.
- Autocomplete hides alias keys and, when the whole input is an alias,
  surfaces its target command as the top (highlighted) suggestion so the
  highlight matches what Enter runs (AA→AREA, L→LINE).
- ALIASEDIT opens a new editor modal (add/edit/delete rows) with an Apply
  button; Apply persists to ocad.pgp, closing discards unapplied edits.
- Strip alias tokens from all 8 dispatch match-arm files and 71 module
  CommandRegistration arrays, keeping canonical/synonym/distinct-command
  names. ocad.pgp is now the sole source: deleting or remapping an alias
  there takes effect. CUI stays on the keyboard-shortcut panel.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-10 12:39:22 +03:00
Hakan Seven
c4fcfacb18 feat(draw): Arc Continue command; 3-Point default
Arc ribbon default + icon + dropdown order set to 3-Point. New ARC_CONT: tangent-continuing arc from the last line/arc endpoint, pick end only; Ctrl flips direction. Exit anchor recorded on commit (disambiguated by last pick) so chaining continues from the correct end.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 20:39:40 +03:00
Hakan Seven
79a5ac6fed fix(scene): correct MIRROR of TEXT under MIRRTEXT (commit + preview)
Root cause: the glyph tessellator advanced the pen by advance*width_factor
while the transform already scales the pen position by the width factor, so
a backward (negative width factor) run kept its word order and grew on the
same side of the anchor instead of mirroring across it. Advance in unscaled
glyph units to match text_local_bounds; the transform applies the factor once.

On top of that:
- The renderer honours the entity's own text-generation flags (DXF 71: bit 2
  backward / bit 4 upside-down) XOR the text style's flags, and signs the
  horizontal anchor by the width factor so Center/Right backward text mirrors
  about its anchor.
- MIRRTEXT on: a MIRROR toggles both group-71 bits so the reflected rotation
  renders a true glyph mirror (backward-upright for a vertical axis, flipped
  for a horizontal one).
- MIRRTEXT off: the text flips left<->right and lands mirror-symmetric to the
  source (right-reading) instead of hugging the axis.
- The MIRROR preview re-derives text ghosts to match the commit; mirrored()
  now reflects the double-single residual too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 12:42:55 +03:00
Hakan Seven
c653a3f38e feat(commands): add FLATSHOT and CONVTOSURFACE
- FLATSHOT: project the selected solid's edges to 2D Line entities at Z=0
- CONVTOSURFACE: convert the selected solid(s) to Surface entities

Both reuse the cached B-rep's edge wires. COMMANDS.md: 219/262.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 09:16:44 +03:00
Hakan Seven
f513899d49 feat(commands): add REGION (closed boundaries -> region entities)
Convert selected closed polylines and circles into Region entities,
one wire loop each (reuses acadrust Region/Wire). COMMANDS.md: 215/262.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 09:07:30 +03:00
Hakan Seven
c19c18c2f2 feat(commands): expand standard CAD command coverage
Integrate a large batch of standard CAD commands and fix several
name/behaviour mismatches, with no product references in code.

3D solids (reusing the truck B-rep pipeline):
- SLICE, INTERFERE, PRESSPULL, POLYSOLID, PYRAMID, SECTION
- 3DROTATE, 3DMIRROR, 3DALIGN (cached-solid transforms)

Annotation / text:
- ARCTEXT, SPLINEFIT (Catmull-Rom to Bezier), DIMJOGGED, OBJECTSCALE
  (XData markers honoured by the existing geometry-gen / tessellator)

Blocks / misc:
- NCOPY (block-content extraction via explode_entity)
- OPTIONS, SYNCPVIEWPORTS, THICKEN, plus earlier toggles, aliases,
  system variables, and layer/style/view commands

POINTCLOUD/RECAP and UNDERLAYLAYERS/UOSNAP are intentionally left out:
they require a proprietary binary / PDF-layer parser, a GPU point
renderer, and real test files.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 08:23:58 +03:00
Hakan Seven
0ca3954b5d feat(commands): integrate standard CAD commands and fix behavior gaps
Broad pass over the command set: integrate missing commands, wire
previously-unreachable ribbon/menu buttons, and correct name/behaviour
mismatches. Every UI command token now resolves (real handler where the
infrastructure exists, an honest "not yet implemented" status otherwise).

New commands:
- Draw: 3DPOLY, 2D solid (SO/SOLID2D), HELIX, TRACE, SKETCH, DIMCENTER
  (DCE/CENTERMARK)
- Modify/inquiry: REVERSE, MEASUREGEOM (MEA), DBLIST
- Data/manage: BASE, OVERKILL (exact-duplicate removal), AUDIT (read-only
  integrity report), SETVAR (system-variable get/set), SCRIPT (.scr runner),
  FINDNONPURGEABLE

Behaviour fixes:
- LINE and SPLINE gain Close/Undo; AREA computes area/perimeter in f64
  (correct at large coordinates)
- ATTEDIT/ATE unified so the alias and the ribbon button open the
  interactive editor; -ATTEDIT is the command-line form
- Linear/aligned/radius/diameter dimensions gain a text override (Text) and
  text angle (Angle) option
- INSERT gains Scale/Rotate options; COPY gains an Array option
- LINETYPE SET sets the current entity linetype; SETBYLAYER resets overrides
- UNDO accepts a step count

Integrations: standard dimension/block aliases (DLI/DRA/DAN, BMAKE,
EXPORTPDF, DDIM), drafting-aid and screen toggles (GRID/SNAP/POLAR/OSNAP/
DSETTINGS/CLEANSCREEN/QUICKPROPERTIES), viewport tiling
(CASCADE/HORIZONTAL/VERTICAL/VPJOIN), and customization entry points
(CUI/ALIASEDIT).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 19:27:35 +03:00
Hakan Seven
bddc050b3e refactor: split four oversized files into submodule trees
Break up the four giant files (~29k lines total) into focused submodule
directories, one concern per file. Pure mechanical moves — behavior is
unchanged.

- app/update.rs (9650) -> app/update/{mod,viewport,command,style,file,
  dynamic,dialog,util}. The 384-arm update_inner match stays in mod.rs
  with thin delegating arms; the 66 fattest arm bodies move to topic
  methods. Arm set preserved exactly (384 -> 384).
- scene/mod.rs (9017) -> scene/{mod,entity,tess,hittest,layout,paper,
  mspace,project,selection,modify,group_layer,preview}. The impl Scene
  body is split across files via inherent-impl-per-file; struct, ctor,
  fields and load-time helpers stay in the root. fn count 123 -> 123.
- app/commands.rs (6082) -> app/commands/* grouped by command family.
  The 233-arm dispatch match becomes source-ordered per-family
  dispatch_* handlers, preserving first-match precedence (233 -> 233).
- app/view.rs (4686) -> app/view/{mod,overlay,modal,viewcube,controls}.

Largest file drops from 9650 to 3343. Builds clean; app launches and
loads plugins with no panic.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 22:51:29 +03:00