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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | 54x 54x 54x 54x 54x 54x 54x 54x 54x 54x 54x 54x 2x 2x 54x 8x 8x 2x 2x 54x 8x 8x 2x 2x 54x 4x 4x 3x 3x 54x 4x 4x 3x 3x 54x 4x 4x 3x 3x 54x 33x 54x 33x 54x 6x 54x 4x 54x 8x 4x 3x 5x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 37x 2x 5x 1x 2x 1x 1x 6x 1x 3x 1x 1x | import { computed, nextTick, ref } from 'vue';
import {
AnchorPoint,
ColourPresetData,
CurrentScanState,
InitialScanState,
PositionData,
ScanView,
} from '@3cr/types-ts';
import {
inflateInitialScanState,
inflateScanState,
} from '@/functions/modelHelper';
import { clamp } from '@/functions/clamp';
const _stlResolution = ref<number>(5);
export const currentColourPreset = ref<ColourPresetData>();
export const transactionStarted = ref<boolean>(false);
export const scanStateIncoming = ref<string>('');
export const initialScanState = ref<InitialScanState>(
inflateInitialScanState(),
);
export const scanState = ref<CurrentScanState>(inflateScanState());
export const previousLayout = ref<PositionData[]>([]);
export const huMinMax = ref({ min: -999999, max: 999999 });
export const tMinMax = ref({ min: 0, max: 999999 });
export const sMinMax = ref({ min: 0, max: 999999 });
export const cMinMax = ref({ min: 0, max: 999999 });
export const stlResolution = computed({
/* v8 ignore start -- @preserve */
get(): number {
return _stlResolution.value;
},
set(value: number): void {
// STL Resolution intentionally limited between 0 and 25%.
_stlResolution.value = clamp(value, 0, 25);
},
/* v8 ignore stop -- @preserve */
});
export const windowSlider = computed({
get(): [number, number] {
const { WindowLower, WindowUpper } = scanState.value.Display;
return [WindowLower, WindowUpper];
},
set(value: [number, number]): void {
scanState.value.Display.WindowLower = value[0];
scanState.value.Display.WindowUpper = value[1];
},
});
export const thresholdSlider = computed({
get(): [number, number] {
const { ThresholdLower, ThresholdUpper } = scanState.value.Display;
return [Math.trunc(ThresholdLower), Math.trunc(ThresholdUpper)];
},
set(value: [number, number]): void {
scanState.value.Display.ThresholdLower = value[0];
scanState.value.Display.ThresholdUpper = value[1];
},
});
export const tSlider = computed({
get(): [number, number] {
const { TransverseLower, TransverseUpper } = scanState.value.Slice;
return [Math.trunc(TransverseLower), Math.trunc(TransverseUpper)];
},
set(value: [number, number]): void {
scanState.value.Slice.TransverseLower = value[0];
scanState.value.Slice.TransverseUpper = value[1];
},
});
export const sSlider = computed({
get(): [number, number] {
const { SagittalLower, SagittalUpper } = scanState.value.Slice;
return [Math.trunc(SagittalLower), Math.trunc(SagittalUpper)];
},
set(value: [number, number]): void {
scanState.value.Slice.SagittalLower = value[0];
scanState.value.Slice.SagittalUpper = value[1];
},
});
export const cSlider = computed({
get(): [number, number] {
const { CoronalLower, CoronalUpper } = scanState.value.Slice;
return [Math.trunc(CoronalLower), Math.trunc(CoronalUpper)];
},
set(value: [number, number]): void {
scanState.value.Slice.CoronalLower = value[0];
scanState.value.Slice.CoronalUpper = value[1];
},
});
export const isLayout2x2 = computed(() => {
return (
scanState.value.Layout.PositionData.length > 1 &&
scanState.value.Layout.PositionData[0].Anchor === AnchorPoint.TOP_LEFT &&
scanState.value.Layout.PositionData[1].Anchor === AnchorPoint.TOP_RIGHT &&
scanState.value.Layout.PositionData[2].Anchor === AnchorPoint.BOTTOM_LEFT &&
scanState.value.Layout.PositionData[3].Anchor === AnchorPoint.BOTTOM_RIGHT
);
});
export const isLayout1x3 = computed(() => {
return (
scanState.value.Layout.PositionData.length > 1 &&
scanState.value.Layout.PositionData[0].Anchor === AnchorPoint.CENTER &&
scanState.value.Layout.PositionData[1].Anchor === AnchorPoint.TOP_RIGHT &&
scanState.value.Layout.PositionData[2].Anchor === AnchorPoint.RIGHT &&
scanState.value.Layout.PositionData[3].Anchor === AnchorPoint.BOTTOM_RIGHT
);
});
export const isFullscreen = computed(() => {
return scanState.value.Layout.PositionData.length === 1;
});
export const fullscreenView = computed(() => {
/* v8 ignore start -- @preserve */
return isFullscreen.value ? scanState.value.CurrentView : null;
/* v8 ignore stop -- @preserve */
});
export const currentGreyscalePreset = computed(() => {
for (const preset of initialScanState.value.GreyscalePresets) {
if (
(scanState.value.Display.WindowLower === preset.Lower ||
(preset.Lower < initialScanState.value.HuLower &&
scanState.value.Display.WindowLower ===
initialScanState.value.HuLower)) &&
(scanState.value.Display.WindowUpper === preset.Upper ||
(preset.Upper > initialScanState.value.HuUpper &&
scanState.value.Display.WindowUpper ===
initialScanState.value.HuUpper))
) {
return preset;
}
}
return undefined;
});
export async function setScanStateFromPayload(message: string): Promise<void> {
transactionStarted.value = true;
scanStateIncoming.value = JSON.stringify(JSON.parse(message), null, 2);
setScanState(message);
await nextTick();
transactionStarted.value = false;
}
export function setInitialScanStateFromPayload(message: string): void {
transactionStarted.value = true;
scanStateIncoming.value = JSON.stringify(JSON.parse(message), null, 2);
const obj = JSON.parse(scanStateIncoming.value) as InitialScanState;
setScanState(JSON.stringify(obj.DefaultDisplaySettings, null, 2));
initialScanState.value = obj;
huMinMax.value.max = obj.HuUpper;
huMinMax.value.min = obj.HuLower;
sMinMax.value.max = obj.XSlices;
cMinMax.value.max = obj.YSlices;
tMinMax.value.max = obj.ZSlices;
currentColourPreset.value = obj.ColourPresets[0];
}
export function setScanState(message: string): void {
scanState.value = JSON.parse(message) as CurrentScanState;
}
export function getCurrentView(position: PositionData): ScanView {
return scanState.value.Layout.PositionData.length !== 1
? position.DefaultView
: scanState.value.CurrentView;
}
export function isHorizontalFlip(view: ScanView): boolean {
switch (view) {
case ScanView.Coronal:
return scanState.value.Orientations.Coronal.HorizontalFlip;
case ScanView.Sagittal:
return scanState.value.Orientations.Sagittal.HorizontalFlip;
case ScanView.Transverse:
return scanState.value.Orientations.Transverse.HorizontalFlip;
default:
return false;
}
}
export function isVerticalFlip(view: ScanView): boolean {
switch (view) {
case ScanView.Coronal:
return scanState.value.Orientations.Coronal.VerticalFlip;
case ScanView.Sagittal:
return scanState.value.Orientations.Sagittal.VerticalFlip;
case ScanView.Transverse:
return scanState.value.Orientations.Transverse.VerticalFlip;
default:
return false;
}
}
|