Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | import { OrientationAxis } from '../../../enums';
import type DisplayArea from '../../../types/displayArea';
import { deepClone } from '../../../utilities/deepClone';
import { clonePlanarOrientation } from './planarLegacyCompatibility';
import type {
PlanarDisplayArea,
PlanarSliceState,
PlanarViewState,
} from './PlanarViewportTypes';
import { normalizePlanarRotation } from './planarViewPresentation';
import {
clonePlanarScale,
normalizePlanarScaleMode,
} from './planarCameraScale';
export function cloneDisplayArea<T extends DisplayArea | PlanarDisplayArea>(
displayArea?: T
): T | undefined {
return deepClone(displayArea);
}
export function createDefaultPlanarViewState(): PlanarViewState {
return {
slice: {
kind: 'stackIndex',
imageIdIndex: 0,
},
orientation: OrientationAxis.ACQUISITION,
flipHorizontal: false,
flipVertical: false,
anchorCanvas: [0.5, 0.5],
scale: [1, 1],
scaleMode: 'fit',
rotation: 0,
};
}
function cloneSlice(slice?: PlanarSliceState): PlanarSliceState | undefined {
if (!slice) {
return;
}
if (slice.kind === 'stackIndex') {
return {
kind: 'stackIndex',
imageIdIndex: Math.max(0, Math.round(slice.imageIdIndex)),
};
}
return {
kind: 'volumePoint',
sliceWorldPoint: [...slice.sliceWorldPoint],
};
}
export function normalizePlanarViewState(
viewState: PlanarViewState
): PlanarViewState {
return {
...(viewState.slice ? { slice: cloneSlice(viewState.slice) } : {}),
orientation:
clonePlanarOrientation(viewState.orientation) ??
OrientationAxis.ACQUISITION,
flipHorizontal: viewState.flipHorizontal === true,
flipVertical: viewState.flipVertical === true,
anchorCanvas: viewState.anchorCanvas
? [...viewState.anchorCanvas]
: [0.5, 0.5],
scale: clonePlanarScale(viewState.scale),
scaleMode: normalizePlanarScaleMode(
viewState.displayArea?.scaleMode ?? viewState.scaleMode
),
rotation: normalizePlanarRotation(viewState.rotation ?? 0),
...(viewState.displayArea
? { displayArea: cloneDisplayArea(viewState.displayArea) }
: {}),
...(viewState.anchorWorld
? { anchorWorld: [...viewState.anchorWorld] }
: {}),
};
}
|