Standalone hatches and hatches from block inserts were rendered
regardless of entity invisible flag, layer off/frozen state, or
whether the owning INSERT belongs to the current layout block.
- Filter self.hatches by invisible, layer, and belongs_to_visible_block
- Skip INSERT entities that are invisible, on a hidden layer, or outside
the current layout block before exploding their contents
- Skip individual hatches produced by explode that are invisible or on
a hidden layer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
paper_canvas_wires() now returns Arc<Vec<WireModel>> backed by
paper_canvas_cache (epoch-keyed). Pan/zoom frames hit the cache and
return a pointer copy; only geometry changes rebuild the wire list.
Completes the paper-canvas caching chain (L+M): sheet cache →
projected-per-viewport cache → full canvas Arc cache.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add two epoch-keyed caches to eliminate per-frame work in paper-space layouts:
paper_sheet_cache — caches wires_for_block(layout_block) as Arc<Vec<WireModel>>.
Previously paper_sheet_wires() re-tessellated all paper-space entities (title
block, annotations, viewport borders) on every mouse-move frame. Now it is an
O(1) Arc clone. entity_wires_arc() reuses the same cache so a geometry-change
frame triggers only one tessellation pass even when both the GPU renderer and
the Iced canvas are active.
paper_projected_cache — caches projected+clipped wires per viewport handle.
viewport_content_wires() now uses model_wires_for_viewport_arc() for the
tessellation step (already O(1) via viewport_wire_cache) and stores the
projection+clip result keyed by (vp_handle, epoch). Navigation frames
(pan/zoom on the paper sheet) are O(N_viewports) Arc/slice copies instead of
O(N_entities × N_points × N_viewports) tessellate+project work.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add `aabb: [f32; 4]` field to WireModel (world-space 2-D bounding box).
In tessellate_entity() set each wire's AABB from e.as_entity().bounding_box()
via new entity_aabb() helper; Insert sub-entities each get their own AABB.
Preview/interim wires and any entity returning a zero-extent default box get
UNBOUNDED_AABB so they are never pre-rejected.
Replace the chord-sphere heuristic in Snapper::wire_in_range() with a proper
AABB vs snap-circle overlap test. The new check is four scalar comparisons and
correctly handles closed curves (circles, arcs) which the chord-sphere approach
had to special-case.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Option I: add per-viewport Arc wire cache so paper-space viewport rendering
no longer re-tessellates model content every frame.
Option J: hit_test_wires() returns Arc<Vec<WireModel>> — O(1) pointer copy
in model space instead of a full Vec clone on every mouse move during commands.
paper_canvas_hatches/wipeouts() now route through the epoch caches added in F.
Option K: add world_snap_r + wire_in_range() pre-check to Snapper::snap().
All Endpoint/Midpoint/Nearest/Perpendicular/Intersection loops skip wires
whose chord sphere is outside the snap circle using O(1) scalar comparisons,
eliminating O(entities × vertices) matrix multiply cost when zoomed in.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add Arc<Vec<...>>-backed epoch caches for hatches, wipeouts, images, and
meshes — the same pattern used for wires. build_primitive() now returns
an O(1) Arc refcount bump on navigation frames instead of rebuilding
every collection from scratch.
Also wrap ImageModel.pixels in Arc<Vec<u8>> so cloning an ImageModel is
O(1) regardless of image resolution.
Navigation frames no longer copy pixel data, tessellated hatch boundaries,
or mesh geometry — all per-frame CPU work on unchanged geometry is now
eliminated.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract tessellate_one body into a Send-compatible free function
tessellate_entity, then drive it with rayon::into_par_iter() in
wires_for_block(). Spreads file-open and post-edit tessellation across
all CPU cores. Navigation frames are unaffected (Options A/B cache
eliminates per-frame tessellation entirely).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the O(objects) linear scan inside wires_for_block() with a
sort_cache keyed by geometry_epoch. On a cache miss the index is built
once by scanning all document objects; subsequent calls within the same
epoch do an O(1) HashMap lookup (block_handle → entity→sort map).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add two complementary render caches that make mouse navigation essentially
free regardless of file size:
Option A – Wire tessellation cache: entity_wires_arc() caches the
tessellated Vec<WireModel> keyed by geometry_epoch and returns an Arc,
so navigation frames (no preview wires) incur zero Vec clones and zero
tessellation work. Primitive::wires changed to Arc<Vec<WireModel>>.
Option B – GPU buffer cache: Pipeline stores cached_epoch; prepare()
skips all upload_wires/hatches/images/meshes calls when the epoch is
unchanged, writing only the 192-byte camera uniform instead.
geometry_epoch is a process-wide AtomicU64 incremented by every Scene
mutation (add/erase entity, selection, layer visibility, layout switch,
populate_*, grip, transform, copy, clear, preview wires). Using a global
counter rather than a per-scene counter prevents two tabs that happen to
have the same local bump count from sharing a cached_epoch value, which
was causing the first file's geometry to remain on screen after opening a
second file.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Empty LwPolyline and single-control-point Spline fallbacks were calling
builder::line(&v, &v) with the same Rc vertex, triggering the
truck-topology panic "Two same vertices cannot construct an edge."
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
White paper fill was calculated from entity bounding boxes (paper_entity_extents),
so adding a viewport caused the paper to visually shrink to the viewport's bounds.
Now paper_limits() (layout min/max limits) is used directly, and the unused
paper_entity_extents() function is removed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Make scene::properties::entity_type_name the single source of truth.
entity_type_label in helpers.rs now delegates to it instead of
maintaining a separate match list.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Properties panel header was still showing "Entity" for unrecognized
types because helpers.rs had its own incomplete match. Both functions now
enumerate every acadrust EntityType variant explicitly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Expanded entity_type_name() to cover all EntityType variants from acadrust
instead of falling back to the generic "Entity" label.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
NAVVCUBE: propagate show_viewcube flag through ViewportPane and the wgpu
Primitive so the ViewCube pipeline skips upload/render when hidden.
UCSICON: bare command (no subcommand) now toggles current state instead
of printing usage info.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Integrate NAVVCUBE, NAVBAR, PROPERTIES, FILETAB, LAYOUTTAB, TOOLPALETTES
and SHEETSET commands to toggle UI widgets at runtime. Add 15 new SVG icons
for view module tools previously using glyph fallbacks. Restyle all SVG
icons to use the established two-color scheme: #e0e0e0 for passive geometry,
#4cc9f0 for active/accent elements.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the flat fixed-length axis arrows with a proper 3D tripod:
- Axis lengths are proportional (longest fills UCS_ICON_LEN, shorter
axes stay foreshortened) giving real depth perception as the camera
rotates
- Draw order computed from NDC Z so back axes render behind front ones
- X / Y / Z labels rendered beyond each arrowhead tip
- All axes drawn at full opacity with solid filled arrowheads
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
prepare() was passing viewport.logical_size() (full window) to
viewcube.upload(), while hit_test/hover_id used the shader widget's
bounds. With the properties panel present the widget is narrower than
the full window, so the visual cube was scaled smaller but the click
area stayed full-size — causing the mismatch that grew toward the
bottom-left corner.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Hide OS crosshair and drawn crosshair when cursor is over ViewCube area
- Enhanced hover glow in WGSL shader (blue tint + brightness boost)
- Fixed region_centroids() Y-axis sign for all FRONT/BACK-related regions
- Swapped corner geometry assignments (TPF↔TBK, BTF↔BBK) to match
intended FRONT/BACK semantics (sy=-1 = FRONT, sy=+1 = BACK)
- Corrected all snap_angles: yaw_pitch_to_quat(0,0) places eye at -Y
(FRONT view), so FRONT=0 and BACK=PI — cascaded through edges/corners
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
acadrust initialises every Layout with 12×9 imperial defaults; override
all non-Model layouts to 297×210mm in new_drawing() so the first paper
tab opens at A4 size, consistent with layouts added later.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- paper_entity_extents() computes the bounding box of actual DXF entities
so the white fill always matches the drawn title-block / frame borders,
regardless of whether Layout min/max_limits match entity positions
- Falls back to paper_limits() (→ A4 297×210) when layout has no entities
- Removed paper_boundary_wire: the white fill now acts as the visual paper
edge so the near-white wire (invisible on white) was redundant
- LayoutCreate sets limits to A4 landscape immediately after add_layout()
to override acadrust's imperial default (12×9)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- paper_limits() falls back to A4 landscape (297×210mm) even when no
Layout object exists in the document
- paper_bg_color default changed to white [1,1,1,1] (paper surface color)
- PaperCanvas::draw() fills canvas with dark desk color first, then draws
the paper area rectangle in paper_bg_color so the sheet is clearly
visible against the desk background
- view.rs container background uses the fixed desk color instead of
paper_bg_color so it no longer conflicts with the paper-surface color
- BACKGROUND RESET for paper space now resets to white instead of dark gray
- Removed unused PaperSheet variant, paper_sheet() constructor,
build_paper_sheet_primitive() and associated match arms (dead code
after 2D canvas replacement)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- viewport_screen_rect now mirrors PaperCanvas::draw()'s camera-based
to_px transform instead of using a fixed paper-limits scale, so the
3D overlay lands exactly over the drawn viewport border at any zoom/pan
- blue border frame (stack layer above the shader) makes the active
viewport boundary always visible even when it fills the canvas
- space-mode pill in MSPACE now dispatches LayoutSwitch("Model") so
clicking it jumps to full Model Space instead of just exiting to PSPACE
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Paper space is now rendered as a 2D vector canvas (iced::widget::canvas)
instead of a 3D shader widget. This allows direct interaction with
paper-space entities (title blocks, viewport borders, annotations)
without needing to enter MSPACE first.
Changes:
- src/scene/paper_canvas.rs: new PaperCanvas<'a> canvas::Program that
renders paper wires (with linetype dashes), solid/gradient hatch fills,
and wipeout backgrounds using the paper camera's orthographic transform.
- Scene: three new public helpers (paper_canvas_wires, paper_canvas_hatches,
paper_canvas_wipeouts) feed the canvas with the same data the old shader
used, including inactive viewport projections and interim/preview wires.
- view.rs: paper_canvas_view() now wraps PaperCanvas instead of
shader(ViewportPane::paper_sheet(…)). The PaperViewportPane 3D shader
overlay for the active MSPACE viewport is unchanged.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
viewport_content_wires() computed view_right via world_z × view_direction
(cross-product). This gives the OPPOSITE sign to the right vector that
look_at_rh produces for views with a Y component (FRONT/BACK views):
GPU look_at_rh: screen_right = f × up = (−vd) × (rot*Y) = rot*X
Old CPU formula: screen_right = Z × vd ← opposite sign for FRONT/BACK
The mismatch caused the paper-space projection to appear mirror-flipped
after panning/rotating in MSPACE.
Fix: use camera_for_viewport() to obtain the exact same rotation
quaternion the GPU uses, then derive both axes from it:
view_right = rotation * X
view_up = rotation * Y
Also replaces the perspective depth dot-product (mp · vd) with
mp · (rotation*Z) so the depth direction is consistent too.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the static MODEL/LAYOUT pill with an interactive button that
shows and toggles the current editing context:
Model tab → "MODEL" (non-clickable, informational)
Layout PSPACE → "PAPER" (click → MspaceCommand: enter MSPACE)
Layout MSPACE → "MODEL" (click → ExitViewport: return to PSPACE)
Highlights in blue when in MSPACE to signal active model editing.
Mirrors the AutoCAD status-bar convention for MODEL/PAPER switching.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
orbit_active_viewport was writing cam.rotation*Z directly to
view_direction, but yaw_pitch_to_quat(y,p)*Z has its Y component
negated relative to the snap convention: (cos(p)*sin(y), -cos(p)*cos(y),
sin(p)) vs (cos(p)*sin(y), +cos(p)*cos(y), sin(p)). This caused
camera_for_viewport to reconstruct yaw = π - original_yaw, making every
orbit appear reversed. Fix: negate Y when writing view_direction back.
pan_active_viewport was using the paper-space camera to convert screen
pixels to model-space delta. This gives wrong pan axes for tilted
MSPACE views (e.g. front/side views where cam_up is Z, not Y). Fix:
use camera_for_viewport so the pan axes match the 3-D view orientation,
and update all three view_target components (X/Y/Z) for tilted views.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add orbit_active_viewport(), snap_active_viewport_to_angles(),
active_view_rotation_mat(), active_viewport_yaw_pitch() helpers so
navigation gestures modify the DXF viewport entity's view_direction
instead of the paper-space camera.
- Fix "already there → flip opposite" check: the previous code used
rot * Vec4::W (always (0,0,0,1) for a rotation matrix); now reads
(yaw, pitch) directly from camera_for_viewport() via the new helper.
- MSPACE right-drag orbit early-returns after writing the viewport
entity, preventing the paper-space camera from also being modified.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a paper-space viewport is activated (double-click / MSPACE command),
it is now rendered through its own dedicated PaperViewportPipeline rather
than the CPU-projection approach used for inactive viewports.
Architecture:
- PaperSheet widget (full-canvas): renders paper entities + CPU-projected
content of all viewports *except* the active one.
- PaperViewportPane widget (Fixed w×h, positioned at viewport screen rect):
renders the active viewport with a true 3D camera derived from the
viewport's view_direction/view_target/view_height.
PaperViewportPipeline is a newtype of Pipeline. Having a distinct type
gives it its own Iced storage entry (keyed by TypeId), preventing the
shared prepare() overwrite that broke the earlier per-viewport approach.
Changes:
- render.rs: PaperViewportPipeline, PaperViewportPrimitive newtypes;
build_active_viewport_primitive(); build_paper_sheet_primitive() now
excludes active_viewport from CPU projection.
- viewport_pane.rs: PaperViewportPane<'a> with shader::Program impl.
- mod.rs: viewport_content_wires() gains exclude_vp parameter;
viewport_screen_rect() is no longer dead code.
- view.rs: paper_canvas_view() overlays PaperViewportPane when MSPACE
is active.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Iced 0.14 batches all shader prepare() calls before any render() calls.
Multiple ViewportPane widgets sharing the same Pipeline type overwrite
each other's GPU buffers, causing the PaperSheet layer (full-canvas) to
render the last viewport's model content — appearing full-screen.
Fix: paper_canvas_view() now renders a single full-canvas PaperSheet
widget. build_paper_sheet_primitive() is updated to include model-space
content projected through each viewport's view matrix (via
viewport_content_wires()), restoring the original working behaviour.
ViewportPane::Paper mode and viewport_screen_rect() are kept with
#[allow(dead_code)] — a per-viewport wgpu sub-renderer that accumulates
data across frames could revive them in the future.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both items were already implemented prior to this commit:
- MSPACE mouse routing (double-click/pan/zoom/Escape) was fully wired
through the existing viewport_mouse overlay and scene helpers.
- Per-viewport frozen layer filtering uses matching Handle values from
the same CadDocument, confirmed correct in model_wires_for_viewport().
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove Scene: shader::Program<Msg> impl; all GPU rendering now goes
through ViewportPane which supports three modes:
Model — full model-space view (unchanged behaviour)
PaperSheet — paper-space entities only, using the paper camera
Paper — model content through a specific viewport's own camera
- Add Scene helper methods (render.rs):
build_primitive / build_paper_sheet_primitive / build_viewport_primitive
update_viewcube_state / viewcube_mouse_interaction
- Add Scene helpers (mod.rs):
paper_sheet_wires() — paper entities without viewport projection
camera_for_viewport() — derive Camera from Viewport entity data
model_wires_for_viewport() — model wires filtered by per-viewport frozen layers
viewport_screen_rect() — paper-space → pixel rect mapping
- Add paper_canvas_view() in view.rs:
Stack of PaperSheet + one Paper widget per Viewport entity,
positioned with Space offsets from viewport_screen_rect()
- Update VIEWPORT_WIDGET_PLAN.md: mark Steps 1–4 done, document remaining work
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- REPORT opens GitHub new-issue page
- ABOUT opens a dialog window with version, OS and arch info + Copy Info button
- CHANGELOG opens GitHub releases page
- Fix Windows build: add windows-sys as target-specific dependency for PRINT command
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Block-definition geometry (entities stored inside named blocks) was
leaking into the viewport when DXF files omit the owner-handle group
code (330) on block-content entities.
The fix tightens `belongs_to_visible_block`: when `owner_handle` is
null, the current layout block-record's `entity_handles` list is used
as the authoritative allow-list before falling back to the older
"not-in-any-other-block" heuristic. This ensures block definitions
are never rendered directly, only when referenced via an INSERT.
Bumps version to 0.1.4.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Arc rendering now respects the normal vector: when normal.z < 0 the
midpoint is placed on the clockwise side so the curve sweeps the right way
- Removed spurious .to_radians() / .to_degrees() round-trips in arc.rs
(angles are already stored in the unit the trig functions expect)
- apply_grip and apply_transform use consistent angle units
- normalize_insert_entity no longer converts arc angles; the old conversion
was only needed by the now-removed .to_radians() call in to_truck
- Added fix_mirrored_arc: swaps arc start/end angles when the INSERT has a
mirrored scale (x_scale * y_scale < 0) so exploded arcs curve correctly
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add COMMANDS.md: full CAD command reference (256 commands across 11
categories) with implemented/partial/missing status for each
- Update ROADMAP.md to English, remove external product name references
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Lists 33 stub commands across Insert, View, Manage, and Annotate tabs
with descriptions and Low/Medium/High complexity estimates.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Redesign Insert ribbon tab with 6 groups matching screenshot layout:
Reference (Attach/Clip/Adjust large + Underlay Layers/Frames/Snap small),
Point Cloud (Attach), Block (Multi-View Block/Insert large + Create/Edit/Base small),
Attributes (Define/Edit large + Manage/Sync small),
Import (Import/Land XML), Content (Content Browser/Design Center)
- Remove Primitives group and dead box_prim/clear/cylinder/sphere modules
- Fix all compiler warnings with #[allow(dead_code)] on unused-but-intentional items
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Redesign View ribbon tab with 8 groups matching AutoCAD layout:
Viewport Tools (UCS Icon, ViewCube, Navigation Bar),
Navigate, Model Viewports (Viewport Configuration, Named, Join, Restore),
Visual Style (dropdown), Projection, Preset,
Palettes (Tool Palettes, Properties, Sheet Set Manager),
Interface (File Tabs, Layout Tabs, Tile Horiz/Vert, Cascade)
- Add Extract Data and Link Data tools to Annotate → Tables group
- Fix tab order to Home → Insert → Annotate → View → Manage via build.rs PRIORITY list
- Add 17 new SVG icons for all new commands
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New StyleComboGroup RibbonItem renders a dropdown combobox for selecting
text style, dimension style, multileader style, or table style. Ribbon
groups in the Annotate tab now match the reference layout: each group
has a large tool on the left and a style combobox with tool rows on the
right.
Each combobox shows the active style name, opens a scrollable item list
on click, and has an optional "Manage…" row that fires the style manager
command (STYLE / DIMSTYLE / MLEADERSTYLE / TABLESTYLE).
Style state is synced from the document on every layer refresh via
sync_ribbon_styles(). RibbonStyleChanged message propagates selections
back to the acadrust document header and the active_mleader_style field.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>