Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::RenderingController Class Reference

Handles all /api/v1/rendering endpoints. More...

#include <mitkRenderingController.h>

Public Member Functions

 RenderingController (DataStorageBridge &bridge)
 Construct a RenderingController. More...
 
void SetDispatcher (StorageThreadDispatcherBase *dispatcher)
 Set the thread dispatcher for RenderingManager operations. More...
 
void SetRenderWindowBridge (RenderWindowBridge *bridge)
 Set or clear the RenderWindowBridge for interactions with the rendering stack of the application. More...
 
void HandlePOST_update (const httplib::Request &req, httplib::Response &res) const
 Handle POST /rendering/update request. More...
 
void HandlePOST_reinit (const httplib::Request &req, httplib::Response &res) const
 Handle POST /rendering/reinit request. More...
 
void HandleGET_selectedPosition (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/selected-position request. More...
 
void HandlePUT_selectedPosition (const httplib::Request &req, httplib::Response &res) const
 Handle PUT /rendering/selected-position request. More...
 
void HandleGET_selectedTime (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/selected-time request. More...
 
void HandlePUT_selectedTime (const httplib::Request &req, httplib::Response &res) const
 Handle PUT /rendering/selected-time request. More...
 
void HandleGET_editors (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors request. More...
 
void HandleGET_stdmultiInfo (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/stdmulti request. More...
 
void HandleGET_stdmultiWindows (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/stdmulti/windows request. More...
 
void HandleGET_stdmultiWindow (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/stdmulti/windows/{id} request. More...
 
void HandleGET_stdmultiCamera (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/stdmulti/windows/{id}/camera. More...
 
void HandlePUT_stdmultiCamera (const httplib::Request &req, httplib::Response &res) const
 Handle PUT /rendering/editors/stdmulti/windows/{id}/camera. More...
 
void HandleGET_stdmultiSelectedSlice (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/stdmulti/windows/{id}/selected-slice. More...
 
void HandlePUT_stdmultiSelectedSlice (const httplib::Request &req, httplib::Response &res) const
 Handle PUT /rendering/editors/stdmulti/windows/{id}/selected-slice. More...
 
void HandleGET_stdmultiScreenshot (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/stdmulti/screenshot. More...
 
void HandleGET_stdmultiWindowScreenshot (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/stdmulti/windows/{id}/screenshot. More...
 
void HandleGET_mxnInfo (const httplib::Request &req, httplib::Response &res) const
 
void HandleGET_mxnWindows (const httplib::Request &req, httplib::Response &res) const
 
void HandleGET_mxnWindow (const httplib::Request &req, httplib::Response &res) const
 
void HandleGET_mxnLayout (const httplib::Request &req, httplib::Response &res) const
 
void HandlePUT_mxnLayout (const httplib::Request &req, httplib::Response &res) const
 Handle PUT /rendering/editors/mxn/layout. More...
 
void HandleGET_mxnCamera (const httplib::Request &req, httplib::Response &res) const
 
void HandlePUT_mxnCamera (const httplib::Request &req, httplib::Response &res) const
 Handle PUT /rendering/editors/mxn/windows/{id}/camera. More...
 
void HandleGET_mxnSelectedSlice (const httplib::Request &req, httplib::Response &res) const
 
void HandlePUT_mxnSelectedSlice (const httplib::Request &req, httplib::Response &res) const
 Handle PUT /rendering/editors/mxn/windows/{id}/selected-slice. More...
 
void HandleGET_mxnSelectedPosition (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/mxn/windows/{id}/selected-position. More...
 
void HandlePUT_mxnSelectedPosition (const httplib::Request &req, httplib::Response &res) const
 Handle PUT /rendering/editors/mxn/windows/{id}/selected-position. More...
 
void HandleGET_mxnScreenshot (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/mxn/screenshot. More...
 
void HandleGET_mxnWindowScreenshot (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/editors/mxn/windows/{id}/screenshot. More...
 
void HandleGET_screenshot (const httplib::Request &req, httplib::Response &res) const
 Handle GET /rendering/screenshot request. More...
 

Detailed Description

Handles all /api/v1/rendering endpoints.

All RenderingManager calls are dispatched to the main/UI thread via the StorageThreadDispatcherBase. In headless/test mode (no dispatcher), tasks execute directly on the calling thread.

Definition at line 38 of file mitkRenderingController.h.

Constructor & Destructor Documentation

◆ RenderingController()

mitk::RenderingController::RenderingController ( DataStorageBridge &  bridge)
explicit

Construct a RenderingController.

Parameters
bridgeReference to the DataStorageBridge for data access.

Member Function Documentation

◆ HandleGET_editors()

void mitk::RenderingController::HandleGET_editors ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors request.

Returns the full list of known editor aliases with their current activity state.

Response 200: [{"alias":..., "plugin_id":..., "active":...}, ...]

◆ HandleGET_mxnCamera()

void mitk::RenderingController::HandleGET_mxnCamera ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/mxn/windows/{id}/camera.

◆ HandleGET_mxnInfo()

void mitk::RenderingController::HandleGET_mxnInfo ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/mxn.

◆ HandleGET_mxnLayout()

void mitk::RenderingController::HandleGET_mxnLayout ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/mxn/layout.

◆ HandleGET_mxnScreenshot()

void mitk::RenderingController::HandleGET_mxnScreenshot ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/mxn/screenshot.

Captures the MxN multi-widget editor canvas (multi-widget area only - no toolbars, no side panels). Query and response contract identical to GET /rendering/screenshot.

◆ HandleGET_mxnSelectedPosition()

void mitk::RenderingController::HandleGET_mxnSelectedPosition ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/mxn/windows/{id}/selected-position.

Returns the per-cell 3D world anchor + scene bounds. Distinct from the global /rendering/selected-position, which targets the StdMulti anchor. Per-cell anchors may legitimately diverge from the global one.

◆ HandleGET_mxnSelectedSlice()

void mitk::RenderingController::HandleGET_mxnSelectedSlice ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/mxn/windows/{id}/selected-slice.

◆ HandleGET_mxnWindow()

void mitk::RenderingController::HandleGET_mxnWindow ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/mxn/windows/{id}.

◆ HandleGET_mxnWindows()

void mitk::RenderingController::HandleGET_mxnWindows ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/mxn/windows.

◆ HandleGET_mxnWindowScreenshot()

void mitk::RenderingController::HandleGET_mxnWindowScreenshot ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/mxn/windows/{id}/screenshot.

Single MxN cell viewport capture without resizing the live render surface. Query and response contract identical to GET /rendering/screenshot.

◆ HandleGET_screenshot()

void mitk::RenderingController::HandleGET_screenshot ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/screenshot request.

Captures a screenshot of the active application window.

Query parameters:

  • format: "png" (default) or "jpeg"
  • width, height: optional positive integers; both must be given together.

Response 200 with binary image body (Content-Type: image/png or image/jpeg).

Precondition
RenderWindowBridge must be set and have a screenshot provider (503 otherwise).
Parameters
reqThe HTTP request.
resThe HTTP response to populate.

◆ HandleGET_selectedPosition()

void mitk::RenderingController::HandleGET_selectedPosition ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/selected-position request.

Returns the current crosshair position and the world-space AABB (i.e. the reinit geometry). If no input geometry is available, bounds.min_position and bounds.max_position are null.

Returns 503 if no render window bridge or position getter is connected.

Response 200: {"position": [x, y, z], "bounds": {"min_position": [...], "max_position": [...]}}

Parameters
reqThe HTTP request.
resThe HTTP response to populate.

◆ HandleGET_selectedTime()

void mitk::RenderingController::HandleGET_selectedTime ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/selected-time request.

Returns the current time step and time point from the global TimeNavigationController, together with the time geometry bounds.

Response 200: {"timepoint_ms": ..., "timestep": ..., "bounds": {...}}

Parameters
reqThe HTTP request.
resThe HTTP response to populate.

◆ HandleGET_stdmultiCamera()

void mitk::RenderingController::HandleGET_stdmultiCamera ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/stdmulti/windows/{id}/camera.

2D windows return parallel_scale, the 3D window returns perspective_angle.

◆ HandleGET_stdmultiInfo()

void mitk::RenderingController::HandleGET_stdmultiInfo ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/stdmulti request.

Returns metadata about the StdMultiWidgetEditor.

◆ HandleGET_stdmultiScreenshot()

void mitk::RenderingController::HandleGET_stdmultiScreenshot ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/stdmulti/screenshot.

Editor-canvas grab. Query contract identical to /rendering/screenshot.

◆ HandleGET_stdmultiSelectedSlice()

void mitk::RenderingController::HandleGET_stdmultiSelectedSlice ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/stdmulti/windows/{id}/selected-slice.

Returns {step, position, bounds}. Returns 404 UNSUPPORTED_OPERATION for the 3D window.

◆ HandleGET_stdmultiWindow()

void mitk::RenderingController::HandleGET_stdmultiWindow ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/stdmulti/windows/{id} request.

Per-window summary. Controller-side validates {id} before bridge dispatch.

◆ HandleGET_stdmultiWindows()

void mitk::RenderingController::HandleGET_stdmultiWindows ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/stdmulti/windows request.

Returns the list of render windows of the StdMultiWidget editor.

◆ HandleGET_stdmultiWindowScreenshot()

void mitk::RenderingController::HandleGET_stdmultiWindowScreenshot ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle GET /rendering/editors/stdmulti/windows/{id}/screenshot.

Single-window offscreen grab. Query contract identical to /rendering/screenshot.

◆ HandlePOST_reinit()

void mitk::RenderingController::HandlePOST_reinit ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle POST /rendering/reinit request.

Three operating modes:

  • No body (or body without "uids"): global reinit – fits all render windows to the bounding box of all currently visible data. Calls RenderingManager::InitializeViewsByBoundingObjects(dataStorage).
  • Body with "uids" containing one UID: single-node reinit – fits render windows to the bounding geometry of that node.
  • Body with "uids" containing multiple UIDs: multi-node reinit – fits render windows to the combined bounding geometry of all listed nodes. Both node cases call RenderingManager::InitializeViews(geometry, REQUEST_UPDATE_ALL, true).
Precondition
DataStorage must be connected (503 otherwise).
When "uids" is given: must be a non-empty array of strings (400 otherwise).
When "uids" is given: every UID must identify an existing node (404 on first failure).
When "uids" is given: every node must have data with a valid TimeGeometry (422 on first failure).
Parameters
reqThe HTTP request.
resThe HTTP response to populate.

◆ HandlePOST_update()

void mitk::RenderingController::HandlePOST_update ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle POST /rendering/update request.

Triggers RenderingManager::RequestUpdateAll() with optional type filter. Optional body: {"type": "all" | "2d" | "3d"} (default: "all").

Parameters
reqThe HTTP request.
resThe HTTP response to populate.

◆ HandlePUT_mxnCamera()

void mitk::RenderingController::HandlePUT_mxnCamera ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle PUT /rendering/editors/mxn/windows/{id}/camera.

Partial update; reuses the StdMulti ParseCameraPatch validation. Under v2 the MxN cell is3d is hard-coded to false: the schema's view_direction enum has no 3d value. When v3 introduces a 3D MxN cell type, derive is3d from the cell's MxNWindowInfo::kind.

◆ HandlePUT_mxnLayout()

void mitk::RenderingController::HandlePUT_mxnLayout ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle PUT /rendering/editors/mxn/layout.

Applies a v2.0 layout document. Response 200 echoes the freshly serialized layout (so callers don't need a follow-up GET to refresh cached cell ids after a tear-down).

Maps mitk::Exception thrown by the engine's ApplyLayout to 400 INVALID_REQUEST. This is the one site under the MxN handlers where mitk::Exception does not fall through to 422 RENDERING_ERROR; the assumption is that every mitk::Exception out of ApplyLayout is a document-shape failure (version, schema, duplicate id, unknown view direction, missing group reference, type error). If the engine ever broadens ApplyLayout's failure model to runtime issues, narrow the catch.

◆ HandlePUT_mxnSelectedPosition()

void mitk::RenderingController::HandlePUT_mxnSelectedPosition ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle PUT /rendering/editors/mxn/windows/{id}/selected-position.

Sets the per-cell 3D anchor via QmitkAbstractMultiWidget::SetSelectedPosition(point, widgetName). Whether the change propagates to other cells / the global anchor depends on the workbench's interactive coupling toggle, which is not exposed via REST. No range checking; out-of-range values are clamped/snapped by MITK.

◆ HandlePUT_mxnSelectedSlice()

void mitk::RenderingController::HandlePUT_mxnSelectedSlice ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle PUT /rendering/editors/mxn/windows/{id}/selected-slice.

Step-only. Body containing position returns 400 with a hint pointing at the per-cell selected-position resource for cell-local world anchor moves and at /rendering/selected-position for global moves.

◆ HandlePUT_selectedPosition()

void mitk::RenderingController::HandlePUT_selectedPosition ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle PUT /rendering/selected-position request.

Moves the global application crosshair to the given 3D world position. No bounds checking is performed; out-of-range values are clamped/snapped by MITK.

Required body: {"position": [x, y, z]} – exactly 3 numbers.

Response 204 on success. Returns 503 if no render window bridge or position setter is connected.

Parameters
reqThe HTTP request (must contain a JSON body with "position").
resThe HTTP response to populate.

◆ HandlePUT_selectedTime()

void mitk::RenderingController::HandlePUT_selectedTime ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle PUT /rendering/selected-time request.

Sets the active time step or time point in the global TimeNavigationController. Exactly one of "timepoint_ms" (number) or "timestep" (non-negative integer) must be present in the body. No bounds checking is performed; out-of-range values may be clamped by the time navigation controller.

Response 204 on success.

Parameters
reqThe HTTP request (must contain a JSON body with exactly one of the fields).
resThe HTTP response to populate.

◆ HandlePUT_stdmultiCamera()

void mitk::RenderingController::HandlePUT_stdmultiCamera ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle PUT /rendering/editors/stdmulti/windows/{id}/camera.

Partial update. Rejects: unknown fields, 2D-only field on 3D and vice versa, unknown standard_view values, non-positive parallel_scale, out-of-range perspective_angle, invalid JSON, empty body.

◆ HandlePUT_stdmultiSelectedSlice()

void mitk::RenderingController::HandlePUT_stdmultiSelectedSlice ( const httplib::Request &  req,
httplib::Response &  res 
) const

Handle PUT /rendering/editors/stdmulti/windows/{id}/selected-slice.

Body accepts only {"step": N}. A position field triggers 400 with a hint pointing at /rendering/selected-position (StdMulti slices are coupled). The 3D window returns 404 UNSUPPORTED_OPERATION.

◆ SetDispatcher()

void mitk::RenderingController::SetDispatcher ( StorageThreadDispatcherBase *  dispatcher)

Set the thread dispatcher for RenderingManager operations.

If set, all RenderingManager calls are dispatched to the storage-owning (main/UI) thread. If nullptr, calls execute directly (headless/test mode).

Thread-safety: serialised against Dispatch() via an internal mutex, so the dispatcher may be set or replaced while requests are in flight.

Parameters
dispatcherThe dispatcher, or nullptr to clear.

◆ SetRenderWindowBridge()

void mitk::RenderingController::SetRenderWindowBridge ( RenderWindowBridge *  bridge)

Set or clear the RenderWindowBridge for interactions with the rendering stack of the application.

Note
Lifecycle contract: this setter is intended to be called exactly once during RestServer::Start(), before the server thread starts accepting connections. The bridge pointer is not re-bound at runtime once request handlers are reachable. Because of this set-once-at-startup contract, the read sites in HandleGET_* / HandlePUT_* deliberately access m_RenderWindowBridge without holding m_DispatcherMutex – which would otherwise add a lock to every request without protecting against a race that does not exist in normal operation. Do not relax this contract without also serialising the read sites.
Parameters
bridgeThe bridge, or nullptr to clear (screenshot endpoint returns 503).

The documentation for this class was generated from the following file: