Skip to content

The FEM gallery live in arigl, and a Demos menu in every demo - #820

Merged
transfix merged 28 commits into
masterfrom
examples/live-gallery
Oct 27, 2026
Merged

transfix merged 28 commits into
masterfrom
examples/live-gallery

Conversation

@transfix

@transfix transfix commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #803 (and #802 under it). GitHub retargets this to master once they merge.

The FEM gallery runs live in the browser: an Ariadne document that you step through item by item. Every demo also opens every other demo from a Demos menu. The .ari demos are one Ariadne app, arigl, which switches between them in place.

Ariadne and arigl

  • Host menus: AppRuntime::set_host_menus puts a host's menus in every document it mounts, and gives a document without a menubar one. AppRuntime::document_menus() marks where the document's own menus go.
    • With a label, they become submenus of one menu, so the menu bar keeps its shape from document to document. That menu is greyed out for a document without menus.
    • Without a label, they stand in the bar as written, and a host menu with the same name adds its items to theirs.
  • An empty stage per document: AppRuntime::load() clears the last document's scene first. The new SceneAdapter::clear() covers nodes, free lights, rigs, physics, and the background, shadows and chrome the document set. A document without channels: drops the last one's channel policy.
  • register_scene_panels: stage_lighting_panel is always registered, so it never draws a rig that left with the previous document.
  • arigl's menu bar: with CVC_ARIGL_GALLERY set to a JSON catalog, it is Demos | Document | Settings for every document, with the document's own menus under Document. Without a catalog, Settings comes after the document's own menus.
    • Settings holds the scene's display settings: shadows, grid, origin axis, bounding boxes and extent labels (a new scene_settings custom widget).
    • A .ari demo picked there loads in place, between frames, and its name goes into the page URL (?doc=).
    • Any other demo opens on its own: its page in the browser, or its program natively, after which arigl closes.
  • cvc::process (core): self_path() and spawn_detached(), native only.

Found trying it in the gallery

  • Sliders follow the drag. A slider writes its key on every change while it is dragged, not only when it is released. commit: release keeps the single write at the end, for a key too costly to redo every frame. Both backends already reported each move; the core now writes it.
  • Windows fit their widgets. A window with no size: fits its widgets every frame, up to the viewport's edge, then scrolls.
    • It used to stay at ImGui's 32 px minimum. The core persisted its geometry after its first, unmeasured frame and seeded that size back, which stopped ImGui's auto-fit. That is why volslice's windows were tiny.
    • Windows with no pos: stack down the left of the viewport, in columns, instead of all opening at ImGui's one default spot. One the user drags leaves the stack.
    • A window with a size: keeps it and scrolls both ways. windows.png is regenerated under Mesa llvmpipe (mesa-dist-win 26.1.7, the build CI pins) for the new horizontal scrollbar in its fixed-size window; the other four goldens still match under it.
  • No forest left behind. forest_trees adds its needles as a second top-level node, which RealizedScene::created did not list. Switching away from lsystem_forest left them in every later demo. realize_scene now records every top-level node a scene's realizers add.
  • The Camera window drives the camera. arigl named its viewer arigl, so camera_controls (bound to viewers.main.camera.*) never reached it. The viewer is main now.

