Skip to content

Commit a1f793e

Browse files
committed
refactor(cine): route remaining view-axis call sites through getEffectiveViewAxis
useSliceInfo and crosshairs read view.options.orientation directly, which diverges from what cine views actually render (Axial). Route all three remaining sites — useSliceInfo (powers annotation widget plane math), crosshairs (cross-view slice sync), and SliceViewer (its own inline cine override) — through getEffectiveViewAxis so the cine collapse is applied consistently and the helper is the single source of truth.
1 parent 931f6a0 commit a1f793e

3 files changed

Lines changed: 11 additions & 22 deletions

File tree

src/components/SliceViewer.vue

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ import { ref, toRefs, computed, watch } from 'vue';
163163
import { storeToRefs } from 'pinia';
164164
import { useCurrentImage } from '@/src/composables/useCurrentImage';
165165
import { useProbeStore } from '@/src/store/probe';
166-
import { getLPSAxisFromDir } from '@/src/utils/lps';
166+
import { getEffectiveViewAxis } from '@/src/core/cine/getEffectiveViewAxis';
167167
import VtkSliceView from '@/src/components/vtk/VtkSliceView.vue';
168168
import { VtkViewApi } from '@/src/types/vtk-types';
169169
import { Tools } from '@/src/store/tools/types';
@@ -198,17 +198,13 @@ import vtkMouseCameraTrackballZoomToMouseManipulator from '@kitware/vtk.js/Inter
198198
import { useResetViewsEvents } from '@/src/components/tools/ResetViews.vue';
199199
import { onVTKEvent } from '@/src/composables/onVTKEvent';
200200
import { useViewStore } from '@/src/store/views';
201-
import { LPSAxis } from '@/src/types/lps';
201+
import { ViewInfo2D } from '@/src/types/views';
202202
import { get2DViewingVectors } from '@/src/utils/getViewingVectors';
203203
204204
interface Props {
205205
viewId: string;
206206
}
207207
208-
interface SliceViewerOptions {
209-
orientation: LPSAxis;
210-
}
211-
212208
const vtkView = ref<VtkViewApi>();
213209
const baseSliceRep = ref();
214210
const layerSliceReps = ref([]);
@@ -218,10 +214,7 @@ const props = defineProps<Props>();
218214
const { viewId } = toRefs(props);
219215
220216
const viewStore = useViewStore();
221-
const viewInfo = computed(() => viewStore.getView(viewId.value)!);
222-
const viewOptions = computed(
223-
() => viewInfo.value.options as SliceViewerOptions
224-
);
217+
const viewInfo = computed(() => viewStore.getView(viewId.value) as ViewInfo2D);
225218
226219
// base image
227220
const {
@@ -233,12 +226,12 @@ const {
233226
} = useCurrentImage();
234227
235228
const isCine = computed(() => isCineImage(currentImageID.value));
236-
const viewingVectors = computed(() =>
237-
get2DViewingVectors(isCine.value ? 'Axial' : viewOptions.value.orientation)
229+
const viewAxis = computed(() =>
230+
getEffectiveViewAxis(viewInfo.value, currentImageID.value)
238231
);
232+
const viewingVectors = computed(() => get2DViewingVectors(viewAxis.value));
239233
const viewDirection = computed(() => viewingVectors.value.viewDirection);
240234
const viewUp = computed(() => viewingVectors.value.viewUp);
241-
const viewAxis = computed(() => getLPSAxisFromDir(viewDirection.value));
242235
243236
const hover = ref(false);
244237

src/composables/useSliceInfo.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { Vector3 } from '@kitware/vtk.js/types';
22
import type { MaybeRef } from 'vue';
33
import { computed, unref } from 'vue';
4-
import { getLPSAxisFromDir } from '@/src/utils/lps';
54
import { useImage } from '@/src/composables/useCurrentImage';
65
import { Maybe } from '@/src/types';
76
import { useSliceConfig } from '@/src/composables/useSliceConfig';
87
import { useViewStore } from '@/src/store/views';
98
import { get2DViewingVectors } from '@/src/utils/getViewingVectors';
9+
import { getEffectiveViewAxis } from '@/src/core/cine/getEffectiveViewAxis';
1010

1111
/**
1212
* Returns information about the current slice.
@@ -29,10 +29,9 @@ export function useSliceInfo(
2929
return computed(() => {
3030
if (!view.value || view.value.type !== '2D') return null;
3131

32-
const { orientation } = view.value.options;
33-
const { viewDirection } = get2DViewingVectors(orientation);
32+
const axis = getEffectiveViewAxis(view.value, unref(imageID));
33+
const { viewDirection } = get2DViewingVectors(axis);
3434
const { lpsOrientation } = imageMetadata.value;
35-
const axis = getLPSAxisFromDir(viewDirection);
3635
const planeOrigin = [0, 0, 0] as Vector3;
3736
planeOrigin[lpsOrientation[axis]] = slice.value;
3837
return {

src/store/tools/crosshairs.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import vtkBoundingBox from '@kitware/vtk.js/Common/DataModel/BoundingBox';
55
import { computed, ref, unref, watch } from 'vue';
66
import { vec3 } from 'gl-matrix';
77
import { defineStore } from 'pinia';
8-
import { getLPSAxisFromDir } from '@/src/utils/lps';
98
import { Manifest, StateFile } from '@/src/io/state-file/schema';
109
import { useViewStore } from '@/src/store/views';
1110
import useViewSliceStore from '@/src/store/view-configs/slicing';
1211
import { ViewInfo2D } from '@/src/types/views';
13-
import { get2DViewingVectors } from '@/src/utils/getViewingVectors';
12+
import { getEffectiveViewAxis } from '@/src/core/cine/getEffectiveViewAxis';
1413

1514
export const useCrosshairsToolStore = defineStore('crosshairs', () => {
1615
type _This = ReturnType<typeof useCrosshairsToolStore>;
@@ -64,9 +63,7 @@ export const useCrosshairsToolStore = defineStore('crosshairs', () => {
6463
const { lpsOrientation } = unref(currentImageMetadata);
6564

6665
otherViews.value.forEach((view) => {
67-
const { orientation } = view.options;
68-
const { viewDirection } = get2DViewingVectors(orientation);
69-
const axis = getLPSAxisFromDir(viewDirection);
66+
const axis = getEffectiveViewAxis(view, imageID);
7067
const index = lpsOrientation[axis];
7168
const slice = Math.round(indexPos[index]);
7269
viewSliceStore.updateConfig(view.id, imageID, { slice });

0 commit comments

Comments
 (0)