Table of Contents

Mat4dControl Component

Mat4dControl edits and displays a 4x4 transform matrix. It is an embedded widget with no route and no Control-Tree node of its own, reached only through the editor that hosts it.

Key Model

The persisted model is Mat4d, exposed over /api/Mat4d by Widget/Mat4dController.cs.

The widget's own model is a plain array of sixteen numbers, exported as type Mat4 from wwwroot-src/src/components/widgets/Mat4Input.vue. The layout is column-major, matching the backend Mat4d: cell (row, col) resolves to index col * 4 + row, so indices 0 to 3 are the first column and 12 to 15 the translation column. wwwroot-src/src/api/transformer.ts states the same column-major contract on the wire. A model shorter than sixteen numbers, or not an array at all, is padded out with zeros before display, and a longer one is truncated to sixteen.

The widget carries no key and calls no endpoint. Its host, wwwroot-src/src/components/topo/StaticFreeformEditor.vue, binds it with v-model and persists each change through updateStaticFreeformMat from wwwroot-src/src/api/transformer.ts, which posts the whole sixteen-number array to /api/StaticFreeform/Update; Mech/Topo/StaticFreeformController.cs rejects a payload that is not exactly sixteen elements.

The props are modelValue, disable, readonly, identity (on by default) and invert (off by default), and the emits are update:modelValue, identity and invert. disable both disables the cells and dims the whole block.

Layout

  • Mat4dControl
    • Matrix Grid — four rows of four numeric cells, each cell right-aligned
    • Identity Button — present when the identity flag is set, which is the default
    • Invert Button — present only when the invert flag is set

The cells and both buttons are inactive while the control is disabled or readonly.

Feature

Single input mode

The grid of sixteen cells is the only editing surface, and each cell shows the full precision of its number with no rounding for display.

Matrix operations

  • Identity — the button raises an identity event and writes nothing itself; the host supplies the matrix. StaticFreeformEditor pushes its own identity constant through updateStaticFreeformMat.
  • Invert — the button raises an invert event and computes nothing itself. StaticFreeformEditor calls invertStaticFreeformMat, which posts to /api/StaticFreeform/InvertMat and feeds the sixteen numbers that come back into the model.

Commit and special values

Each cell commits on blur or Enter, and the widget emits the entire sixteen-number array rather than a single index. An unparseable cell reverts to its previous value, an empty cell becomes 0, and a cell whose parsed value is unchanged emits nothing. Formatting and parsing are local to the component: Infinity and -Infinity are shown and parsed as literal text, while NaN and a missing cell both display as 0, so NaN is not round-tripped.

Source Code Path

See HiNC App Anatomy for git repository links.

  • wwwroot-src/src/components/widgets/Mat4Input.vue — the widget itself: the column-major sixteen-cell grid, the Identity and Invert buttons, and the local format, parse and commit helpers
  • wwwroot-src/src/components/topo/StaticFreeformEditor.vue — the host, and the full binding contract in one place: v-model, the two button flags, @update:model-value, @identity, @invert
  • wwwroot-src/src/api/transformer.tsupdateStaticFreeformMat and invertStaticFreeformMat
  • Mech/Topo/StaticFreeformController.cs — the backend behind those two endpoints: Update takes a sixteen-element array, InvertMat returns the inverted sixteen numbers
  • Widget/Mat4dController.cs — the /api/Mat4d REST surface: New, NewWithValue, Get, Update, UpdateAt, ParseAndUpdate, SetIdentity, Transpose and Inverse. The SPA reaches none of them; the widget's host persists through the StaticFreeform endpoints instead.
  • wwwroot-src/src/i18n/en/widgets.ts — the Invert label and both button tooltips under widgets.matInput

See Also

  • Vec3dControl Component — the sibling numeric-geometry editor, and the one a reader usually wants next
  • Numeric Input/Output — why NaN and the infinities are text on the wire, and why NaN does not survive this grid