import { DRAG_MODE, Niivue, SLICE_TYPE, type NVConfigOptions, type NVImage } from "@niivue/niivue"; import type { LayoutConfig } from "./layouts"; import type { NvSceneEventMap, ViewerState, ImageFromUrlOptions } from "./types"; export { SLICE_TYPE }; export type NiivueCallback = (nv: Niivue, index: number) => void; export interface ViewerSlot { id: string; niivue: Niivue; canvasElement: HTMLCanvasElement; containerDiv: HTMLDivElement; } export interface NvSceneControllerSnapshot { currentLayout: string; viewerCount: number; slots: number; isBroadcasting: boolean; isLoading: boolean; viewerStates: ViewerState[]; } export interface BroadcastOptions { "2d": boolean; "3d": boolean; } export interface SliceLayoutTile { sliceType: number; position: [number, number, number, number]; } export interface SliceLayoutConfig { label: string; layout: SliceLayoutTile[]; } /** * Default slice layout: Axial as hero (80% height), coronal and sagittal below (20% height each, side by side) */ export declare const defaultSliceLayout: SliceLayoutTile[]; /** * Split view: sagittal left, coronal/axial stacked on the right. */ export declare const splitSliceLayout: SliceLayoutTile[]; /** * Tri-fan: three equal horizontal panels. */ export declare const triSliceLayout: SliceLayoutTile[]; /** * Stacked: three equal vertical stacks. */ export declare const stackedSliceLayout: SliceLayoutTile[]; /** * Quad: axial/coronal/sagittal with a render tile. */ export declare const quadSliceLayout: SliceLayoutTile[]; /** * Hero render with three small orthogonal slices below. */ export declare const heroRenderSliceLayout: SliceLayoutTile[]; export declare const defaultSliceLayouts: Record; type Listener = () => void; export declare const defaultViewerOptions: Partial; export declare const defaultMouseConfig: { leftButton: { primary: DRAG_MODE; }; rightButton: DRAG_MODE; centerButton: DRAG_MODE; }; /** * An NvSceneController is a declarative representation of what we want to render with Niivue. * * A scene can contain multiple Niivue instances. Each Niivue instance has its own * canvas element for the WebGL2 context. All canvas elements are wrapped in container * divs that are children of the main scene container element. * * Canvas elements are added/removed on-demand based on the scene definition. * * The scene layout controls the position of each canvas via layout functions that * return absolute positioning styles. The scene container is responsive and maintains * the requested layout proportionally. */ export declare class NvSceneController { containerElement: HTMLElement | null; viewers: ViewerSlot[]; currentLayout: string; slots: number; layouts: Record; onViewerCreated?: NiivueCallback; private listeners; private snapshotCache; private nextId; private viewersById; private broadcasting; private broadcastOptions; private viewerSliceLayouts; private viewerDefaults; private eventListeners; private loadingCounts; private viewerErrors; constructor(layouts?: Record, viewerDefaults?: Partial); on(event: E, cb: NvSceneEventMap[E]): () => void; off(event: E, cb: NvSceneEventMap[E]): void; private emit; subscribe: (listener: Listener) => (() => void); getSnapshot: () => NvSceneControllerSnapshot; private notify; setContainerElement(element: HTMLElement | null): void; setLayout(layoutName: string): void; updateLayout(): void; canAddViewer(): boolean; getNiivue(index: number): Niivue | undefined; getAllNiivue(): Niivue[]; forEachNiivue(callback: NiivueCallback): void; private hasSyncableContent; private safeBroadcastTo; private rewireBroadcasting; setBroadcasting(enabled: boolean, options?: Partial): void; isBroadcasting(): boolean; setViewerSliceLayout(index: number, layout: SliceLayoutTile[] | null): void; getViewerSliceLayout(index: number): SliceLayoutTile[] | null; private applySliceLayout; getNiivueById(id: string): Niivue | undefined; getViewerById(id: string): ViewerSlot | undefined; loadVolume(index: number, opts: ImageFromUrlOptions): Promise; loadVolumes(index: number, opts: ImageFromUrlOptions[]): Promise; removeVolume(index: number, url: string): void; /** * Look up the Niivue instance and NVImage at the given viewer and volume indices. * Returns undefined if either index is out of bounds. */ private findVolume; /** Set the colormap for a volume at the given viewer and volume index. */ setColormap(viewerIndex: number, volumeIndex: number, colormap: string): void; /** Set the intensity range (cal_min / cal_max) for a volume at the given viewer and volume index. */ setCalMinMax(viewerIndex: number, volumeIndex: number, cal_min: number, cal_max: number): void; /** Set the opacity for a volume at the given viewer and volume index. */ setOpacity(viewerIndex: number, volumeIndex: number, opacity: number): void; private incrementLoading; private decrementLoading; private addError; addViewer(options?: Partial): ViewerSlot; removeViewer(index: number, shouldNotify?: boolean): void; private disposeViewer; clearViewers(): void; reset(): void; }