Commit graph

1,766 commits

Author SHA1 Message Date
Hakan Seven
deec48ad99 perf: keep heavy work off UI thread 2026-07-25 18:49:18 +03:00
Hakan Seven
12bf126646 perf: remove large drawing stalls
Keep resident geometry and GPU resources stable across edits, MSPACE zoom, and Model/Paper switches. Add unified PERF output for tracing remaining costs.
2026-07-25 13:34:48 +03:00
Hakan Seven
2bc4c1c8f3 perf: eliminate initial hover freeze 2026-07-25 10:09:23 +03:00
Hakan Seven
47423eae18 build: pin DBCOLOR round-trip fix 2026-07-25 09:22:35 +03:00
Hakan Seven
39449ec684 perf: speed large drawing workflows 2026-07-25 09:05:52 +03:00
Hakan Seven
97be4fefaa build: update acadrust DWG pipeline 2026-07-25 03:32:31 +03:00
Hakan Seven
71e0b88839 perf: optimize large drawing workflows 2026-07-25 02:58:46 +03:00
Hakan Seven
1c7e4bb850 perf: reuse interaction index after edits
Remap immutable base candidates and cache only changed-wire indexes so block-heavy drawings avoid rebuilding millions of primitives on pointer movement. Build 3D BVHs lazily for plan views.
2026-07-25 01:34:49 +03:00
Hakan Seven
da34c6817a perf: eliminate dense edit stalls
Keep resident wires, draw depths, GPU slabs, and edit history incremental across entity changes. Defer rollover work to avoid cursor jumps on dense drawings.
2026-07-25 01:06:00 +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
90714d34b2 perf: expand spatial interaction indexing
Share subprimitive broad-phase queries across snap, hover, selection, hatch, and mesh paths while preserving exact hit tests.\n\nRefs #433
2026-07-24 22:00:40 +03:00
Hakan Seven
4db763ef27 perf: unify spatial interaction queries
Dense drawings previously rescanned full geometry for snapping, tracking, and selection.\n\nRefs #433
2026-07-24 20:49:05 +03:00
Hakan Seven
ece5598372 fix: correct viewport stretch and SHX plots
Anchor the opposite viewport corner during grip and STRETCH resizing.
Match plotted stroke-font pen widths to the SDF atlas unless CTB overrides.

Closes #435
2026-07-24 19:26:10 +03:00
Hakan Seven
ceddb287f5 fix(renderer): match leader and dash styles
Read canonical ACAD/DSTYLE overrides for leader color and arrow size. Scale block-local linetype patterns through INSERT transforms.

Closes #436
2026-07-24 19:04:57 +03:00
Hakan Seven
7a1c0ead0d fix(xref): preserve layer-zero colors
Treat namespaced XREF layer |0 as layer zero during block inheritance so ByLayer geometry keeps its source color.\n\nCloses #437
2026-07-24 18:43:04 +03:00
Hakan Seven
a0558e187c fix(pick): tighten XREF text hit test
Test SDF glyph quads instead of a style-batch union AABB so empty gaps inside XREF content do not preselect the insert.\n\nCloses #438
2026-07-24 18:35:39 +03:00
Hakan Seven
a413f75548 fix(snap): preserve OTRACK precision
Keep tracking geometry in f64 until screen projection so typed and dynamic distances no longer expose f32 drift.\n\nCloses #439
2026-07-24 17:56:06 +03:00
Hakan Seven
658aa4a4a5 fix(start): complete Start page workflow
Track Save As paths, persist the selected section, and size tabbed
panels from their actual available width.

Refs #443
2026-07-24 17:44:07 +03:00
Hakan Seven
77ea43fb96 fix(dwg): pull AC15 locator fix 2026-07-24 17:44:02 +03:00
Hakan Seven
91326e9a0c fix(renderer): add automatic compat fallback
Use packed wire and texture-backed hatches on low-limit adapters.