Keys, and arigl in a terminal

  • Arrow keys through SDL3. cvc::gl::SdlInput::attach takes the keyboard of the window VTK made, while VTK keeps every event it had.
    • Windows: SDL wraps the HWND and passes each message on to VTK's window procedure.
    • In the browser: SDL's window is a hidden canvas of its own, and its keyboard element stays the page's window. SDL removes every key listener on its keyboard element, so on VTK's canvas it would take VTK's keys away. An event filter keeps the keys typed into VTK's canvas; otherwise SDL would preventDefault them and swallow the keypress VTK turns into typed text.
    • X11, Wayland and macOS: SDL does not wrap the window. On X11 its XInput2 selection takes VTK's clicks; on Wayland it opens a toplevel of its own; on macOS VTK hands out an NSView. So attach() reads VTK's own key events, renamed as SDL names them: presses below ImGuiOverlay, releases above it, and a held key's presses marked as repeats. $CVC_SDLINPUT_VTK_KEYS=1 forces this path anywhere.
    • SDL's video init leaves the screensaver and the process's DPI awareness alone.
    • arigl attaches it once VTK's window exists, so a document's on_key and keys: work there. It hands the document no key typed into an ImGui field and no click on an ImGui window.
  • Rebindable keys. A document's keys: block names its key actions: a label, default key(s), and on:.
    • Each binding's keys live at keys.<id>. canonical_key matches SDL's and VTK's spellings of a key.
    • AppRuntime puts a Keys window in every document. It lists the document's bindings and the host's (set_host_keys; arigl adds the camera's fly keys). Each row has a Change button that takes the next key down; Escape keeps the old one, and closing the window drops the wait. In the terminal every key goes to it, Tab and Return included.
    • Documents a host loads in turn share its state prefix. A new document's defaults replace an earlier one's at the same keys.<id> (a binding with no key gets none), and they go in before init:, which can set its own. A reload of the same file keeps the keys you chose.
    • canonical_key knows punctuation, shifted punctuation and the keypad in both spellings (, and comma, KP_1 and Keypad 1). The comma key is stored as Comma.
    • arigl's Settings > Keys... opens it, in a window and in the terminal. fem_gallery's arrows are a keys: block now.
    • A group with an id scopes its children's identities, so each row's Change is its own.
    • Each row is a bound text the runtime keeps (tree.ariadne_keys.shown.<id>): the keys, or "press a key..." while its Change waits. So the window evaluates nothing per frame. With show/hide expressions per row, its twenty in fem_gallery exhausted the wasm frame's reactive budget, and the document's own expressions were skipped.
  • iTerm2 inline images in the terminal backend (--graphics iterm). Like Sixel, but each bitmap is a JPEG in an OSC 1337 escape that names its cells, so the terminal scales it. Auto picks it, off Windows and on a tty, when $TERM_PROGRAM names WezTerm, iTerm2 or mintty. A cached bitmap is remade when the terminal's size changes.
  • arigl --terminal in the browser (arigl_term). A wasm target and an xterm.js page derived from ari.html.
    • VTK renders the scene into a hidden #canvas; it is read back and drawn behind the FTXUI widgets. By default the scene is drawn as iTerm2 inline images through xterm.js's image addon (?gfx=iterm), or as half-blocks (?gfx=color / mono), switchable from the page header. ?doc= picks the document.
    • The gallery gets two cards, terminal_scene_term and terminal_tour_term. arigl's Demos menu opens them as pages, and the native catalogs leave them out. build-wasm-demo.sh builds arigl_term beside ari, and deploy-pages checks it is live.
    • The terminal menu bar no longer takes a background picture's colours. Its inverted titles had come out the same colour as their background, so the bar was nearly invisible over a half-block scene.
  • What the terminal can show on Windows. A console program reaches its terminal through ConPTY, and the ConPTY decides what gets through:
    • Windows Terminal 1.24: its ConPTY passes Sixel on. arigl run --terminal --graphics sixel --cell-size 10x19 draws the volume-raycast bunny in real pixels behind the FTXUI windows. Half-blocks work too.
    • WezTerm 20240203: its bundled ConPTY, and Windows' own, drop kitty's APC and Sixel's DCS. They forward an iTerm2 image ahead of the cursor moves they redraw on their own timer, so a full-screen program's images land misplaced and get painted over; a static frame shows them correctly. Half-blocks work.
    • So kitty graphics need a terminal on Linux or macOS, with no ConPTY between program and terminal.

Each document's own layout

  • A new document starts its layout afresh. AppRuntime::load on a switch calls Runtime::forget_layout. Each window's and grid's first frame then ignores the geometry, pane sizes and column widths the last document persisted, and Backend::reset_layout lets the ImGui and FTXUI backends forget their own. Before this, a window keeping an id across documents kept the last document's place.
  • ImGui placement:
    • An authored pos: is measured from the work area, below the main menu bar, from the first frame.
    • Windows with no pos: flow below any window that stands where it is, and a column never starts past the right edge.
    • A split-pane window with no size: fits its panes' widgets; it used to collapse to about 30 px.
  • menus.png: its window moves up under the open File menu, which its text says draws over it (it never did). Regenerated under Mesa llvmpipe.
  • forest_controls: the structural sliders are commit: release, since each regrows the whole forest. Wind stays live.

The FEM gallery as an Ariadne document

  • fe_lab and mesh_lab additions:
    • load a new source at run time;
    • run several requests in order in one key;
    • Neumann eigenmodes (fe_lab) and Laplace–Beltrami eigenmodes (mesh_lab);
    • interval meshes and hexahedra;
    • an elements view: the cutaway, coloured by size or quality, outlined, with a ghost of the cut-away part;
    • the field drawn on a smooth surface (view.boundary);
    • Optimization added to the Improve options.
  • The loader: fit: takes an up axis and flip. Scene nodes know their document's directory, so relative data paths work.
  • examples/ariadne/documents/fem_gallery.ari: the 20 items of docs/FEM_GALLERY.md, data-driven.
    • Step through them from the Gallery menu or the Previous/Next buttons. Its on_key takes the arrow keys too, where the host delivers keys (see Known issues).
    • The fe_controls / mesh_tools windows stay available for changing a solve or mesh.
    • Document arguments: --item N and --tour SECONDS.
  • Data: the head (TexMol head.off, one vertex per line) and the CT (VolRover vh4.rawiv) are in examples/data/fem, about 2.7 MB, with a README on where they come from.

Examples and the web gallery

  • Every C++ demo puts a Demos menu (examples/common/demos_menu.h) first in its main menu bar.
  • examples/common/demos.cmake turns web/demos.json into the menu's table and arigl's catalogs (the build tree's, and share/libcvc-examples/gallery.json installed).
  • The browser gallery:
    • The .ari demos are arigl on their documents: arigl/?doc=<name>. Their old pages redirect there.
    • The per-document ariadne_hello wasm targets are gone; arigl is built into the gallery with every document, the components and examples/data.
    • Every page has a demo picker in its header (which covers the terminal ari pages), and the menus read the deployed list from gallery.js.
    • fem_gallery_ari has a card.
  • Builds:
    • The gallery's wasm build turns the LBIE mesher on. It had been off since the first minimal wasm build, with no recorded reason.
    • deploy-pages and the libcvc-examples-web recipe install eigen, libigl and sdl3 for wasm. eigen and libigl wasm bundles were published to cvcpkg.org for this, for both wasm and wasm-mt.

Verification (Windows, MSVC Release shared, ImageMagick ON, FTXUI + tvision from cvcpkg)

  • Tests: the 528 Ariadne, cvcGL and arigl tests pass.
    • ariadne_runtime_test: host menus, the scene clear, live sliders, key bindings and capture (closing the window, the comma key, a binding named capture), group id scope, the Keys window, each document's own key defaults and layout, and init: over a key default.
    • ariadne_loader_test 185 pass, 1 pre-existing skip: commit:, keys:.
    • ariadne_host_test 17/17: --graphics iterm.
    • ariadne_ftxui_test: live slider drag, commit: release, iTerm2 auto-pick and emission, keys to a waiting capture, an iTerm2 image remade on resize, a new document's windows placed afresh.
    • ariadne_term_graphics_test 18/18: the iTerm2 encoder.
    • New cvcgl_imgui_window_fit (25 checks): windows fit, stack, scroll, flow around a fixed window, stay on screen, split panes fit, a new document relays out, and an authored pos sits below the menu bar.
    • New cvcgl_sdl_attach: a key and a click reach both SDL and VTK; the VTK-key path renames keys and marks repeats.
    • cvcgl_ari_switch, now with a forest; cvcgl_camera, with an SDL-spelled binding; cvcgl_terminal_scene, with kitty, sixel and iterm.
    • Also pass: cvcgl_ariadne_realize, cvcgl_ari_golden (all five goldens under Mesa llvmpipe, windows.png regenerated), cvcgl_imgui_table_columns, and all six arigl_* tests, the terminal ones included now that FTXUI is in.
  • Native arigl, window:
    • A gallery snapshot shows Demos | Document | Settings, and volslice's windows fitted and stacked.
    • Live, in a scratch keys: document, posted Right, Right, Right, Left key messages moved Next/Previous to item 2, through SDL3.
    • The Keys window lists the document's keys and the camera's eight.
  • Native arigl, terminal:
    • Windows Terminal 1.24: half-blocks, and sixel with real pixels (--cell-size 10x19).
    • WezTerm 20240203: half-blocks. iTerm2 images show from a replayed snapshot, not live (ConPTY; see above).
  • Browser (arigl_term): in the browser pane, on a local wasm build.
    • terminal_scene renders through VTK/WebGL, is read back, and draws both as half-blocks and as iTerm2 images at real pixels.
    • Dragging orbits. F10, the menus, the Keys window and clicks work.
    • The menu bar reads clearly over the half-block scene.
    • terminal_tour runs.
  • Browser:
    • A local wasm build of arigl (LBIE included, plus a 2.8 MB arigl.data) and bunny_shadow, assembled with build-pages.py and served locally: the redirects into arigl, the FEM gallery stepping through its items, in-place switching that leaves nothing behind, and the URL and picker following along.
    • On the newest build, in the browser pane: Right, Right, Left stepped the FEM gallery from item 1 to 2. Settings > Keys... opened the Keys window with the document's two bindings and the camera's eight. Change on "Next item" showed "press a key...", N became its key without stepping, and N then stepped to item 3. VTK's own key listener on the canvas is still in place (it handles Tab and letters as before SDL was attached). With the Keys window open in fem_gallery, no reactive expression is skipped for budget; "press a key..." shows on Change, and Escape keeps the old keys.

Known issues (not in this PR)

  • FEM_GALLERY.md pictures: not regenerated here. That waits for fix(LBIE): fitted tet boundaries in any units, a geometric flow that can't wreck tets, and real interval meshes #808.
  • X11, Wayland, macOS: documents get VTK's keys there, not SDL's pointer events.
  • Two terminal tests need a shell FTXUI sees colour in. AriadneStreamView.TheTerminalWidgetDrawsLiveFramesAndAPlaceholder and cvcgl_terminal_scene fail when ctest runs from a process FTXUI detects no colour support in (here, a PowerShell tool host): the half-blocks come out uncoloured. They pass from a normal shell.
  • cvcgl_terminal_scene exits once with 0xc0000409, after printing PASSED, in a build with FTXUI on this box. Ten runs after that all passed. It is a teardown crash, not a failed check, and it is not chased here.
  • arigl_term flickers to the half-block underlay. FTXUI repaints every cell each frame, which deletes the image tiles under them, and the image addon decodes each image asynchronously. So for a moment the scene can show at half-block resolution instead of its real pixels, but never blank. xterm.js 5.5 has no synchronized output to hold the frame.
  • Clicks land too low in a page resized while running (seen in the browser pane). After the pane resized, ImGui took clicks lower than the pointer: up to a row lower in menus, and Next got no response at all. A reload at the new size fixed it. This is in the VTK-in-wasm / ImGui input path, not in this change.

…caled Jacobian is 1

geoframe stores a hexahedron as its six faces, and LBIE winds the second
face against the first (Octree::add_hexa); saveHexa and the optimizer in
octree.cpp read the top corners from it as v5 v4 v7 v6. The geoframe_adapter
read and wrote both faces in plain order, so every hexahedron from
cvc::hexahedralize was twisted (corner k + 4 not over corner k), and
geometry::quality_improve handed LBIE's optimizer twisted hexahedra. The older
convert() path (decode_hexs_from_quads) had it right. The adapter now reads and
writes LBIE's layout: on the bunny at 65^3 the mean scaled Jacobian goes from
~0 to 0.85, with 97-99% of the hexahedra right-handed at every corner.

hex_scaled_jacobian divided the centre Jacobian by the space diagonal cubed, so
a unit cube scored 1/sqrt(27) = 0.024, though its docs say 1 and
filter_hexs_by_quality's default threshold of 0.2 rejected every cube. It is now
the worst corner's determinant of unit edges (the Verdict definition): 1 for a
box, 1/sqrt(5) for a cube sheared by twice its height, -1 for its mirror image.
…s/FEM_GALLERY.md

fem_gallery is a synchronous offscreen CLI: load a surface mesh or a volume,
tet-mesh the solid (SDF_IGL + LBIE, or a CT isovalue), solve Poisson, heat or
Neumann eigenmodes with cvc::fem (or curvature, geodesics and Laplace-Beltrami
modes on the surface), colour the boundary and a planar cut, and write a PNG.
For a surface mesh the solution is sampled onto the input surface, which hides
the tet mesh's grid-aligned boundary. --problem mesh shows LBIE's tetrahedra or
hexahedra themselves, cut away and coloured by element size (octree level) or
quality (minimum dihedral angle, scaled Jacobian); --iso2 and --improve reach
cvc::tetrahedralize2 and LBIE's improvement passes.

docs/FEM_GALLERY.md shows 20 renders (bunny, the TexMol head, the VolRover vh4
CT), and examples/cvcgl/fem_gallery_docs.sh regenerates them. The page lists
what LBIE does not do well yet, so it isn't shown: staircase tet boundaries,
geometric flow on tets, tetrahedralize2's slivers, collapsed adaptive hexahedra
on the head and CT.
… --improve out are fixed by #808

The tetrahedral staircase boundary, geometric flow wrecking tetrahedra, tetrahedralize2's
broken layers and the collapsed hexahedra on the head and the CT are all fixed in #808. The
pictures and element counts here predate it and change once both land.
AppRuntime::set_host_menus puts a host's menus in every document it mounts,
ahead of the document's own (a gallery's Demos menu), and gives a document
without a menubar one. Their menu_action events go to the host's on() handlers.

load() now clears the last document's scene before anything else: a new
SceneAdapter::clear(), which cvcGL's adapter implements as room_view takes a
room down -- the realized nodes and free lights, then the RealizedScene with its
rigs and physics -- and by putting back the background, shadows and chrome the
host had set up. A reload rebuilt every node already, but a switch to another
document kept the first one's nodes, lights and gradient. A document without
channels: also drops the last one's channel policy.

register_scene_panels registers stage_lighting_panel with or without a rig, so
a document loaded after one with a rig doesn't draw the gone rig's panel.
With CVC_ARIGL_GALLERY naming a catalog of demos (JSON), arigl run puts a Demos
menu first in every document's menubar, through AppRuntime's host menus. A demo
there that is a .ari document replaces the running one in the same window,
loaded between frames; any other opens on its own: its page in the browser, its
program natively (cvc::process::spawn_detached beside arigl), and arigl closes.
In the browser the document's name goes into the page URL (?doc=), so a reload
or a shared link opens it again.

cvc::process (core) finds the running program and starts another: what arigl's
menu and the examples' C++ demos need, native only.

In a wasm build with the examples, arigl itself is the browser gallery's Ariadne
app: the documents, the component library and examples/data go into its file
system and it joins wasm-demos.
…the .ari ones

A Demos menu comes first in each demo's main menu bar, over the gallery's list
(web/demos.json, made into a C table and arigl's catalogs by
common/demos.cmake). In the browser it lists what the gallery deployed (each
page's gallery.js) and goes to that demo's page; natively it starts the demo's
program beside this one -- an .ari demo is arigl on its document, with the
catalog so it has the menu too -- and the demo closes.

The browser gallery's .ari demos are now arigl, its one Ariadne app, opened on
each document (arigl/?doc=<name>) and switched in place from arigl's Demos menu.
demos.json marks them with "app"/"doc"; build-pages.py lists them when arigl was
built, redirects their old pages there, boots arigl from its "boot" entry
(command line, environment, files fetched before main), and writes gallery.json
and gallery.js. Every canvas page also gets a demo picker in its header. The
per-document ariadne_hello wasm targets are gone, and fem_gallery_ari joins the
list.

The gallery's wasm build turns the LBIE mesher on, and deploy-pages installs the
eigen and libigl wasm bundles, so the FEM gallery's fe_lab and mesh_lab nodes
exist in the browser.
The recipe and deploy-pages install them for wasm: SDL3 carries the documents' keys and pointer (cvcGL's SdlInput), and eigen + libigl are what the FEM gallery's fe_lab and mesh_lab nodes run on.
…in-place switch

build-pages.py keeps a "card": false page (arigl's) out of gallery.json and gallery.js, since arigl is in the menus as its documents. When arigl loads a document in place it also selects it in the page's demo picker, not only in the URL.
… nodes know their document's directory

fit: { up: x } turns the cyclic x -> z, and flip: true then turns the dataset upside down (a
half turn about x, for a scan stored head down), before the existing centre / ground / scale.
fit_to_ground, sdf_volume_from_mesh and the geometry nodes take the new form; turn_up and
turn_up_point expose the rotation alone, and sdf_volume_of_mesh the SDF of a mesh in hand.

The loader stamps every scene node with its document's directory (SceneNode::base_dir, empty
for a string), so a custom node can resolve a relative path the way an import: does. The
built-in nodes' source: { file } still resolves against the working directory.
…odes, mesh intervals and hexahedra, and show the elements

Both nodes:
- source.* keys (seeded from source: and fit:) and a `load` request that reads them again on
  the node's lane, only when one changed; `reload` always does. A relative path resolves
  against the document's directory, then the working directory; stanford.bunny stays built in.
- A request may chain commands separated by spaces ("load smooth", "stop load"), each run after
  the job before it.
- stats.work_ms: the wall time of the last run of commands.

mesh_lab: color.mode modes (a Laplace-Beltrami eigenfunction, modes.index, eigenpairs cached
per mesh) and geodesic.source -1 (the highest vertex). A load that finds its source unchanged
goes back to the loaded mesh and keeps the caches.

fe_lab:
- source.type sdf | volume, source.file, source.dim (the SDF's grid, or a volume's resample),
  source.algorithm, source.up / flip / height. An SDF is taken in the mesh's own units and fit:
  places the elements, as for a volume: LBIE refines by an error in value units, so an SDF
  scaled to the fit height refined a small model everywhere (the bunny at 48^3 gave 244,125
  hexahedra; now 12,822, as fem_gallery does).
- auto.mesh / auto.solve keys: a load re-meshes only when the source or a mesh.* key changed,
  else re-solves.
- problem modes (fem::laplacian_eigenmodes on the volume, modes.index, cached per mesh).
- mesh.interval + mesh.isovalue2 (tetrahedralize2, the upper isovalue first in the negated
  space of an inside-below volume) and mesh.elements tet | hex. A solve refuses hexahedra.
- view.mode elements: the elements on one side of the cut (view.cut_side), whole and flat-
  coloured by size or quality, outlined by <id>_edges, with <id>_ghost at view.ghost opacity;
  view.fixed_range / range_min / range_max in both views. stats.hexes and quality min / mean.
- view.boundary input: the field drawn on the surface the elements approximate (an SDF's
  mesh, or the volume's isosurface) instead of their staircase boundary.

fe_controls offers all of it, Optimization (5) among the improvements; mesh_tools the source
and the eigenfunction mode. cvcgl_ariadne_realize covers source switching, chaining, both
eigenmode kinds, intervals, hexahedra and the elements view.
… document

The twenty items of docs/FEM_GALLERY.md, computed in the scene one at a time by one fe_lab and
one mesh_lab node. init: writes the item table into state (each item's title, description, node
keys and starting request); on_tick applies the selected one (state-json / state-from-json onto
the nodes, the item's camera onto every viewer), and mirrors the node's status and timing. Step
with the Gallery menu, the Previous / Next buttons, or Left / Right and PageUp / PageDown where
the host passes keys; the Windows menu opens the component panels. Arguments: --item N, --data
DIR (default ../../data/fem, relative to the document) and --tour S.

examples/data/fem holds the head (TexMol's LBIE_lib/head.off, one vertex per line) and the CT
(VolRover's SimpleExample/vh4.rawiv), with a README on where they come from.

ARIADNE.md §5.4 documents the new keys and §6.5 the document; FEM_GALLERY.md points at it.
…e the scene is realized

Realizing an fe_lab with source: { sdf } used to compute the SDF on the render thread before
the document showed: about 3 s for the bunny at 48^3 with the igl algorithm, a frozen start in a
single-threaded browser build. Now the realizer reads only the mesh (the bounds the camera frames
are its padded box, placed by fit:), and the first tick computes the field as a `load` on the
node's lane, reading the source.* keys -- so a document whose init: or first on_tick picks
another source (fem_gallery.ari --item 10) never computes the node's own. Requests wait for it,
status says loading; a build without CVC_ENABLE_SDF still refuses the node at realize.
Four of its items (the bunny's first vibration mode, heat in the CT body, LBIE's hexahedra by size, the head's mean curvature), from docs/img/fem-gallery.
Emscripten won't mix --preload-file with --embed-file, and the datasets are too big to embed
in the module. Also clang-format the lines this branch changed, leaving demos_menu's JavaScript
body alone.
… across documents

- A slider writes its key on every change while it is dragged, so what it drives follows it.
  `commit: release` keeps the old single write at the end of the drag, for a key too costly to
  redo every frame. Both backends already reported each move; the core now writes it.
- AppRuntime::document_menus() marks where a host's menu bar puts the document's own menus.
  Given a label, one menu of that name holds them as submenus, so the bar keeps its shape from
  one document to the next (the menu is greyed out for a document without menus). Without one,
  they stand in the bar as written, and a host menu with the same name adds its items to theirs.
- arigl: with a gallery the bar is Demos | Document | Settings for every document; without one,
  Settings follows the document's own menus. Settings is the scene's display settings (shadows,
  grid, origin axis, bounding boxes, extent labels), from a new scene_settings custom widget.
- arigl's viewer is "main", so the shared camera_controls component (viewers.main.camera.*)
  reaches its camera.
- A window with no size: fits its widgets every frame, up to the viewport's edge, past which it
  scrolls. It used to stay at ImGui's 32 px minimum: the core persisted its geometry after its
  first, unmeasured frame and seeded that size back, which stopped ImGui's auto-fit.
- Windows with no pos: and nothing persisted stack down the left of the viewport, in columns,
  instead of all opening at ImGui's one default spot; one the user drags leaves the stack.
- A window with a size: keeps it and gets a horizontal scrollbar as well as the vertical one.
  windows.png is regenerated under Mesa llvmpipe for its fixed-size window's new scrollbar (the
  other goldens still match under it).
- cvcgl_imgui_window_fit covers all three on a bare ImGui context.
forest_trees adds its needles as a second top-level node, which RealizedScene::created did not
list, so a host loading another document (arigl's Demos menu) left the trees' needles behind.
realize_scene now records every top-level node the scene's realizers added.
…ery document

- cvc::gl::SdlInput::attach wraps the window VTK made, so SDL delivers its keys and pointer:
  natively the HWND (or X11 window), whose messages SDL passes on to VTK's procedure; in the
  browser a hidden canvas of SDL's own, with its key listeners on VTK's canvas and an event
  filter that keeps the keys (SDL would otherwise preventDefault them and swallow the keypress
  VTK turns into typed text). arigl attaches it once VTK's window exists, so a document's
  on_key and keys: work there. cvcgl_sdl_attach checks a Left arrow reaches both SDL and VTK.
- A document's `keys:` block names rebindable actions (label, default key(s), on:). Each
  binding's keys live at keys.<id>; Runtime::post_input runs the `on:` of a binding a key down
  matches, in the next drain. canonical_key matches SDL's and VTK's spellings of a key.
- AppRuntime puts a Keys window (closed until tree.ariadne_keys.open) in every document: a row
  per binding, the document's and the host's (set_host_keys), with a Change button that takes
  the next key down (Escape keeps the old one). A group with an id now scopes its children's
  identities, so each row's button is its own.
- arigl's Settings menu opens it, in a window and in the terminal, and the camera's fly keys
  are host bindings; the camera now matches its keys canonically and defaults to SDL's names.
- fem_gallery's arrow keys are a keys: block. FTXUI draws a bound text with no label as just its
  value, as ImGui does.
`--graphics iterm` (FtxuiBackend::Options::ImageColor::Iterm) draws pixel images as iTerm2 inline
images: like Sixel, a bitmap per rectangle of uncovered cells over the half-block underlay,
re-sent after each repaint, but a JPEG in an OSC 1337 escape that names its cells, so the
terminal scales it and the cell size need not be known. WezTerm, iTerm2, mintty and xterm.js's
image addon show them. `Auto` picks it, after kitty and Sixel, when $TERM_PROGRAM names such a
terminal; TerminalScene renders the scene at the cells' pixels for it, and arigl/ari info report
it. The JPEG comes from stb_image_write, compiled into term_graphics as its own static copy.

On Windows a console program reaches its terminal through ConPTY. Windows Terminal's (1.22 and
later) passes Sixel on, and arigl draws real pixels there with --graphics sixel --cell-size WxH.
The ConPTY WezTerm 20240203 bundles, and Windows' own, drop kitty's APC and Sixel's DCS and forward
an iTerm2 image ahead of the cursor moves they redraw on their own, so a full-screen program's
images land misplaced and get painted over: kitty graphics need a terminal on Linux or macOS.
ARIADNE.md says so.
…s through its program

cvcgl_sdl_attach also sends a click: SDL reports it and VTK's interactor (ImGui's input) still
gets it. The Keys window test clicks Change, so keys.capture is set by the button's own program,
and the next key down becomes the binding's key.
Keys
- The Keys window's capture lives at tree.ariadne_keys.capture (beside its open state), so a
  document binding named `capture` is its own. A capture counts only while the window is open;
  closing it drops one still waiting.
- The comma key is stored as "Comma" (a comma separates stored keys), a document's "," default
  too, and a key with no name keeps the capture waiting.
- canonical_key matches SDL's and VTK's punctuation, shifted punctuation and keypad names (","
  and "comma", "+" and "plus", "'" and "quoteright", "Keypad 1" and "KP_1", "_", Numlock,
  Print).
- Documents a host loads in turn share its prefix: a new document's keys: defaults replace an
  earlier one's for the same id ("" for a binding with no key), where a reload of the same file
  keeps the user's keys. The defaults go in before init:, which can set its own.
- In the terminal, while the Keys window waits, every key goes to the capture
  (FtxuiBackend::route, now what run_loop does with each event, and the tvision desktop's host),
  Tab and Return included.

Window layout
- A new document starts its layout afresh: Runtime::forget_layout (AppRuntime::load on a
  switch) makes each window's and grid's first frame ignore the geometry, pane sizes and column
  widths the last document persisted, and Backend::reset_layout lets the ImGui and FTXUI
  backends forget their own.
- ImGuiBackend: an authored pos is in the work area, below a main menu bar, from the first frame
  (the bar drawn earlier this frame counts); flowing windows go below a window that stands where
  it is (told apart by ImGui id, not by name; nothing is in the way on a new document's first
  frame, and ImGui's own windows never are), and a column never starts past the right edge; a
  split-pane window with no size gets panes that fit their widgets, so the window does (it
  collapsed to ~30 px).
- The menus golden's window moves up under the open File menu, which its text says draws over
  it (it never did); menus.png regenerated under llvmpipe.
- forest_controls' structural sliders are commit: release: each would regrow the whole forest
  every frame of a drag.

SDL input
- SdlInput wraps VTK's window only on Windows (and listens on the page in the browser). On X11
  SDL's XInput2 selection takes VTK's clicks, and on Wayland it makes a window of its own, so
  there (and on macOS, without SDL, or with $CVC_SDLINPUT_VTK_KEYS=1) attach() observes VTK's
  key events instead: presses below ImGuiOverlay, releases above it, named as SDL names them,
  and a held key's presses (X11's release+press pairs too) marked as repeats.
- SDL video init no longer blocks display sleep or changes the process's DPI awareness (unless
  the app set those hints).
- arigl hands the document no key typed into an ImGui field and no click on an ImGui window.

Also: the iTerm2 probe is POSIX and needs a tty, VS Code's terminal is not assumed to show
images, a cached iTerm/Sixel bitmap is remade when its raster or cells change, and
ariadne_host_test.cpp is LF again.
…nu bar keeps its colours

Found running the wasm gallery:

- With the Keys window open in fem_gallery, its rows' show/hide expressions (two per binding,
  twenty there) exhausted the per-frame reactive budget, and the document's own expressions were
  skipped. Each row is a bound text now, tree.ariadne_keys.shown.<id>: the binding's keys, or
  "press a key..." while its Change waits. The runtime keeps it each drain, writing only what
  changed.
- In the terminal, the menu bar over a picture behind the widgets took the picture's colours:
  its inverted titles came out the same colour as their background, so the bar was nearly
  invisible over a half-block scene. The bar clears the cells under it first.
…widgets

arigl's terminal mode as a wasm page, beside ari's:

- src/arigl/CMakeLists.txt: an arigl_term target (built by name, where FTXUI is found), the
  documents, the terminal tour and the components preloaded as for arigl (no datasets),
  -sEXIT_RUNTIME and FTXUI's resize hook exported as for ari, and cvcGL's WebGL state shim off
  (it would patch xterm.js's renderer's context too).
- src/arigl/web/arigl_term.html, from ari.html: an xterm.js terminal with the image addon
  (iTerm2 inline images; Sixel off), VTK's hidden #canvas, the document and drawing from the URL
  (?doc=documents/terminal_scene, ?gfx=iterm|color|mono, switchable from the header), and one
  terminal write per animation frame, so a frame's text and the images after it go together.
- main(): opened without a command line it runs terminal_scene, and it is always in the
  terminal.
- The gallery: two cards, terminal_scene_term and terminal_tour_term, open arigl_term on their
  documents (with thumbnails). build-pages.py gives gallery.json a document to load in place only
  for arigl, so arigl's Demos menu opens these as pages; demos.cmake leaves them out of the native
  catalogs. build-wasm-demo.sh builds arigl_term beside ari, and deploy-pages checks it is live.

In the browser pane: terminal_scene renders through VTK/WebGL, is read back and drawn as
half-blocks and as iTerm2 images at real pixels; dragging orbits; F10, the menus, the Keys
window and clicks work; terminal_tour runs. FTXUI repaints every cell each frame and the addon
decodes images asynchronously, so the picture can flicker to its half-block underlay (ARIADNE.md).
#802 (its base) landed on master as a squash; this merges master on the branch's real base, fc9220a, so #803 carries only its own changes.
…s/live-gallery

Conflicts: src/cvc/CMakeLists.txt (master's new conference and physics sources, plus this branch's ariadne/keys.cpp) and src/cvcGL/CameraController.cpp (both includes).
#827 (tf_editor) and this branch both rework fe_lab. fe_lab keeps #827's mesh.region
(solid | interval), its interval props and tetrahedralize_interval; this branch's mesh.interval
flag becomes region interval (fe_controls' Mesh region combo, fem_gallery.ari, the realize test,
ARIADNE.md). Everything else here stays: hex elements, source loading, placement, quality stats.

fe_lab now loads its volume on its lane, so the transfer-function binding follows each load
(tf_binding_options::volume_source): until a volume arrives there is no range or overlay and no
bound key is written; on a new range the followed bars move to the keys' values, which are never
rewritten for it, and nothing re-meshes. mesh.isovalue2's default waits for an SDF's range.
cvcgl_tf_binding checks this with an SDF source loaded after realize and then reloaded.

docs/FEM_GALLERY.md: #803 landed as a squash of this branch's base, so this branch's version
(#803's plus its own edits) is kept.
@transfix
transfix changed the base branch from examples/fem-gallery to master October 27, 2026 05:25
@transfix
transfix merged commit aac8f76 into master Oct 27, 2026
23 of 24 checks passed
transfix added a commit that referenced this pull request Oct 27, 2026
…ges (#840)

Since #820 the _ari demos are documents opened in arigl (demos.json app + doc): build-pages.py
writes each one a redirect page and no .wasm. The gallery check still wanted <demo>.wasm, so the
v3.7.1 publish failed after libcvc and cvcgl were already up, with no libcvc-examples-web package.
Check the binary demos (now with arigl) for their module and the document demos for their
redirect to arigl.
transfix added a commit that referenced this pull request Oct 28, 2026
Master's #820 landed its own window fitting in the ImGui backend: a window with no size: fits its
widgets every frame and takes no size from its persisted geometry, windows with no pos: stack down
the left of the work area around the windows that stand where they are, a sized window scrolls both
ways, and an authored pos: is measured from below the menu bar. That replaces this branch's ImGui
sizing (fit once, report no geometry while fitting, its own flow cursor), so ImGuiBackend.h/.cpp
and cvcgl_imgui_window_fit.cpp are master's, and backend.h's contract and the roadmap's §11.4 text
are master's again. The runtime test of the dropped contract (a fitting window's geometry is not
persisted) goes with it.

What this branch still adds on top:

- The core's built-in Windows menu (ARIADNE.md §5.9), and tree.<id>.open honoured by every window.
  A host's menus count as the document's, so arigl's Settings > Keys... keeps the Keys window out
  of it; under a host without such a menu the Windows menu is how the Keys window opens. A menu
  already in the bar with the Windows menu's title, like fem_gallery.ari's own Windows menu, now
  takes the built-in items after a separator instead of a second menu of the same name in the bar.
- The FTXUI backend stops an unsized window at the screen's edge and scrolls a body that does not
  fit.
- In a sized ImGui window a combo or colour widget reserves room for its label, like a slider or
  an input.

The loader takes both master's keys: and this branch's windows_menu: (block, schema, widget type).
ARIADNE.md §5.8 describes master's ImGui sizing; §5.9 gains the host-menu and same-title rules. The
duplicate cvcgl_imgui_window_fit target from the merge is gone. cvcgl_imgui_windows_menu also checks
that a reopened window takes its place in the column without landing on another, and that a window
stands below the menu bar the Windows menu brings. New runtime tests cover the same-title merge and
host menus.

menus.png and windows.png are master's here. Both documents now draw the Windows menu (menus.ari
after Help; windows.ari, whose closable window gives it a bar, with every window below that bar),
so both goldens need regenerating under llvmpipe.
@transfix
transfix deleted the examples/live-gallery branch October 29, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant