Skip to content

Commit

Permalink
refactor: currentImageID is now Maybe<string>
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Sep 7, 2023
1 parent a6360b2 commit 49e6177
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/components/VtkTwoView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,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);
}
},
Expand All @@ -320,7 +320,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];
Expand Down Expand Up @@ -362,7 +362,7 @@ export default defineComponent({
// --- setters --- //
const setSlice = (slice: number) => {
if (curImageID.value !== null) {
if (curImageID.value != null) {
viewSliceStore.updateConfig(viewID.value, curImageID.value, {
slice,
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/tools/SliceScrollTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
13 changes: 7 additions & 6 deletions src/composables/usePersistCameraConfig.ts
Original file line number Diff line number Diff line change
@@ -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<string>,
dataID: Ref<string | null>,
dataID: Ref<Maybe<string>>,
viewProxy: Ref<vtkLPSViewProxy>,
...toPersist: (keyof CameraConfig)[]
) {
Expand All @@ -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(),
});
Expand All @@ -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(),
});
Expand All @@ -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(),
});
Expand All @@ -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()
Expand All @@ -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(),
});
Expand Down
3 changes: 2 additions & 1 deletion src/composables/useSceneBuilder.ts
Original file line number Diff line number Diff line change
@@ -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<string | null>;
baseImage?: Ref<Maybe<string>>;
labelmaps?: Ref<string[]>;
layers?: Ref<string[]>;
models?: Ref<string[]>;
Expand Down
3 changes: 2 additions & 1 deletion src/store/tools/crop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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';
Expand Down Expand Up @@ -60,7 +61,7 @@ export const useCropStore = defineStore('crop', () => {
croppingByImageID: {} as Record<string, LPSCroppingPlanes>,
});

const getComputedVTKPlanes = (imageID: MaybeRef<string | null>) =>
const getComputedVTKPlanes = (imageID: MaybeRef<Maybe<string>>) =>
computed(() => {
const id = unref(imageID);
if (id && id in state.croppingByImageID && id in imageStore.metadata) {
Expand Down
3 changes: 2 additions & 1 deletion src/store/tools/paint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Manifest, StateFile } from '@/src/io/state-file/schema';
import { computed, ref, watch } from 'vue';
import { vec3 } from 'gl-matrix';
import { defineStore } from 'pinia';
import { Maybe } from '@/src/types';
import { Tools } from './types';
import { useLabelmapStore } from '../datasets-labelmaps';

Expand Down Expand Up @@ -34,7 +35,7 @@ export const usePaintToolStore = defineStore('paint', () => {

// --- actions --- //

function selectOrCreateLabelmap(imageID: string | null) {
function selectOrCreateLabelmap(imageID: Maybe<string>) {
if (!imageID) {
activeLabelmapID.value = null;
return;
Expand Down

0 comments on commit 49e6177

Please sign in to comment.