Editors
Handles for the StdMultiWidget and MxN render-window editors, including the
typed MxN layout surface. Workbench.std_multi and Workbench.mxn return
the editor handles below; every state read goes to the network.
Shared handles
Editor and render-window primitives shared by all editor types.
- Public types:
WindowKind, ViewDirection, StandardView, EditorAlias — vocabulary. EditorDescriptor, EditorInfo — discovery payloads. WindowSummary, MxNWindowSummary — per-window summaries. Camera — camera GET + PUT body. SliceBounds, SelectedSlice — per-window slice state. EditorBase, RenderWindow — base classes for editors.
- class mitk_workbench_remote.editors._base.WindowKind(*values)
-
Render-window kind (drives which sub-resources apply).
- TWO_D = '2d'
- THREE_D = '3d'
- class mitk_workbench_remote.editors._base.ViewDirection(*values)
-
Anatomical plane / view direction.
Mirrors
mitk.mxn.layout.ViewDirectionvalue-for-value so that the editors module remains usable without the optionalmitkpackage installed.- AXIAL = 'axial'
- SAGITTAL = 'sagittal'
- CORONAL = 'coronal'
- ORIGINAL = 'original'
- class mitk_workbench_remote.editors._base.StandardView(*values)
-
Standard camera orientations accepted by the camera PUT endpoint.
- ANTERIOR = 'anterior'
- POSTERIOR = 'posterior'
- LEFT = 'left'
- RIGHT = 'right'
- CRANIAL = 'cranial'
- CAUDAL = 'caudal'
- class mitk_workbench_remote.editors._base.EditorAlias(*values)
-
Stable short aliases for the built-in MITK editors.
- STD_MULTI = 'stdmulti'
- MXN = 'mxn'
- class mitk_workbench_remote.editors._base.EditorDescriptor(alias, plugin_id, active)
Bases:
objectEditor list entry returned by
GET /rendering/editors.- Variables:
alias – Stable short alias used in URL paths.
plugin_id – Berry editor plugin id.
active – True if an editor instance is currently open.
- class mitk_workbench_remote.editors._base.EditorInfo(alias, plugin_id, active, windows)
Bases:
objectEditor metadata returned by
GET /rendering/editors/{alias}.- Variables:
alias – Stable short alias used in URL paths.
plugin_id – Berry editor plugin id.
active – True if an editor instance is currently open.
windows – Current window identifiers (URL segments for sub-resources). Empty when the editor is inactive.
- class mitk_workbench_remote.editors._base.WindowSummary(id, kind, view_direction, has_camera, has_selected_slice)
Bases:
objectPer-window summary common to every editor type.
The contract guarantees
view_directionis present iffkind == WindowKind.TWO_D; the StdMulti 3D window omits it.- Variables:
id – Render window id (URL segment for sub-resources).
kind – Window kind (2D vs. 3D).
view_direction – Anatomical plane the slot renders.
Nonefor 3D.has_camera – Whether the camera sub-resource applies.
has_selected_slice – Whether the selected-slice sub-resource applies.
- kind: WindowKind
- view_direction: ViewDirection | None
- class mitk_workbench_remote.editors._base.MxNWindowSummary(id, kind, view_direction, has_camera, has_selected_slice, display_name, links, has_selected_position)
Bases:
WindowSummaryMxN cell summary — extends
WindowSummarywith layout fields.- Variables:
display_name – Optional human-readable label from the layout document.
Nonewhen the cell has no display name.links – Per-cell synchronisation links from the layout document (at minimum
{"selection": <group>}under v2).has_selected_position – Always True under v2 (per-cell selected position is a v2 capability, distinct from the global resource).
- class mitk_workbench_remote.editors._base.SliceBounds(steps, min_position, max_position)
Bases:
objectBounds of a slice navigator.
- Variables:
steps – Total step count.
min_position – World position of the first slice.
Nonewhen no geometry is loaded.max_position – World position of the last slice.
Nonewhen no geometry is loaded.
- class mitk_workbench_remote.editors._base.SelectedSlice(step, position, bounds)
Bases:
objectSelected-slice state for a 2D window.
- Variables:
step – Current step index.
position – World position on the live slice plane.
bounds – Navigator bounds.
- bounds: SliceBounds
- class mitk_workbench_remote.editors._base.Camera(kind=None, position=None, focal_point=None, view_up=None, parallel_scale=None, perspective_angle=None, standard_view=None)
Bases:
objectRender-window camera state.
Used both as a GET response (full state, with
kindset and the irrelevant axis nulled out) and as a PUT body (any subset of fields;Nonefields are omitted from the wire payload). 2D windows carryparallel_scale; the 3D window carriesperspective_angle.kindis local-only metadata: the contract response carries nokindfield.RenderWindow.get_camera()populates it from the surrounding window’s known kind.- Variables:
kind – Local-only window kind label; ignored on PUT.
position – Camera origin in world coordinates.
focal_point – Point the camera looks at, in world coordinates.
view_up – View-up vector in world coordinates.
parallel_scale – Orthographic zoom (2D windows only).
perspective_angle – Vertical FOV in degrees (3D window only).
standard_view – Symbolic camera orientation. Cannot be combined with explicit pose fields (
position/focal_point/view_up) on PUT — server rejects with 400.
- kind: WindowKind | None = None
- standard_view: StandardView | str | None = None
- diff(other)
Return a Camera carrying only fields that differ from
other.kindis preserved fromself(it is local metadata, never diffed). A field is “different” iff it is non-Noneonselfand not equal to the value onother. Whenself.kindis set, the scalar that does not apply to that kind (perspective_anglefor 2D,parallel_scalefor 3D) is dropped from the result soto_payload()cannot produce a body the server rejects.- Return type:
- class mitk_workbench_remote.editors._base.EditorBase(transport)
Bases:
objectCommon behaviour for editor handles.
Subclasses set the
ALIASclass variable to the editor’s URL alias (e.g."stdmulti"or"mxn"). Editor handles hold only the transport — every state read goes to the network.- get_info()
Fetch the editor’s metadata (always live).
Returns a degraded
EditorInfowithactive=Falseand emptywindowswhen the editor exists but no instance is open (server signalsEDITOR_NOT_ACTIVE). A missing Qt render-window bridge (RENDER_WINDOW_NOT_AVAILABLE) is a deployment-level problem and still surfaces asRenderingError.- Return type:
- screenshot(*, fmt=ScreenshotFormat.PNG, width=None, height=None, path=None)
Capture a screenshot of the editor canvas.
- Parameters:
fmt (
ScreenshotFormat|str(default:<ScreenshotFormat.PNG: 'png'>)) – Image encoding format ("png"or"jpeg").width (
int|None(default:None)) – Output width in pixels. Must be given together withheight.height (
int|None(default:None)) – Output height in pixels. Must be given together withwidth.path (
str|Path|None(default:None)) – If given, save the screenshot to this file path.
- Return type:
- Returns:
Raw image bytes.
- list_windows()
List the editor’s render windows. Always live.
- Return type:
- get_window(window_id)
Get a render-window handle by its id (no network call).
- Return type:
- class mitk_workbench_remote.editors._base.RenderWindow(transport, editor_alias, window_id, *, kind=None)
Bases:
objectHandle to a single render window of an editor.
- Parameters:
transport (
RestTransport) – Configured REST transport.editor_alias (
str) – Editor alias the window belongs to.window_id (
str) – Render-window id (URL segment).kind (
WindowKind|None(default:None)) – Optional eagerWindowKindpopulated by the editor’s window listing. Cached because the kind of a window is an immutable identity field. Falls back to a network call whenNone.
Note
view_directionis intentionally NOT cached: MxN cells can be re-bound to a different anatomical plane at runtime. Readingview_directionalways issues a freshGETagainst the per-window summary so callers see the live server state.- property kind: WindowKind
Window kind. Immutable identity field — cached after first resolution. Resolved via
GET .../windows/{id}on first access when not pre-populated by the editor’s window listing.
- property view_direction: ViewDirection | None
View direction.
Nonefor 3D windows. Always live — MxN cells can be re-bound to a different anatomical plane at runtime, so this is not cached.
- get_summary()
Fetch the per-window summary from the server (always live).
- Return type:
- screenshot(*, fmt=ScreenshotFormat.PNG, width=None, height=None, path=None)
Capture a screenshot of this single render window.
- Return type:
- set_camera(camera=None, /, **fields)
Update the camera state.
Two call shapes:
Value form:
set_camera(Camera(parallel_scale=120))— sends the camera’s non-Nonefields.Kwargs form:
set_camera(parallel_scale=120, standard_view="anterior")— equivalent to building a one-off Camera.
Mixing the two raises
TypeError.- Return type:
- get_selected_slice()
Fetch the selected-slice state.
- Raises:
UnsupportedOperationError – For the StdMulti 3D window.
- Return type:
- set_selected_slice(step)
Step the slice navigator to a target index.
stepis not range-checked — out-of-range values are clamped or snapped by MITK.- Raises:
UnsupportedOperationError – For the StdMulti 3D window.
- Return type:
- set_node_layer(node, layer)
Set this node’s per-window layer (stack order) property.
- Return type:
StdMultiWidget editor
StdMultiWidget editor handle.
Wraps GET /rendering/editors/stdmulti and its sub-resources.
- class mitk_workbench_remote.editors.std_multi.StdMultiEditor(transport)
Bases:
EditorBaseHandle to the StdMultiWidget editor (axial / sagittal / coronal / 3d).
- property axial: RenderWindow
The axial 2D window.
- property sagittal: RenderWindow
The sagittal 2D window.
- property coronal: RenderWindow
The coronal 2D window.
- property three_d: RenderWindow
The 3D window. Equivalent to
editor["3d"]("3d"is not a valid Python identifier, hence the spelled-out alias).
MxN editor and layout
MxN multi-widget editor handle and per-cell render-window handle.
Wraps GET /rendering/editors/mxn and its sub-resources, plus the
layout endpoint (GET/PUT /rendering/editors/mxn/layout).
Layout I/O comes in two flavours:
Raw-dict (always available):
MxNEditor.get_layout_json()andset_layout(dict)move the wire JSON unchanged. No DSL dependency.Typed (requires the optional
mitkpackage):MxNEditor.get_layout(),set_layout(MxNLayoutDocument),MxNEditor.update_layout(),MxNEditor.apply_grid(),MxNEditor.apply_preset()use themitk.mxn.layoutDSL for typed construction, validation, and bulk transforms.
- class mitk_workbench_remote.editors.mxn.MxNRenderWindow(transport, editor_alias, window_id, *, kind=None)
Bases:
RenderWindowHandle to a single MxN cell.
Adds the per-cell selected-position primitive and overrides
get_summary()to return the richerMxNWindowSummary.kindis resolved via the inherited base-class accessor: cached when eagerly populated byMxNEditor.list_windows(), otherwise fetched lazily throughget_summary(). No client-side assumption about which cell kinds the active schema supports.- get_summary()
Fetch the per-cell summary (always live).
- Return type:
- get_selected_position()
Fetch this cell’s 3D world anchor and scene bounds.
- Return type:
- set_selected_position(position)
Set this cell’s 3D world anchor.
Distinct from the global
/rendering/selected-positionresource: whether the change propagates to other cells or to the global anchor depends on the workbench’s interactive coupling toolbar state, which is intentionally not exposed via REST.
- class mitk_workbench_remote.editors.mxn.MxNEditor(transport)
Bases:
EditorBaseHandle to the MxN multi-widget editor.
Cell ids are the canonical fully-qualified form
<editor_name>__<bare>(e.g."mxn__widget0"). The same string appears in the URL, the layout document, and the engine — no prefix translation happens at any boundary.- list_windows()
List the editor’s cells (in pre-order traversal of the layout).
- Return type:
- get_window(window_id)
Get a render-window handle by its id (no network call).
- Return type:
- get_layout_json()
Fetch the current layout document as a raw dict.
Returns the JSON body unchanged — no DSL parsing — so callers can round-trip the layout byte-for-byte without a
mitkinstall.
- get_layout()
Fetch the current layout, parsed into a typed
MxNLayoutDocument. Requires the optionalmitkpackage.- Return type:
MxNLayoutDocument
- set_layout(layout)
Apply a layout document to the editor.
Accepts:
MxNLayoutDocument— sent as-is (trusted; the DSL validates on construction). Requires the optionalmitkpackage.Mapping(raw dict) — sent as-is, no client-side validation. Always available; the server enforces the schema and surfaces 400INVALID_REQUESTon a malformed body.JSON
strorpathlib.Path— parsed viaMxNLayoutDocument.from_json()and validated client-side before PUT (catches typos / missing groups before a wasted round-trip). Requires the optionalmitkpackage.
Returns the freshly-serialized layout returned by the server in the PUT response (same shape as
get_layout_json()).All existing cells are torn down and rebuilt from the document — any cell handle a caller cached prior to the call is invalid afterwards.
- Return type:
dict[str, Any]
- update_layout(transform)
GET the layout, apply
transform, validate, PUT it back.transformreceives the freshly-fetched typedMxNLayoutDocumentand returns a new one (DSL operations are immutable). The returned document is validated client-side before PUT; the parsed PUT response is returned to the caller.Idiomatic use:
from mitk.mxn.layout import MxNWindowSelector, ViewDirection def link_axials(doc): return ( MxNWindowSelector(doc) .by_view(ViewDirection.AXIAL) .link_to("axial_group") ) wb.mxn.update_layout(link_axials)
- Return type:
MxNLayoutDocument
- apply_grid(rows, cols, *, view_directions=None, group='main')
Apply a fresh
rowsxcolsgrid layout.Returns the freshly-serialized layout from the PUT response, parsed back into a typed
MxNLayoutDocument.- Return type:
MxNLayoutDocument
- apply_preset(name)
Apply a named preset from
mitk.mxn.layout.PRESETS.Returns the freshly-serialized layout from the PUT response, parsed back into a typed
MxNLayoutDocument.- Return type:
MxNLayoutDocument