Skip to content

tf_editor: few colour bars for colormaps, a hover readout, honest FEM overlays - #878

Merged
transfix merged 1 commit into
masterfrom
fix/tf-editor-fem-colours
Oct 29, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/tf-editor-fem-colours

Conversation

@transfix

Copy link
Copy Markdown
Owner

Usability fixes for the transfer-function editor (tf_editor), mostly as the FEM demos use it.

Too many colour bars. mesh_lab and fe_lab seeded each named colormap as 33 colour nodes. A colour bar can be grabbed anywhere along the canvas height within about 5 px, so 33 bars about 9 px apart left no empty canvas: every hover and double-click hit a bar, which made recolouring or moving bars awkward. colormap_model now samples the colormap at 256 points and thins it with the new cvc::tf::simplify_ramp. The result keeps the nodes that follow the colormap within 0.02 per channel, at most 12.

colormap nodes max error
viridis 9 0.019
magma 10 0.015
plasma 9 0.020
inferno 12 0.020
turbo 12 0.048
jet 6 0.012
parula 12 0.027
gray 2 0

Hover readout and tooltips.

  • Over empty canvas, the histogram bin under the pointer lights up at once.
  • Once the pointer settles, a readout follows it with:
    • the value;
    • the bin's range, count and share of all values;
    • the contour spectrum's area, min/max volume and gradient, and the contour tree's component count (each while that layer is shown);
    • a reminder of what a double-click and the right-click menu do.
  • The right-click menu's Add and Display items explain themselves on hover.
  • Nodes, bars and the zoom bars already had their own tooltips.

Contour spectrum and contour tree on mesh fields. These are computed for volumes only (tf_binding). On a mesh_lab or fe_lab field, the Display toggles used to do nothing. A request for them now gets <tf>.overlay_status = "unavailable: ... this field is on a mesh", which the editor shows under the canvas. On volumes (volren, volslice, the VTK volume node) they work as before.

Right-click in the browser. examples/web/templates/demo.html.in did not prevent the browser's own context menu on the canvas (checked on the live arigl page: defaultPrevented was false). The browser menu covered the editor's menu, or took the button release the editor's menu opens on. The canvas now calls preventDefault() on contextmenu.

Tests (Windows, MSVC):

  • cvcgl_tf_editor covers:
    • the lit bin and the readout's bin, count, spectrum and component lines;
    • that the readout waits for the pointer to settle;
    • a handle's own tooltip taking over;
    • the readout with the histogram hidden;
    • simplify_ramp (knot recovery, the node cap, two-node input).
  • cvcgl_ariadne_realize checks, for mesh_lab and fe_lab:
    • each of the eight colormaps' node count and error against colormap_rgb;
    • the overlay-request note, and that it survives a republish.
  • cvcgl_tf_editor, cvcgl_ariadne_realize, cvcgl_tf_binding and cvcgl_fe_interval all pass.

Visual check: arigl snapshots showed:

  • turbo and viridis Colours editors with 12 and 9 bars;
  • the volume editor drawing the histogram, the spectrum curves and the contour tree.

The readout and the browser right-click were not checked by hand in a browser. The wasm build happens in CI and the gallery deploy.

Docs: docs/TRANSFER_FUNCTIONS.md §4 (the hover readout and the browser right-click) and §6 (the thinned ramps and the mesh-field overlay note).

… overlays

The FEM / mesh_lab field colours seeded each named colormap as 33 colour
nodes. A colour bar is grabbed across the canvas height within about 5 px,
so 33 bars about 9 px apart left no empty canvas: every hover and
double-click hit a bar. The colormap is now sampled at 256 points and thinned
by the new cvc::tf::simplify_ramp to the nodes that follow it within 0.02
per channel, at most 12 (viridis 9, jet 6, gray 2; turbo keeps 12, within
0.05).

The ImGui editor lights the histogram bin under the pointer over empty
canvas and, once the pointer settles, shows a readout: the value, the bin's
range, count and share, the contour spectrum's values and the contour
tree's components (each while shown), and what a double-click and the
right-click menu do. The menu's Add and Display items explain themselves on
hover.

The contour spectrum and contour tree are computed for volumes only. A
mesh_lab / fe_lab field now answers a request for them with
"unavailable: ... this field is on a mesh" in <tf>.overlay_status, where the
toggle used to do nothing.

The wasm demo page lets the canvas keep right-clicks: it did not prevent the
browser's context menu, which covered the editor's menu or took the release
it opens on.
@transfix
transfix merged commit f715017 into master Oct 29, 2026
26 checks passed
@transfix
transfix deleted the fix/tf-editor-fem-colours branch October 29, 2026 23:01
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