Refs #475
2026-07-24 17:05:54 +03:00
Hakan Seven
2ff37b088b fix(camera): re-derive ortho near/far per frame so orbit never clips
The orthographic depth half-range was frozen at fit time and measured along
the fit-time eye direction. A 3-D drawing fitted straight-down (top view) got
a shallow depth span; orbiting only rotated the camera, never resized the
span, so the drawing's width loaded onto the eye axis and overran near/far —
clipping the model the moment it was tilted off top (#473).

Cache the model AABB on the camera and recompute the near/far depth from it
for the live eye direction every frame. This tracks orbit, viewcube snaps,
roll and restored views uniformly, and keeps the same tight, zoom-independent
depth precision (coincident solids / meshes / wires keep their draw order).
Falls back to the scalar half-range / distance-scaled span when no AABB is set.

Closes #473

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 14:57:16 +03:00
Hakan Seven
8c36d3aca8 chore(deps): bump acadrust for down-saved gradient false-positive fix
Solid hatches carrying stale GradientColor1/2ACI EED (no ACAD_XREC_ROUNDTRIP
XRecord) no longer resurrect as a two-colour gradient — red / ACI-253 solids
now render solid instead of blue→yellow.

Closes #471

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 14:45:04 +03:00
Hakan Seven
d59f90992c fix(dxf): tapered R12 polyline widths via acadrust c209306
Heavy 2D POLYLINE vertices with absent width codes now inherit the
polyline default while explicit-zero segments stay zero, so tapered
polylines (e.g. sample_AC1009 handle 0x35B) render variable-width
instead of constant — matching the DWG/LWPOLYLINE form.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 13:52:32 +03:00
Hakan Seven
6ba8bb15bc chore(deps): bump acadrust for R12 paper-space entity placement
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 13:11:50 +03:00
Hakan Seven
106fbbec71 chore(deps): bump acadrust for R12 block-content owner fix
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 12:54:24 +03:00
Hakan Seven
4d898aeead chore(deps): bump acadrust for pre-R2004 MTEXT bg fill recovery
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 12:41:39 +03:00
Hakan Seven
95bc47e084 chore(deps): bump acadrust for MTEXT background fill colour fix
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 11:55:36 +03:00
Hakan Seven
36bc1a911a chore(deps): bump acadrust for pre-R2004 gradient hatch recovery
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 11:45:19 +03:00
Hakan Seven
ce49f4da0a fix(render): DXF leader hookline width + SHAPE name fallback; bump acadrust
Companion to the acadrust DXF-fidelity sweep (bump to 379ce12):
- Legacy LEADER hookline: underline the annotation using the leader's own
  stored text width (DXF code 41) when the MTEXT has no computed extents,
  so the landing spans the text instead of a short stub.
- SHAPE: resolve the glyph by name when the shape number is 0 (DXF SHAPE
  carries only the name), and search shape-file text styles when the entity
  has no direct style reference.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-24 11:30:03 +03:00
Sebastian
b7dc62ffa5 Add handler for document_cache for REPL 2026-07-24 00:30:22 +03:00
Hakan Seven
0e61836e91 fix(properties): name AEC / proxy objects instead of "Unknown"
Selecting a proxy object we render from its cached graphics (an AEC
Wall/Door/Window and the like) showed "Unknown" as its type. The entity
now carries its real DXF class name from the CLASSES section (acadrust
bump), so surface it: ui_name_or_class title-cases the class ("AEC_WALL"
→ "Aec Wall") for the properties Type row and the status-bar label, and
still says "Unknown" only when the class truly can't be named.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 23:59:27 +03:00
Hakan Seven
8fd03e56ff chore: bump acadrust — resolve pre-R2018 MLINESTYLE element linetypes
Multilines read from an R13–R2017 DWG (e.g. an AutoCAD 2013 save) lost
their per-element linetypes and drew every element solid instead of
dashed / with embedded text; R2018 saves were fine. The crate now decodes
the pre-R2018 bit_short linetype index.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 23:45:30 +03:00
Hakan Seven
346f4ce27d fix(wipeout): bias the mask toward the camera so it wins coincident depth
Even collected at the right place, a block-internal wipeout still let
geometry show through: the wipeout pipeline's depth bias was positive,
pushing the mask behind geometry at the same depth (a block's wipeout and
its shapes are coincident at Z=0), so LessEqual rejected it. Bias toward
the camera (constant -8, slope -1) so the mask wins against coincident
2-D geometry, small enough that genuinely nearer geometry still occludes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 23:22:55 +03:00
Hakan Seven
de5c35d44a fix(wipeout): mask block-internal wipeouts once inserted
A wipeout defined inside a block never masked the geometry once the block
was inserted — wipeout_models only scanned top-level entities, so the
wipeout was invisible unless you entered block-edit (where it is
top-level). It also drew a stray mask at its raw block-local coordinates
because the top-level scan lacked the block-defn reject the hatch path
uses.

Descend visible inserts and place each block-internal wipeout in world
space, applying the accumulated insert transform via apply /
apply_rotation. Add the belongs_to_visible_block filter so block-defn
wipeouts only appear through the descent, in world space.

Bumps acadrust for the matching transform_wipeout fix: its u/v basis was
double-scaled (apply_rotation then another scale-factor multiply), so a
scaled insert grew the mask; the descent sidesteps that path but the
explode/copy commands need the crate fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 23:18:48 +03:00
Hakan Seven
d54fb9e2aa fix(render): annotative scale representations + model-space linetype scale
Two rendering defects surfaced on the budweiser benchmark drawings, both
tied to a drawing's annotation scale.

Annotative scale representations. A drawing may materialise each annotation
scale as its own object (here a block insert per scale, on a "0 @ <scale>"
layer, each carrying a per-object AcDbContextData bound to one scale).
Nothing filtered them, so every scale drew at once — a 1× copy stacked
under a 10× one. Add annotative::annotative_offscale and apply it in the
three paths that expand block content: the wire block-defn cache, the
resident/top-level visibility gate (model space only — paper viewports use
their per-viewport frozen scale layers), and the exploded-insert hatch/fill
walk (filtered before normalize strips the handle). An object is shown when
a representation matches the current scale; the off-scale ones are hidden.
When the current scale is unsupported by any representation, fall back to
the base "1:1" copy instead of hiding everything (the object must not
vanish) or showing everything (the copies must not stack).

Model-space linetype scale. PSLTSCALE (a paper-space flag) was applied to
model-space linetypes via the annotation scale, so a drawing saved at e.g.
CANNOSCALE 10:1 drew its linetypes 10× off. Thread a `paper_space` flag
through tessellate_entity and gate the PSLTSCALE factor on it, so it only
scales linetypes for content shown inside a paper-space viewport; model
space keeps LTSCALE × CELTSCALE.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 21:24:56 +03:00
Hakan Seven
5e2b67c642 fix(linetype): keep complex linetypes precise at large coordinates
A circle with a complex linetype (embedded shapes/text, e.g. IZOLACE) drew
its dashes and symbols scattered far off the entity at UTM-scale
coordinates. Two defects compounded, both catastrophic-cancellation at a
~1.2M-unit origin:

- The single-entity complex-linetype path fed apply_along the wire's HIGH
  double-single half only (`base.points`), an absolute f32 quantised to
  ~0.1 at 1.2M. Walking the pattern along those points blew the shape /
  dash positions up to ~1e308. Reconstruct the absolute f64 path from
  high+low, re-origin it at the first vertex, walk apply_along in that
  local frame, then lift each result wire back to world with
  shift_wire_to_world (now pub(crate)) — the same local-frame trick the
  MLINE complex-linetype path already uses. Fixes every entity, not just
  circles.

- The circle was tessellated with truck's circle_arc (arc-through-three-
  points), whose fit cancels catastrophically at 1.2M and returned a ~3%
  radius wobble with uneven segments. Tessellate directly as a cos/sin
  polyline (adaptive segment count from the curve tolerance); adding a
  small ±r term to the centre stays precise, and the Lines path RTE-splits
  it. Arc and polyline bulges share the circle_arc root and remain to fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 17:16:57 +03:00
Hakan Seven
2d3f33de10 fix(leader): suppress oversized arrowheads, keep them precise at UTM
Three defects made a leader's arrowhead render as one stray line far
longer than the leader itself, at UTM coordinates:

- The arrowhead was drawn even when it is larger than the first leader
  segment it sits on. A DIMASZ sized for a bigger plot (here 6 units on a
  ~1-4 unit pointer) painted a stroke longer than the whole leader.
  AutoCAD omits the arrowhead when it does not fit the first segment, so
  gate the arrow on `arrow_size <= first_segment_len`.

- Leader geometry was built as absolute f32. At UTM coordinates (Y ~ 4.5M,
  f32 ulp ~ 0.5) the oblique arrow tick's small cross-slope quantised
  away, collapsing the 45-degree tick into a flat horizontal line. Build
  the path and arrow in absolute f64 — the arrow around a local origin so
  append_arrow's f32 math stays precise — then RTE-split into the double
  single (points_low / fill_tris_low) at the end.

- The `_Oblique` / `_Archtick` arrowhead block mapped to ArrowKind::Tick
  with the full DIMASZ, but the tick emitter draws `size` to either side
  (half-length semantics, matching DIMTSZ). Pass half so an oblique
  arrowhead sizes to DIMASZ like every other arrowhead, not double.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 16:46:55 +03:00
