Rename release uploads:
OpenCADStudio-<tag>-windows-x86_64.exe → -portable.exe
OpenCADStudio-<tag>-windows-x86_64.msi → -installer.msi
Makes the distinction obvious on the release page so users don't have
to guess which file is the standalone exe and which one runs setup.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Cross-platform prerequisite for OS-level file associations: the boot
task now consumes `std::env::args_os().nth(1)` as a path and dispatches
`Message::OpenRecent` for it. Flag-style args (starting with `-`) are
ignored, and `OpenRecent` already does the file-existence check, so a
bogus path lands as a clean command-line error instead of a panic.
Linux: the AppImage's desktop entry adds `image/vnd.dwg` alongside the
existing `image/vnd.dxf` MIME type and grows a `%f` placeholder in
`Exec=` so the launcher forwards the picked file path. Once the
AppImage is integrated with the system (xdg-mime / AppImageLauncher),
double-clicking a .dwg / .dxf opens it in Open CAD Studio.
Windows: new `packaging/windows/main.wxs` defines an MSI installer —
per-machine install to `Program Files\Open CAD Studio`, Start Menu
shortcut, `MajorUpgrade` so newer MSIs replace older ones, and a
single ProgID `OpenCADStudio.Drawing` that owns both `.dwg` and
`.dxf` and launches the exe with the file as `argv[1]`. The icon is
pulled from the SVG logo, converted to multi-resolution ICO at build
time with the runner's pre-installed ImageMagick. CI now also runs
`candle` / `light` (WiX Toolset 3, pre-installed on `windows-latest`)
and uploads both the bare `.exe` (portable) and `.msi` (installer)
to the release.
macOS Info.plist already declares the DWG / DXF UTIs; combined with
the argv-handling change above, double-clicking a drawing in Finder
will open it in Open CAD Studio without further packaging changes.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The eight layer-state commands (LAYOFF, LAYFRZ, LAYLCK, LAYULK, LAYON,
LAYTHW, LAYISO, LAYUNISO) mutated `document.layers` directly through
`dl.turn_off()` / `dl.freeze()` / `dl.lock()` / … and then called
`refresh_layer_panel()` — but never bumped the scene's geometry epoch.
The 3D viewport caches its uploaded geometry keyed by that epoch, so
visibility / freeze changes only took effect once something else
triggered a re-render. Pressing Esc was the workaround because the Esc
handler calls `deselect_all()`, which internally bumps geometry.
The Layer Properties panel toggles already did this (their handlers in
`update.rs` call `scene.bump_geometry()` after each freeze / visibility
toggle), which is why the panel worked and only the command path
exhibited the lag.
Add `scene.bump_geometry()` after the layer mutation loop in each of
the eight command branches so the viewport repaints immediately. Lock /
unlock don't strictly affect rendering today but are bumped for
consistency — selection / grip code may grow lock-aware later.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Both hatch fragment shaders ended their `fs_main` with a bare
`discard;` after the pattern-match for-loop falls through without
matching. WGSL accepts this — discard kills the fragment, so there is
nothing left to return — and naga (the Linux/Vulkan path wgpu defaults
to) lowers it without complaint. DX12's FXC (the default Windows
compiler) is stricter and rejects it with `X3507: 'fs_main': Not all
control paths return a value`, taking the entire pipeline create-down
on every drawing open.
Append an unreachable `return vec4<f32>(0.0);` after each terminal
`discard;` so every control path syntactically ends in a return. The
return never executes at runtime; it only exists to make FXC's
all-paths-return analysis succeed. Naga still accepts the shader
unchanged, so the Vulkan / Metal / WebGPU paths are unaffected.
Reported by @Ward-Vandepitte (Windows 11, DX12, wgpu 27.0.1).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Quick Select used to filter only on Object Type and Layer. The classic
QSELECT model — pick a type, pick one of its properties, compare with a
typed value via a logical operator — is much more general: a Line entity
can now be filtered on Start X, Length, Angle, Delta Y, …, and any
entity on the common Layer / Color / Linetype / Lineweight.
Panel layout: Object type → Property → Operator → Value → Append. The
Property dropdown is type-aware: it always lists the four common
properties; picking a specific Object type appends that type's
`geometry_properties` rows, sampled from the first entity of that type
in the active layout (so `Start X`, `Radius`, `Pattern Angle`, … only
appear when their entity type is selected). Changing the Object type
drops the Property when the new type no longer offers it.
Operators: `= Equals`, `!= Not equal`, `> Greater than`, `< Less than`,
`* Any value`. Eq/Neq do case-insensitive string compare against the
canonical property string (so "ByLayer" matches "bylayer"); Gt/Lt parse
both sides as `f64` and reject anything non-numeric; Any skips the
value test entirely. The Value text field is disabled when no Property
is picked or the operator is Any. Append behaves the same as before.
The new value reader is hand-rolled for the four common properties
(layer name, color formatted as `ByLayer`/`ByBlock`/`<aci>`/`r,g,b`,
linetype name, lineweight formatted as `0.30mm`) and falls back through
`geometry_properties()` for type-specific fields — extracting the
property's value out of the `PropValue` variant so EditText / Choice /
ColorChoice all canonicalise the same way the panel will display them.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two ways to extend the current selection by entity type + layer:
* `Select Similar` (right-click → Select Similar, or `SELECTSIMILAR` /
`SELSIM`): for every (type, layer) pair in the current selection, add
every entity in the active layout that matches the pair. The seed
selection stays selected; matches already selected are not
double-counted.
* `Quick Select` (right-click → Quick Select…, or `QSELECT` / `QS`):
opens a centred floating panel with Object-type and Layer pick_lists
(populated only with values that actually exist in the active layout)
and an "Append to current selection" checkbox. `(Any)` in either slot
skips that filter. Apply replaces the selection (or extends it with
Append on) and reports the match count on the command line. Cancel,
Esc, and outside-click all dismiss without applying. When opened with
a selection present, the panel pre-fills both filters from the first
selected entity so QSelect doubles as an editable Select Similar.
Scoped to entities owned by the active layout's block-record so a paper
layout's QSELECT never reaches into model-space entities (and vice
versa). Entity-type names live in a single `entity_type_name` helper in
`entities::traits` to keep the UI strings and the filter keys aligned.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The right-click context menu was being placed via window-relative
coordinates while the cursor position it anchored to was canvas-relative,
so the menu drifted away from the cursor by the size of the surrounding
ribbon / sidebar / status bar.
Move the menu inside `viewport_stack` so its anchor resolves in the same
coordinate space the cursor was captured in. Introduce
`position_canvas_overlay(anchor, panel)` — wraps `panel` in a column+row
of fixed-width spacers and `iced::widget::opaque(panel)` so events on the
menu itself don't fall through to the viewport mouse area underneath.
The multi-functional grip popup is rewritten to use the same helper.
Outside-click dismiss now mirrors the grip popup: `ViewportLeftPress`
checks `selection.context_menu.take()` at the top and returns early
when it was set, so a press that reaches the viewport mouse area
(i.e. outside the opaque panel) closes the menu without running the
rest of the left-click handler. The redundant `context_menu = None`
later in the handler and the now-unused `Message::ViewportContextMenuClose`
are removed.
Two related issues fixed in the same pass:
* The right-drag threshold for orbit was 3 px squared, small enough that
normal hand jitter between a right-button press and release was
promoting a click to a drag and suppressing the menu on release.
Bumped to 8 px squared.
* `Message::ViewportExit` was clearing `context_menu`. With the menu now
living above the viewport mouse area, the opaque panel capturing the
cursor fires the underlying area's exit handler — which closed the
menu the instant it opened. Stop clearing the menu there; outside-click
dismiss is enough.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
GitHub Actions takes ~15 min to build and attach the platform binaries
after a tag is pushed; the latest-release API returns the tag the moment
it's published, so users were getting a popup pointing at a release page
whose asset list was still empty. Parse `published_at` (minimal
YYYY-MM-DDTHH:MM:SSZ → UNIX seconds via days-from-civil, no new deps)
and skip the notification while the release is younger than 30 minutes.
A missing or unparseable timestamp falls through to the old behaviour so
a malformed payload can't permanently silence notifications.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Lengthen / Radius / Arc Length need a number after the pick. Stash
`grip_pending` on the picked action, push prompt to command line,
route next `CommandSubmit` parse into `apply_grip_menu_value`.
Escape cancels.
- `Grippable::grip_menu_value_prompt` returns label when action
wants value; `apply_grip_menu_value` runs the edit. Dispatched
via `EntityTypeOps`.
- Line: Lengthen extends either endpoint along line direction.
- Arc: Radius sets radius; Arc Length redrives end angle from
`value / radius`; Lengthen extends start / end angle the same
way.
The previous single-widget refactor left the column at
`Length::Shrink` and the buttons at `Length::Fill`, which iced
resolves to a zero-width column — the popup degenerated into a
1-pixel vertical line. Set the column to a fixed pixel width
derived from the longest item's label (and restore `width(Fill)`
on the buttons) so the selection highlight covers the full row
instead of just the text glyphs.
Also silences a `dead_code` warning on `GripMenuAction` variants
that the Phase 2 / 3 wiring will consume next.
- Popup items now render inside one bordered container with
borderless buttons so the menu reads as a single widget instead
of stacked tiles.
- Arrow Up / Down (and Tab) walk `grip_popup.selected` while the
popup is open; Enter commits the highlighted item by re-emitting
`GripMenuPick`; Escape dismisses without acting; the underlying
handlers (`CommandHistoryPrev/Next`, `CommandFinalize`,
`CommandEscape`, `DynTabNext`) keep their normal behaviour when
no popup is open.
- A press inside the viewport that reaches the mouse_area (i.e. not
on a popup item) closes the popup and consumes the click — the
user's next press then starts a normal selection / drag.
- Line: endpoint grips expose Stretch + Lengthen; midpoint exposes
Stretch only.
- Arc: endpoint exposes Stretch + Lengthen; midpoint exposes
Stretch + Radius + Arc Length; centre exposes Stretch.
- Dimension text grip exposes the full text-position vocabulary
(Move with Dim Line / with Leader / Independent, Reset Text,
Rotate Text, Above Dim Line, Center). Dim-line-position grip
exposes Stretch + Reverse Arrows. Extension origins keep the
default Stretch.
- Each affected entity drops `impl_entity_basics!` and writes the
three trait impls (Grippable, PropertyEditable, Transformable)
manually so `grip_menu` / `apply_grip_menu` can override.
- `apply_grip_menu` handles Reset Text (clear text override) and
Center (snap text to midpoint of extension origins) inline;
remaining actions stub to no-op pending the follow-up
prompt / drag plumbing.
Dwell timing only advanced when `ViewportMove` fired; a perfectly
still cursor never triggered the popup. Subscribe to animation
frames while `grip_hover` is set and dispatch `GripDwellTick` from
them so `update_grip_hover` re-checks the elapsed dwell each frame.
Subscription auto-stops as soon as the hover clears or the popup
opens.
Phase 2 of the grip overhaul: when the cursor dwells on a selected
entity's grip the overlay opens a popup menu with entity-specific
options (Stretch / Add Vertex / Remove Vertex / Convert to
Arc-Line / …). Picking an item dispatches `apply_grip_menu`; the
default `Stretch` entry is a no-op that lets the user click the
grip to start the normal drag.
- `GripMenuItem` + `GripMenuAction` (full vocabulary covering
stretch, add/remove vertex, convert to arc/line, reverse arrows,
text-position variants, hatch parameters, tangent direction).
- `Grippable` trait gains `grip_menu` + `apply_grip_menu` with
trait-default `Stretch`-only impls so every existing entity gets
the popup for free.
- `EntityTypeOps` dispatches both methods across the same entity
list as the existing grip / property machinery.
- `OpenCADStudio` carries `grip_hover` (dwell tracker) +
`grip_popup` (open menu). `update_grip_hover` runs from
`ViewportMove`: hit-tests grips, refreshes the dwell timer, and
opens the popup after 600 ms. Cursor drift past 80 px or a grip
click dismisses it.
- `view.rs` paints the popup as an absolute-positioned column of
buttons at the grip's screen anchor; each button publishes
`Message::GripMenuPick(idx)`.
- `LwPolyline` overrides `Grippable` manually (skips the standard
macro) so its vertex grip exposes Add/Remove Vertex and its
segment-midpoint grip exposes Add Vertex + Convert to Arc/Line.
`apply_grip_menu` performs the edits: vertex insertion at the
chord midpoint inheriting the previous bulge, vertex removal,
and bulge toggle for the arc/line conversion.
Phase 1 of bringing the grip vocabulary in line with the standard
CAD convention: drop the per-position-type shape encoding (Diamond
for translate, Circle for parameter) and use a plain square for
every endpoint / vertex / centre grip. The behavioural midpoint vs
vertex distinction stays — it lives on `GripDef::is_midpoint` and
drives `Translate` vs `Absolute` in the grip-edit dispatcher — only
the marker shape collapses.
- `GripShape` keeps `Square`, `Rectangle`, `Triangle`. Diamond /
Circle are gone.
- `GripDef` gains `dir: Option<[f32; 2]>` — a world-XY direction
vector consumed by `Rectangle` to orient the box along its
segment.
- `entities::common` exposes `square_grip`, `center_grip` (same
square marker, flagged as translate), `rectangle_grip(id, world,
dir)` for oriented mid-segment handles, and a kept-for-Phase-2
`triangle_grip`.
- `overlay::GripMarker` / `grips_to_screen[_paper]` thread `dir`
through to the canvas painter; the Rectangle path rotates the
box around the grip centre using the world-XY direction (flipping
the sin for screen-Y).
Every existing `diamond_grip(id, w)` call becomes `center_grip(id,
w)` — the visual change is square-replacing-diamond at line
midpoints / arc midpoints / circle centres / ellipse centres /
viewport / hatch loop centroids / dimension grips / image corners /
multileader / ray / underlay / ole2frame / solid3d.
`LwPolyline` grows a stretch handle on every segment (straight or
arc), drawn as the new oriented rectangle. The grip-edit path
translates both segment endpoints for straight segments and
adjusts the arc bulge from the new midpoint for arc segments.
Existing entity grip definitions already followed the conventional
CAD layout: square at vertices / endpoints, diamond at curve
centres / midpoints, triangle for directional control. Round out
the supported shape vocabulary with the two missing standards so
future entities (polyline straight-segment stretch grips, dimension
parameter grips, …) can pick the right marker without inventing
ad-hoc visuals:
- `GripShape::Rectangle` — direction-aware mid-segment stretch
handle (wider-than-tall box).
- `GripShape::Circle` — parametric control (radius / dimension
value).
New `rectangle_grip` / `circle_grip` helpers in `entities::common`
mirror the existing `square_grip` / `diamond_grip` / `triangle_grip`
constructors. `SelectionCanvas::draw` renders the two new variants;
the previously-used Square / Diamond / Triangle paths are
unchanged. Both new variants carry `#[allow(dead_code)]` until an
entity adopts them.
Two bugs from #34:
1. Hovering a circle showed the Center snap as a diamond instead of
the conventional circle outline.
2. Hovering a circle also showed Midpoint hits (triangle marker)
even though a closed curve has no midpoint.
(2) came from a "tessellated curve" fallback in the Midpoint snap
path that produced a midpoint for every chord of the polyline
approximation. Drop that fallback — only entities with explicit
`key_vertices` (Line, LwPolyline) contribute per-segment midpoints
now. Curves that DO have a single well-defined midpoint (arcs, and
later splines) declare it explicitly via a new
`SnapHint::Midpoint`; `arc.rs` emits one at the arc-length centre.
(1) — and the broader "everything past Endpoint / Midpoint / Grid
was a diamond" inconsistency — fixed by giving every `SnapType` a
distinct marker in `SelectionCanvas::draw`:
- Center: hollow circle
- Node: circle with inscribed X
- Quadrant: diamond (unchanged)
- Intersection: X
- Apparent Intersection: X inside a square
- Insertion: two overlapping rectangles (tag glyph)
- Perpendicular: right-angle hook
- Tangent: circle with a bar across the top
- Nearest: hourglass / bowtie
- Extension: three dots
- Parallel: two parallel diagonal bars
- Endpoint / Midpoint / Grid: unchanged
Closes#34
LAYOFF / LAYFRZ / LAYLCK / LAYON / LAYTHW / LAYULK / LAYISO /
LAYUNISO mutated the document's layer table (\`turn_off\` /
\`freeze\` / \`lock\` / …) and then called \`sync_ribbon_layers\`,
which feeds the ribbon dropdown from \`self.tabs[i].layers.layers\`
— the \`LayerPanel\` cache. That cache was never refreshed from
the document for these commands, so the dropdown stayed wrong and
the Layers Properties Manager kept showing the old visibility /
lock / freeze icons.
Add \`OpenCADStudio::refresh_layer_panel\` that runs
\`LayerPanel::sync_with_viewports\` from the live document before
calling \`sync_ribbon_layers\`. Replace every direct
\`sync_ribbon_layers\` in \`commands.rs\` (all of them sit inside
LAY* arms) with the new helper.
Closes#39
A ribbon tool that opens a popup window (LAYERS, PAGESETUP,
ABOUT, the style managers, …) marks itself blue via
\`activate_tool\` when the user clicks it, but nothing un-marked
the tool after the window was dismissed — \`OsWindowClosed\`
cleared the matching \`_window\` slot, the active-tool string
stayed put, and the button kept rendering as if the panel were
still open.
Add \`Ribbon::deactivate_tool_if(id)\` (clears only when the
active tool matches) and call it for every popup-window slot in
\`OsWindowClosed\`. Also clear inside the \`ToggleLayers\` close
branch — that path \`take()\`s \`layer_window\` to \`None\` before
\`OsWindowClosed\` fires, so the conditional in the
\`OsWindowClosed\` handler would miss the close otherwise.
Mapped IDs match the matching ribbon \`ToolDef.id\`s (LAYERS,
PAGESETUP, ABOUT) plus command names for the popups normally
opened via the command line (TEXTSTYLE, TABLESTYLE, MLSTYLE,
LAYOUTMANAGER / LAYOUTPANEL, PLOTSTYLE / STYLESMANAGER, DIMSTYLE,
SHORTCUTS / KEYBOARD) so a future ribbon tool with one of those
ids gets the same correct deactivate.
Closes#40
Every secondary window (save-as, unsaved-changes, layout manager,
layer properties, ribbon dialogs, …) opened at the default
\`Level::Normal\`, so flicking focus to the main window let the popup
disappear behind it — easy to lose, especially the modal-flavoured
save-as / unsaved-changes prompts where the user has no clear way
back. Set \`level: Level::AlwaysOnTop\` on every \`window::open\`
call in \`update.rs\` so each popup floats above the main window
until it's closed. Main window's \`Settings\` in \`mod.rs::boot\`
keeps the default level on purpose.
Refs #38
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
`sync_dyn_fields` only ran during `ViewportMove`, so a typed-coord
or click-driven point commit left the previous iteration's field
shape in place until the user nudged the mouse. After the first
LINE click that meant the stale `[X, Y]` (built when there was no
base) kept serving the next point's input as cartesian even though
the command-default for a "Point with base" is now polar
`[Distance, Angle]`. The original #35 fix preserved a
`,`-reshaped cartesian set on purpose, but the same machinery now
also held onto a never-explicitly-chosen `[X, Y]` carried over from
"no base" → "has base".
Track that intent explicitly with `dyn_user_reshaped` (set in
`dyn_comma_advance`, cleared on point commit and command start)
and only treat a non-matching shape as acceptable while that flag
is on. Re-run `sync_dyn_fields` from every point-commit path
(command-line typed coord, mouse click, dynamic-input locked
commit) so the freshly updated `has_base` state immediately picks
the right default and the user sees polar fields without having
to move the mouse first.
Typing \`,\` while DYN was on appended the character to the focused
field's buffer (treated as a European decimal point), so users
couldn't switch to cartesian coordinates mid-command. The dynamic
input was stuck in polar \`[Distance, Angle]\` whenever a base point
existed.
\`,\` now acts as the coordinate separator (matching the AutoCAD
convention): pressing it locks the current field's buffer, then
either advances within the existing cartesian set or reshapes a
polar configuration into cartesian:
- \`[Distance, Angle]\` + \`,\` on the first field → \`[X(buf), Y]\`
- \`[X, Y]\` + \`,\` on Y → \`[X, Y, Z]\`
- otherwise advances to the next field (Tab-equivalent)
\`sync_dyn_fields\` accepts both polar and cartesian shapes as valid
\`Point\` configurations so a mouse-move after the reshape doesn't
revert to polar. \`dyn_resolve_point\` and the overlay's live-value
formatter treat cartesian inputs as RELATIVE to the base point when
one exists — matching the DYN-on relative-coords convention from
#26. \`DynComponent::Z\` plus its label / value paths fill out the
3-D variant.
Closes#35
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Typing a coordinate (e.g. \`25\`\\TAB\`45\` for polar input) and pressing
Enter committed the point through \`on_point\` but never re-ran the
preview hook. The mouse-move pipeline that normally publishes the
rubber-band segment from the latest \`last_point\` didn't fire — no
mouse motion occurred — so the active blue segment kept dangling
from the *previous* point until the user nudged the mouse.
Add \`refresh_active_cmd_preview\` and call it after the keyboard
point commits (both the command-line path and the dynamic-input
locked-field path) so the next segment starts from the
just-committed point immediately.
Closes#32
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The OCS main menu's "Exit Open CAD Studio" button dispatched
`Message::Command("EXIT")` but `dispatch_command` had no arm for it,
so the click was swallowed. Route `EXIT` and `QUIT` through
`Message::WindowCloseRequested` so the unsaved-changes dialog runs
first and the app then exits via the same path as the OS-window close.
Closes#41
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
`tessellate_sub_local` and `build_nested_ref` baked `adapt_to_bg`
results into the cached `BlockCache`, keyed against whatever bg was
live at cache-build time. Paper-space content viewports render
through model content with `paper_bg_color`, but if the cache had
been built earlier against `bg_color` (or vice versa, after the
recent layout-switch dance) the cached sub-wire colours were
already adapted to the wrong bg and `expand_insert` emitted them
verbatim.
Store the raw `render_style_for` result on `LocalWire.color` /
`NestedRef.ins_color` and run `adapt_to_bg` in `Batches::finalize`
with the per-render `bg_color` that `expand_insert` already
threads through. The same cached defn can now serve renders
against any background — paper viewports get `paper_bg`-adapted
sub-entities, model renders get `bg_color`-adapted sub-entities,
no rebuild required.
Double-adaptation (ByBlock sub inheriting an already-adapted
`ctx.ins_color` from `tessellate_entity`) is idempotent: a pure
white that adapted to black on a white bg stays black through a
second adapt against the same bg.
`adapt_to_bg` (pure black → white on dark bg, pure white → black on
light bg) was only running through `render_style`, which the wire and
per-frame hatch paths already use. The mesh population paths and the
file-load hatch path went straight through `aci_to_rgba`, so:
- ACIS solids / regions / bodies appeared in their raw ACI colour
even when that colour was pure white on a white paper bg.
- The initial hatch upload used the unadapted colour for the first
frame after load (`synced_hatch_models` then re-ran adaptation per
frame, so the issue cleared after one redraw — but visible).
Now every mesh / hatch creation site funnels through
`render_style_for` + `adapt_to_bg`:
- `build_derived_caches` (load): uses the default model bg as the
adaptation target.
- `populate_meshes_from_document`: uses `self.render_style` so the
per-frame paper / model bg selection applies.
- New `Scene::recolor_meshes` rewrites every cached mesh's colour
field through `render_style`; called from `BACKGROUND` (after the
user changes bg) and `set_current_layout` (Model ↔ paper bg
switch) so ACIS mesh colour tracks the live bg without re-
tessellating ACIS geometry.
Wipeout fills stay bg-coloured by design (that's their job). Raster
images skip adaptation — pixel data is not entity colour.
The previous commit let model-block hatches into the shared
`hatch_models_arc` so paper-layout content viewports could pick them
up through their GPU pipeline. PaperCanvas was reading the same arc
and projecting every entry through the paper camera, so model hatches
got a second copy on the paper sheet — at huge / off-position
coordinates because their `world_origin` is in offset-subtracted
local space, not paper millimetres.
Split the canvas-side accessors:
- `paper_canvas_hatches` now iterates `self.hatches` directly (the
source map is keyed by entity handle) and keeps only entries whose
owner is the active paper-layout block. The flattened arc only
carries pattern names, so handle-based filtering had to move here.
- `paper_canvas_wipeouts` iterates entities likewise; paper-block
wipeouts get `[0;3]` `world_offset` so the boundary is in paper
millimetres.
GPU paths still call `hatch_models_arc` / `wipeout_models_arc` which
return everything — the per-viewport scissor / camera projection
silently culls the wrong-block hatches there.
Paper-space content viewports rendered the model's wires + meshes but
no hatches. `synced_hatch_models` only kept entries owned by the active
layout's block, so flipping to a paper layout dropped every hatch
created in model space from the arc that `viewport_data_for` uploads
to the per-vp GPU pipeline.
`populate_hatches_from_document` already bakes the right per-block
world_offset into each `world_origin` (model → `self.world_offset`,
paper → 0), so adding both buckets back is safe: projecting a paper-
block hatch through a model viewport's camera lands it outside the
frustum and the per-vp scissor / LOD culls it (and vice versa). No
double-rendering.
`wipeout_models` had the same shape of bug — its `world_offset` was
picked from the active layout instead of the wipeout's owner. Now it
chooses per-entity, so model wipeouts also show up in paper viewports.
Two world_offset bugs in viewport rendering.
(1) Solid3D / Region / Body meshes were tessellated straight out of
the ACIS SAT data in WCS, while the wire / hatch / face3d pipelines
all run in `(WCS - world_offset)` local space. At UTM scale the
result was triangles drifting millions of units off-camera every
frame. `offset_mesh_lod_set` post-processes the freshly built
`MeshLodSet`, subtracting `world_offset` from every vertex and
recomputing `world_aabb` so the LOD / cull math agrees with the
shared camera space. Applied at the three `tessellate_volume`
call sites — load, `add_entity`, and `populate_meshes_from_document`.
(2) Paper-space content viewports rendered blank on UTM drawings.
The DWG / DXF saved `view_target = (0, 0, 0)` while the model sat
around `world_offset`; the CPU projection in `viewport_content_wires`
already had a "saved view doesn't overlap content cluster →
auto-fit to (world_offset ± local_extent_max)" fallback, but the
GPU path read `vp.view_target` literally and culled every entity
against the empty WCS rect. `camera_for_viewport` now applies the
same overlap test + auto-fit, and `model_wires_for_viewport`
derives its frustum AABB / wpp from the resulting camera so both
the camera and the cull agree on which area to show.
Folding `view_center` directly into `effective_target_wcs` matches
the CPU path's `display_center_x = view_target + view_center`,
removing the prior `+ view_right * view_center.x` shift that would
double-count once auto-fit had overwritten the target.
`model_wires_for_viewport` previously passed `view_aabb: None` and
`wpp: None` to `tessellate_entity` — the assumption that paper-space
viewports were too small for culling to matter falls over the moment
the document carries 100k+ entities. Each frame re-tessellated the
full model through every floating viewport.
`wires_for_block_culled` grows two optional parameters
(`frozen_layers`, `anno_scale_override`) and now flips its
`world_offset` / `bg` / `anno` selection on `is_model_block` rather
than `current_layout`, so a paper-layout caller asking for the model
block still gets WCS-subtracted coordinates and the right annotation
scale.
`model_wires_for_viewport`:
- derives the viewport's frustum AABB from its (paper-zoom-invariant)
camera + entity aspect — 25 % margin to match `view_world_aabb`,
- derives `wpp` from the on-paper pixel height the viewport currently
occupies, so LOD stubs and zoom-adaptive curve sampling track the
paper-zoom state,
- delegates everything else to `wires_for_block_culled` so block /
layer / frozen-layer / curve-tolerance handling stays in one place.
`model_wires_for_viewport_arc` keys on `(geometry_epoch,
round(screen_height_px))` — sub-pixel jitter still hits the cache,
real paper-zoom steps invalidate. Hit-test / CPU-projection callers
pass `screen_height_px = 0.0` to get the no-LOD (full-fidelity) wire
list in their own cache slot.
Tiled Model panes were all reading from the shared `entity_wires_arc`,
whose tessellation runs `view_world_aabb` / `world_per_pixel` against
the live `Scene::camera`. Zooming the active tile re-built that arc
with the active camera's LOD / frustum cull, then every other tile
rendered from the same arc — content in the inactive panes flickered
between full and LOD-stub tessellations as you zoomed.
- `wires_for_block` now delegates to `wires_for_block_culled`, which
takes `view_aabb` + `wpp` explicitly. The original caller passes
the live-camera values; tile rendering passes its own.
- New `model_tile_wires_arc` builds a per-tile view AABB + wpp from
the tile's camera + pixel rect and caches the result. Cache is
keyed by tile index; the value holds `(geometry_epoch,
camera_state_hash)`, so a stale hit (camera moved, doc changed)
still misses and rebuilds.
- `ViewportInstance` gains `tile_idx` so `viewport_data_for` can route
Model tiles into the per-tile cache without disturbing the paper-
layout content-viewport path (it still uses `model_wires_for_viewport_arc`).
Two cursors layered on top of each other (the OS arrow / crosshair
icon plus the CAD crosshair drawn in `SelectionCanvas::draw`) looked
busy and made it harder to see what was pickable. `Interaction::None`
was the first try but `Stack::mouse_interaction` skips that value as
"no opinion" — the correct hide signal is `Interaction::Hidden`,
which iced_winit maps to a hidden cursor.
Over a Model-tile divider the OS now wins (resize arrow), and the CAD
crosshair is suppressed in `draw` via the same `tile_edge_under`
helper that mouse_interaction uses.
Tiled Model layouts now show the inner edges between panes as 2-px
dividers that act as resize grips: cursor on a divider → resize cue,
press + drag moves the edge (with every tile sharing that edge
updating together), release runs a collapse pass that absorbs any
tile that fell below the viewcube-comfort minimum into the neighbour
with the longest shared contact edge — drag a divider all the way
across to remove a pane.
- Scene grows `model_tile_edges`, `hit_model_tile_edge`,
`move_model_tile_edge`, `collapse_small_model_tiles`. Edges are
derived from the existing `model_tiles` rects (no extra storage).
- App carries a `tile_drag` Option; `ViewportLeftPress` starts it
ahead of tile activation / picking, `ViewportMove` drives the
edge, `ViewportLeftRelease` collapses + clears.
- `SelectionCanvas` draws the dividers and switches the cursor to
`Resizing{Horizontally, Vertically}` over them.
`model_wires_for_viewport` was tessellating with `self.bg_color` (the
model bg), so model content rendered inside a paper-layout viewport
adapted to a dark bg even though the transparent shader now reveals
the PaperCanvas sheet behind it — white wires stayed white on a light
sheet. Pass the paper bg in a paper layout.
Wire cache also needed an explicit invalidation when the bg or the
active layout changes; otherwise the cached, already-adapted wires
were returned against the new bg unchanged.
- BACKGROUND command bumps `geometry_epoch` after both branches
- new `Scene::set_current_layout` setter bumps on actual change; layout
switch + history restore use it
The previous off-canvas fix sized each per-viewport MSAA / depth /
resolve texture to the full viewport rect, then UV-cropped the blit.
With deep paper-space zoom that rect can grow past wgpu's 8192-pixel
texture limit and the program panics in `Device::create_texture`
("Dimension Y value 9493 exceeds the limit of 8192").
`viewport_data_for` now clips the screen rect to the canvas before
returning the `ViewportData`, so the per-viewport textures are bounded
by the surface (≤ canvas size, always within the GPU limit). The
camera frustum is still built at the *full* vp aspect (so the world it
projects matches the viewport entity), and a new `crop_view_proj`
post-multiplies the standard view_proj by a clip-space transform that
remaps the visible sub-rect to NDC `[-1, 1]^2` — the off-center ortho
that lets the visible-sized MSAA carry the correct portion of the
view. `viewport_size` is set to the visible size for the wire shader's
screen-space line extrusion; `world_per_pixel` is crop-invariant (the
`vs` factor cancels) so the value `Uniforms::new` computes from the
full bounds remains correct.
Viewports whose screen rect doesn't intersect the canvas at all return
`None` and are filtered out before any inner pipeline is allocated.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Refactor the per-viewport blit so a content viewport whose screen rect
extends off the canvas composites the correct slice of its MSAA target
to the visible portion of the surface, instead of being slammed against
the canvas corner by an `(f32 as u32)` saturation on the negative
offset.
- blit.wgsl + Pipeline gain a small uniform buffer (`uv_offset` /
`uv_scale`). `Primitive::prepare` computes the per-viewport crop from
`screen_rect`'s on-canvas fraction and writes it via the new
`upload_blit_uv` helper while it still has the `Queue`.
- `Pipeline::render` now takes `vp_size` (full vp — MSAA / camera size)
and `surface_dest` (visible intersection — blit destination) and
reads the crop from the uniform; passes that don't have a non-empty
surface intersection are skipped.
- `Primitive::render` clips the full vp rect against the surface clip
in `i32` and skips empty intersections. The earlier "skip GPU for
inactive off-canvas viewports" workaround in `active_viewports` is
no longer needed.
- ViewCube draws only when its hosting vp is fully on-canvas (its own
pipeline writes directly to the surface and would distort under a
clamped `set_viewport`).
With the GPU path correct for every vp position, drop
`viewport_content_wires` from `paper_canvas_wires` — the inactive
viewport CPU projection was only there to mask the blit bug and was
duplicating the unified shader's output. The hit-test / snap path
(`entity_wires_arc`, `wires_for_block`) still calls
`viewport_content_wires` directly, so picking through inactive
viewports keeps working.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Zooming the paper view in PSPACE grows each floating viewport's screen
rectangle until its edges run past the canvas. The per-viewport blit
computes its surface offset via `(screen_rect.x * cw) as u32`, which
saturates negative values to 0 — so a viewport hanging off the left
edge was being painted at the canvas top-left instead of its actual
position, producing a drifting ghost copy on top of the CPU projection
that PaperCanvas was already drawing correctly clipped.
`active_viewports` for paper now skips the GPU pass for any inactive
content viewport whose screen rect would extend beyond the canvas. The
CPU projection already handles those, so only one (correct) copy is
visible. The active viewport keeps the GPU path so its per-viewport
render mode (Hidden Line, Gouraud, …) still applies.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Geometry passes draw with standard `SrcAlpha / 1-SrcAlpha` into a
transparent MSAA target, so AA-edge fragments sit as `(rgb * a, a)` in
the resolve texture. The previous straight-alpha blit then multiplied
those by `a` a second time, darkening thin lines and curves over the
transparent background. `PREMULTIPLIED_ALPHA_BLENDING` matches what is
actually in the resolve texture and renders edges at full intensity
while still leaving fully-transparent pixels untouched on the surface.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
A multi-pane Model view (split / VPORTS 2H|2V|4) used to collapse back
to a single tile after save→reopen — only the *Active VPort entry was
written, the rest of model_tiles was discarded.
Each ModelTile now round-trips through a dedicated `*OCS_Tile_<i>` entry
in the VPort table:
- save_model_tiles_to_vports stashes the live camera into the active
tile, removes any previous tile entries, and writes one VPort per
tile (rect via lower_left/upper_right, camera via
view_target/direction/height); the active tile is mirrored to
`*Active` so apps that only read that entry still get a sensible
view.
- restore_model_tiles_from_vports rebuilds the tile list on file open
and selects the active tile by matching the entry whose view_target
equals `*Active`'s, falling back to index 0.
Single-tile configurations and files from other apps skip the tile
entries entirely — restore returns false and the existing *Active /
View-table path runs, so behaviour for non-tiled files is unchanged.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collapse the paper-space rendering path into the same shader widget the
model layout uses. The PaperCanvas widget draws the paper sheet, paper
entities and viewport borders underneath; the unified shader paints all
content viewports on top, scissored to each viewport's rect.
- Drop PaperViewportPane / PaperViewportPipeline newtype /
PaperViewportPrimitive, ViewportPaneMode::Paper, ViewportPane::paper,
build_primitive and build_viewport_primitive. Scene exposes only
build_viewports.
- view.rs: the paper branch stacks PaperCanvas + the unified shader
instead of the old paper_canvas_view function. The active paper
viewport's blue border, render-mode picker and ViewCube hit-area are
layered in the same viewport_stack as the model layout.
- Transparent shader clear (alpha=0) + alpha-blended blit pipeline so
the underlying widget (container bg in model, PaperCanvas sheet in
paper) shows through everywhere the shader has not painted geometry —
including inside content viewport rectangles.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Route every per-frame interaction through the active model tile's screen
rectangle so a tiled VPORTS layout behaves like independent panes while
still sharing one shader widget:
- pick / draw / snap / box+lasso: cursor mapped to tile-local space; the
hover-activates-tile rule on ViewportMove keeps the active tile under
the cursor, so the picked camera matches what the user sees.
- pan: switched to Camera::pan_screen(dx, dy, viewport_height) so the
world-per-pixel rate matches the active tile's height instead of the
full canvas.
- grid: clipped via Frame::with_clip to the active tile rect; world→screen
adds the tile origin so the lines align with the panel.
- UCS icon: origin offset by the tile rect so the gizmo sits in the
active tile's bottom-left corner.
- render-mode picker (+ split buttons) and ViewCube hit-area: positioned
via active_model_tile_bounds with leading Spaces, mirroring the
floating-viewport pattern.
- ViewCube hover: driven by the CursorMoved/ViewportMove handlers into a
new Scene::viewcube_hover cell, so the highlight survives the cube
hit-area overlay masking events from shader::Program::update.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Model space'de VPORTS artık iki aşamalı: bare VPORTS bir yapılandırma
istiyor (SIngle/2H/2V/4), sonraki komut-satırı girdisi düzeni kuruyor
(boş giriş = SINGLE). set_model_tile_layout normalized rect listesiyle
tiled düzeni değiştiriyor:
- SINGLE: tek tam-ekran
- 2H: üst/alt
- 2V: sol/sağ
- 4: 2x2
awaiting_vports app flag'i prompt sonrası girdiyi yakalıyor. Paper-space
VPORTS davranışı değişmedi.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Tiled Model layout'ta aktif olmayan bir tile'a tıklamak onu aktive edip
kamerasını canlı scene.camera'ya yüklüyor (set_active_model_tile_at).
Böylece her panel bağımsız bir bakış tutuyor — bir panelde orbit/zoom
yaparken diğerleri sabit kalıyor. Aktif tile'a tıklama normal
selection/draw akışına devam ediyor.
Pick/pan/viewcube'un tam tile-relative koordinat yönlendirmesi sıradaki
adımda.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Model layout artık tiled viewport destekliyor. Scene.model_tiles
normalized ekran rect'i + kamera tutan tile listesi; active_viewports
model layout'ta her tile için bir ViewportInstance üretiyor (aktif tile
canlı scene.camera'yı, inaktif tile'lar saklı snapshot'ı kullanıyor).
Render-mode picker'ın yanına iki buton eklendi: ▤ aktif tile'ı yatay
(üst/alt), ▥ dikey (sol/sağ) ikiye böler. split_active_model_tile
bölmeyi yapıyor; her iki yarı aktif kameranın kopyasını alıyor.
set_active_model_tile_at (cursor → aktif tile, kamera swap) ve
reset_model_tiles eklendi ama henüz bağlanmadı — aktif tile cursor
seçimi + pick yönlendirme sonraki adımda.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
build_viewports, active_viewports'un ViewportInstance listesinden
viewport başına ViewportData üretiyor (model: tüm model wire'ları;
paper viewport: layer-freeze'li alt küme). Model space artık
ViewportPane::model -> build_viewports üzerinden birleşik çoklu-viewport
yolundan render ediliyor — şimdilik tek tam-ekran viewport, davranış
birebir aynı.
Paper space hâlâ eski yolda (PaperCanvas + PaperViewportPane); sonraki
adımda birleşik yola taşınacak.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Birleşik viewport mimarisinin yapısal temeli. Primitive artık tek kamera/
geometri yerine viewport başına bir ViewportData listesi taşıyor; yeni
MultiPipeline her viewport için bir iç Pipeline instance tutuyor.
prepare/render viewport listesi üzerinde dönüp her iç-pipeline'ı kendi
(normalized) ekran rect'ine çiziyor.
Mevcut Pipeline kodu (upload/LOD/render/blit) HİÇ değişmedi — sadece
viewport başına bir kez çalışıyor. build_primitive ve
build_viewport_primitive tek-elemanlı liste (FULL_VIEWPORT_RECT)
ürettiği için render davranışı tek-viewport ile birebir aynı; çoklu
viewport sonraki adımda (view.rs tek widget + active_viewports) aktive
edilecek.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Birleşik viewport mimarisinin ilk parçası: tek render geçişinde
çizilecek viewport'ları tanımlayan ViewportInstance (handle, ekran
rect, kamera, render mode, aktif) ve bunları üreten active_viewports.
Model layout tek tam-ekran instance, paper layout her content viewport
entity'si için bir instance döndürüyor. Henüz render'a bağlı değil
(additive); mevcut davranış değişmedi.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>