Class: OrientationLabelLayer
Defined in: src/display/OrientationLabelLayer.ts:64
OrientationLabelLayer renders anatomical direction labels (L/R/A/P/S/I) pinned to the four edges of the viewport, at a fixed screen size — exactly as typical neuroimaging viewers (FSLeyes, MRIcron) display them.
Why this is a screen-space layer
The slice image is rendered into a container that is scaled to fit and Y-flipped. Anything placed in that container scales and flips with the image. Orientation labels must instead stay a constant pixel size and stay pinned to the viewport edges through zoom/pan/resize, so this layer declares screenSpace and is rendered by SliceView into an unscaled, stage-level overlay container.
How the letters are assigned to edges (correctness)
The letters for the in-plane axes (viewAxes.i, viewAxes.j) come from the orientation, but which screen edge each letter belongs to is derived from the live image transform via ScreenLayoutContext.project. We project the endpoints of the i- and j-axes to screen pixels and assign each label to the edge it actually points to. This guarantees the labels can never disagree with the rendered image, regardless of axis flips, zoom, or pan — which is essential because mislabeling Left/Right is a serious error in neuroimaging.
Implements
Constructors
Constructor
new OrientationLabelLayer(neuroSpace, options?): OrientationLabelLayer;Defined in: src/display/OrientationLabelLayer.ts:82
Parameters
neuroSpace
options?
Returns
OrientationLabelLayer
Properties
screenSpace
readonly screenSpace: true = true;Defined in: src/display/OrientationLabelLayer.ts:65
If true, this layer renders in screen-pixel space rather than in the scaled/Y-flipped image content space.
The container returned by renderSlice is added to a dedicated, unscaled overlay container that sits on top of the image. Such layers are excluded from the image's fit-to-screen bounds (so they never affect the image scale) and must position their content using viewport pixel coordinates via layoutScreen.
Use this for overlays that should stay a constant size and stay pinned to the viewport (orientation labels, scale bars, fixed HUD text) instead of tracking the anatomy.
Implementation of
neuroSpace
neuroSpace: NeuroSpace;Defined in: src/display/OrientationLabelLayer.ts:66
The NeuroSpace associated with the layer. Ensures spatial coherence with other layers in the viewer.
Implementation of
Methods
initialize()
initialize(): void;Defined in: src/display/OrientationLabelLayer.ts:95
Initializes the layer, loading any necessary data or resources. This method is called once when the layer is added to the SliceViewer. It can perform asynchronous operations if needed.
Returns
void
Implementation of
renderSlice()
renderSlice(
_sliceIndex,
_coord,
viewAxes,
_parentContainer): Container | null;Defined in: src/display/OrientationLabelLayer.ts:99
Renders the slice for the current slice index and view axes. This method is called whenever the SliceViewer updates the slice index or the view orientation.
Parameters
_sliceIndex
number
_coord
number[]
viewAxes
The AxisSet3D defining the view orientation.
_parentContainer
Container
Returns
Container | null
A PIXI.Container or PIXI.DisplayObject containing the rendered content. Returns null if the layer has nothing to render for the given slice.
Implementation of
layoutScreen()
layoutScreen(ctx): void;Defined in: src/display/OrientationLabelLayer.ts:134
Pin the four labels to the viewport edges. The edge each label belongs to is derived from the live image transform so the labels always match the image.
Parameters
ctx
Returns
void
Implementation of
setPosition()
setPosition(_coord): void;Defined in: src/display/OrientationLabelLayer.ts:214
Updates the layer's state based on the new volume coordinates. This method is called whenever the SliceViewer's position changes, ensuring that the layer remains in sync with the current view.
Parameters
_coord
number[]
Returns
void
Implementation of
onPointerMove()
onPointerMove(_event): boolean;Defined in: src/display/OrientationLabelLayer.ts:218
Handles pointer (mouse or touch) move events. Layers can implement this method to provide interactive behaviors, such as displaying tooltips or highlighting regions.
Parameters
_event
SlicePointerEvent
Returns
boolean
A boolean indicating whether the event has been fully handled. If true, the event propagation stops, preventing other layers from handling it.
Implementation of
onPointerDown()
onPointerDown(_event): boolean;Defined in: src/display/OrientationLabelLayer.ts:222
Handles pointer (mouse or touch) down events. Layers can implement this method to provide interactive behaviors, such as selecting regions or initiating drag operations.
Parameters
_event
SlicePointerEvent
Returns
boolean
A boolean indicating whether the event has been fully handled. If true, the event propagation stops, preventing other layers from handling it.
Implementation of
dispose()
dispose(): void;Defined in: src/display/OrientationLabelLayer.ts:226
Disposes of the layer, cleaning up any resources or event listeners. This method is called when the layer is removed from the SliceViewer or when the SliceViewer itself is disposed.
Returns
void