diff --git a/src/components/VtkObliqueView.vue b/src/components/VtkObliqueView.vue index 4ae8f8e8..57fdd9f8 100644 --- a/src/components/VtkObliqueView.vue +++ b/src/components/VtkObliqueView.vue @@ -219,7 +219,7 @@ export default defineComponent({ get: () => windowingStore.getConfig(viewID.value, curImageID.value), set: (newValue) => { const imageID = curImageID.value; - if (imageID !== null && newValue != null) { + if (imageID != null && newValue != null) { windowingStore.updateConfig(viewID.value, imageID, newValue); } }, @@ -229,7 +229,7 @@ export default defineComponent({ const windowLevel = computed(() => wlConfig.value?.level); const dicomInfo = computed(() => { if ( - curImageID.value !== null && + curImageID.value != null && curImageID.value in dicomStore.imageIDToVolumeKey ) { const volumeKey = dicomStore.imageIDToVolumeKey[curImageID.value]; diff --git a/src/components/VtkTwoView.vue b/src/components/VtkTwoView.vue index 3b8c921a..94ee61c4 100644 --- a/src/components/VtkTwoView.vue +++ b/src/components/VtkTwoView.vue @@ -333,7 +333,7 @@ export default defineComponent({ get: () => windowingStore.getConfig(viewID.value, curImageID.value), set: (newValue) => { const imageID = curImageID.value; - if (imageID !== null && newValue != null) { + if (imageID != null && newValue != null) { windowingStore.updateConfig(viewID.value, imageID, newValue); } }, @@ -346,7 +346,7 @@ export default defineComponent({ ); const dicomInfo = computed(() => { if ( - curImageID.value !== null && + curImageID.value != null && curImageID.value in dicomStore.imageIDToVolumeKey ) { const volumeKey = dicomStore.imageIDToVolumeKey[curImageID.value]; @@ -388,7 +388,7 @@ export default defineComponent({ // --- setters --- // const setSlice = (slice: number) => { - if (curImageID.value !== null) { + if (curImageID.value != null) { viewSliceStore.updateConfig(viewID.value, curImageID.value, { slice, }); diff --git a/src/components/tools/SliceScrollTool.vue b/src/components/tools/SliceScrollTool.vue index cd04de82..0feaf6c5 100644 --- a/src/components/tools/SliceScrollTool.vue +++ b/src/components/tools/SliceScrollTool.vue @@ -96,7 +96,7 @@ export default defineComponent({ range.step, () => scrollVal.value, (slice) => { - if (currentImageID.value !== null) { + if (currentImageID.value != null) { viewSliceStore.updateConfig(viewID.value, currentImageID.value, { slice, }); diff --git a/src/composables/usePersistCameraConfig.ts b/src/composables/usePersistCameraConfig.ts index 2fdfb5ee..5bddbe12 100644 --- a/src/composables/usePersistCameraConfig.ts +++ b/src/composables/usePersistCameraConfig.ts @@ -1,12 +1,13 @@ import { manageVTKSubscription } from '@/src/composables/manageVTKSubscription'; import { Ref } from 'vue'; +import { Maybe } from '@/src/types'; import { CameraConfig } from '../store/view-configs/types'; import { vtkLPSViewProxy } from '../types/vtk-types'; import useViewCameraStore from '../store/view-configs/camera'; export function usePersistCameraConfig( viewID: Ref, - dataID: Ref, + dataID: Ref>, viewProxy: Ref, ...toPersist: (keyof CameraConfig)[] ) { @@ -19,7 +20,7 @@ export function usePersistCameraConfig( if (toPersist.indexOf('position') > -1) { persist.push(() => { - if (dataID.value !== null && persistCameraConfig) { + if (dataID.value != null && persistCameraConfig) { viewCameraStore.updateConfig(viewID.value, dataID.value, { position: viewProxy.value.getCamera().getPosition(), }); @@ -28,7 +29,7 @@ export function usePersistCameraConfig( } if (toPersist.indexOf('viewUp') > -1) { persist.push(() => { - if (dataID.value !== null && persistCameraConfig) { + if (dataID.value != null && persistCameraConfig) { viewCameraStore.updateConfig(viewID.value, dataID.value, { viewUp: viewProxy.value.getCamera().getViewUp(), }); @@ -37,7 +38,7 @@ export function usePersistCameraConfig( } if (toPersist.indexOf('focalPoint') > -1) { persist.push(() => { - if (dataID.value !== null && persistCameraConfig) { + if (dataID.value != null && persistCameraConfig) { viewCameraStore.updateConfig(viewID.value, dataID.value, { focalPoint: viewProxy.value.getCamera().getFocalPoint(), }); @@ -46,7 +47,7 @@ export function usePersistCameraConfig( } if (toPersist.indexOf('directionOfProjection') > -1) { persist.push(() => { - if (dataID.value !== null && persistCameraConfig) { + if (dataID.value != null && persistCameraConfig) { viewCameraStore.updateConfig(viewID.value, dataID.value, { directionOfProjection: viewProxy.value .getCamera() @@ -57,7 +58,7 @@ export function usePersistCameraConfig( } if (toPersist.indexOf('parallelScale') > -1) { persist.push(() => { - if (dataID.value !== null && persistCameraConfig) { + if (dataID.value != null && persistCameraConfig) { viewCameraStore.updateConfig(viewID.value, dataID.value, { parallelScale: viewProxy.value.getCamera().getParallelScale(), }); diff --git a/src/composables/useSceneBuilder.ts b/src/composables/useSceneBuilder.ts index 71b1dd99..3b95c190 100644 --- a/src/composables/useSceneBuilder.ts +++ b/src/composables/useSceneBuilder.ts @@ -1,11 +1,12 @@ import vtkAbstractRepresentationProxy from '@kitware/vtk.js/Proxy/Core/AbstractRepresentationProxy'; import { computed, Ref, watch } from 'vue'; +import { Maybe } from '@/src/types'; import { useViewStore } from '../store/views'; import { vtkLPSViewProxy } from '../types/vtk-types'; import { arrayEquals } from '../utils'; interface Scene { - baseImage?: Ref; + baseImage?: Ref>; labelmaps?: Ref; layers?: Ref; models?: Ref; diff --git a/src/store/tools/crop.ts b/src/store/tools/crop.ts index 9fe59a13..73e100a1 100644 --- a/src/store/tools/crop.ts +++ b/src/store/tools/crop.ts @@ -9,6 +9,7 @@ import { MaybeRef } from '@vueuse/core'; import { vec3 } from 'gl-matrix'; import { defineStore } from 'pinia'; import { arrayEqualsWithComparator } from '@/src/utils'; +import { Maybe } from '@/src/types'; import { useImageStore } from '../datasets-images'; import { LPSCroppingPlanes } from '../../types/crop'; import { ImageMetadata } from '../../types/image'; @@ -89,7 +90,7 @@ export const useCropStore = defineStore('crop', () => { croppingByImageID: {} as Record, }); - const getComputedVTKPlanes = (imageID: MaybeRef) => + const getComputedVTKPlanes = (imageID: MaybeRef>) => computed(() => { const id = unref(imageID); if (id && id in state.croppingByImageID && id in imageStore.metadata) { diff --git a/src/store/tools/paint.ts b/src/store/tools/paint.ts index e7716e65..0a96dffc 100644 --- a/src/store/tools/paint.ts +++ b/src/store/tools/paint.ts @@ -15,7 +15,7 @@ export const usePaintToolStore = defineStore('paint', () => { type _This = ReturnType; const activeMode = ref(PaintMode.CirclePaint); - const activeSegmentGroupID = ref(null); + const activeSegmentGroupID = ref>(null); const activeSegment = ref>(null); const brushSize = ref(DEFAULT_BRUSH_SIZE); const strokePoints = ref([]); @@ -48,7 +48,7 @@ export const usePaintToolStore = defineStore('paint', () => { /** * Sets the active labelmap. */ - function setActiveLabelmap(segmentGroupID: string | null) { + function setActiveLabelmap(segmentGroupID: Maybe) { activeSegmentGroupID.value = segmentGroupID; } @@ -57,7 +57,7 @@ export const usePaintToolStore = defineStore('paint', () => { * * If a labelmap exists, pick the first one. If no labelmap exists, create one. */ - function setActiveLabelmapFromImage(imageID: string | null) { + function setActiveLabelmapFromImage(imageID: Maybe) { if (!imageID) { setActiveLabelmap(null); return; @@ -178,7 +178,7 @@ export const usePaintToolStore = defineStore('paint', () => { function serialize(state: StateFile) { const { paint } = state.manifest.tools; - paint.activeSegmentGroupID = activeSegmentGroupID.value; + paint.activeSegmentGroupID = activeSegmentGroupID.value ?? null; paint.brushSize = brushSize.value; paint.activeSegment = activeSegment.value; paint.labelmapOpacity = labelmapOpacity.value;