Hakan Seven
ec92a0cdc6 chore(release): v0.8.7
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 15:22:42 +03:00
Hakan Seven
f1a348260f fix(group): preserve groups when pasting, cross-drawing too
PR #446 kept a fully-copied group grouped for the in-drawing COPY/ARRAY
path, but clipboard paste (Ctrl+C / Ctrl+V, PASTECLIP) runs through
finalize_paste, a separate route that never touched groups — so pasted
copies came out ungrouped, and a cross-drawing paste had no group data at
all.

Unify all copy routes on one shared Scene::recreate_groups(sources,
handle_map): copy_complete_groups now gathers the live source groups and
delegates to it, while paste snapshots the complete groups into the
clipboard at copy time (ClipboardDeps.groups) and recreates them over the
pasted handles. A group whose whole membership is copied now stays grouped
whether the copy lands in the same drawing, via the clipboard, or in a
different file; partially-selected groups still stay ungrouped.

Closes #440

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 15:09:06 +03:00
Hakan Seven
6d22671383 Merge PR #446: fix group copies and arc hover-picking
Two fixes from @UserDevtec (Jonathan):
- Copying a complete group now recreates the Group object and dictionary
  entry for the copies (unique NAME_COPYn), so the copy is treated as a
  group too; partial copies stay ungrouped. Undo recording is poisoned
  when groups are copied, since Group objects are non-entity state a
  pure-entity delta cannot restore.
- set_wire_aabb now widens the cull box over the wire's tessellated
  points, not just pick_tris, so bulge arcs that bow outside the stored
  vertex box are no longer rejected before segment hit-testing — arcs
  are hoverable/pickable again.

Builds clean; the AABB change is strictly box-growing so it can only
fix under-sized boxes.

Closes #446

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 14:50:29 +03:00
Jonathan
27cd957e4e
Merge branch 'HakanSeven12:main' into main 2026-07-23 13:14:53 +02:00
Hakan Seven
e4b1f17522 test(font): cover the Shx face variant in resolution test
`case_insensitive_ttf_resolution` matched `Face::resolve` against Ttf and
Lff only; the SHX shape-font variant added later left the match
non-exhaustive, which failed the whole lib-test build. Add the arm.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 14:09:38 +03:00
Hakan Seven
f2ad1cc0c8 feat(thumbnail): on-screen framing + PNG/RLE8 preview, far smaller files
The embedded DWG preview was the whole drawing fit to a canvas, encoded
as a 24-bit uncompressed DIB (~180 KB at 256²) — the bulk of the gap
between an OCS-saved file and AutoCAD's. Three changes:

- Frame it like the screen. `from_scene` now projects every wire vertex
  through the live camera into a viewport-aspect canvas, so the thumbnail
  is the current pan / zoom / rotation and only the visible region, not
  the full extent. Off-screen / clipped segments don't draw (a `None`
  projection or NaN separator breaks the polyline run). Works for any
  view. `stamp_thumbnail` passes the model pane's pixel size and the
  target version.

- PNG for R2013+ (AC1027+). A line drawing on a flat background is almost
  one colour, so PNG collapses to a few KB. PNG previews are only valid
  from R2013, so older targets keep a BMP.

- BMP is now 8-bit palettised, BI_RLE8-compressed (was 24-bit raw). The
  long single-colour runs of a preview compress to a handful of KB; a
  view with >256 colours (rare) falls back to the 24-bit DIB. A full
  256-entry palette is written so the reader's `(1<<bpp)*4` pixel-data
  offset lands correctly.

Net: the preview drops from ~120 KB to ~2-5 KB on every version.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 14:09:38 +03:00
Jonathan
3e48959456 Merge branch 'main' of https://github.com/HakanSeven12/OpenCADStudio 2026-07-23 13:07:55 +02:00
Jonathan
6e92ef9a6f Fix: arc hovering 2026-07-23 13:07:51 +02:00
Jonathan
39ae993b48 Fix: group copies 2026-07-23 13:07:29 +02:00
Hakan Seven
3326c5f0c8 fix(purge): drop orphaned blocks, anonymous blocks, and stale draw-order
PURGE left behind three classes of dead data that AutoCAD removes,
so an OCS-purged drawing stayed far larger than AutoCAD's (a 23 MB test
file purged to 3.5 MB in OCS vs 0.58 MB in AutoCAD):

- Anonymous blocks (`*U`/`*D`/`*T`/dynamic-block variants) were skipped
  wholesale. Leftover unreferenced ones now purge like AutoCAD's, held
  live only when actually referenced.

- Block liveness now comes from REACHABILITY: a block is kept only if it
  is reached from a real layout container by following block references
  (INSERT names, dimension *D, table *T / cell blocks, MultiLeader
  content). The old flat "named by some INSERT" scan could not free a
  mutually-referencing dead subgraph — e.g. the dependent blocks a
  detached xref leaves behind, whose head carried a DANGLING layout
  handle that `is_layout()` mistook for a real layout and shielded. That
  subgraph (here 467k lines) is now purged; live xrefs, reached from the
  layout that inserts them, stay. The used-set also gains the by-handle
  block references (table/MultiLeader/dimstyle-arrow) so purging
  anonymous blocks can't delete an in-use block no INSERT names.

- SortEntitiesTable objects (per-block draw order) were never removed, so
  each purged block's table lingered still listing the handle of every
  deleted entity — 341k stale handles / ~2.7 MB of dead weight the save
  re-emitted. Drop every table whose owning block is gone.

Net on the test file: 3.5 MB -> 0.81 MB (AutoCAD 0.58 MB).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 13:32:26 +03:00
Hakan Seven
1f4bdfa741 fix(save): default Save-As format to the drawing's own version
The Save-As dialog hard-coded the format dropdown to the latest
(DWG/DXF 2018) regardless of what was opened, so a round-trip silently
re-targeted the version. Default it to the loaded document's own version
and DWG-vs-DXF kind instead (from `document.version` + the file
extension), which always matches one of the dropdown options. A new,
unsaved drawing keeps its document default. QSAVE on an existing file
already preserved the version; only Save-As was wrong.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 13:32:26 +03:00
Hakan Seven
0d4bd274b4 style: clear two build warnings
- image_model.rs: drop unnecessary parentheses around a map's array
  literal return.
- text_support.rs: remove dead row_in_column / col_rows computation and
  its unused `li` binding (the only consumer).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 11:39:23 +03:00
Hakan Seven
fc72827428 deps: bump acadrust — don't resurrect disabled gradients on R2004+
Pulls acadrust 022290a: recover_roundtrip_gradients is now gated to
pre-R2004. A native R2018 file whose hatch has its gradient turned off
(is_gradient=0, solid fill) but still carries stale GradientColor1/2ACI
round-trip EED no longer gets a spurious two-colour gradient painted over
it — the arrowhead / "Aluminium shading" hatches render solid as ODA and
libredwg decode them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 11:39:23 +03:00