Skip to content

Commit a66d1cf

Browse files
committed
fix(tools): show frame number in cine measurement details
Measurement details rendered "Slice: 1" for ruler/polygon/rectangle annotations on cine ultrasound, because cine annotations store `frame` and pin `slice` to 0. Display "Frame: N" when `tool.frame` is set.
1 parent 2806264 commit a66d1cf

3 files changed

Lines changed: 76 additions & 2 deletions

File tree

src/components/MeasurementRulerDetails.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ const toolStore = useRulerStore();
1111

1212
<template>
1313
<v-row>
14-
<v-col cols="4">Slice: {{ tool.slice + 1 }}</v-col>
14+
<v-col v-if="tool.frame != null" cols="4">
15+
Frame: {{ tool.frame + 1 }}
16+
</v-col>
17+
<v-col v-else cols="4">Slice: {{ tool.slice + 1 }}</v-col>
1518
<v-col cols="4">Axis: {{ tool.axis }}</v-col>
1619
<v-col>
1720
Length:

src/components/MeasurementToolDetails.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ defineProps<{
88

99
<template>
1010
<v-row>
11-
<v-col cols="4">Slice: {{ tool.slice + 1 }}</v-col>
11+
<v-col v-if="tool.frame != null" cols="4">
12+
Frame: {{ tool.frame + 1 }}
13+
</v-col>
14+
<v-col v-else cols="4">Slice: {{ tool.slice + 1 }}</v-col>
1215
<v-col cols="4">Axis: {{ tool.axis }}</v-col>
1316
</v-row>
1417
</template>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { mount } from '@vue/test-utils';
2+
import { describe, expect, it, vi } from 'vitest';
3+
import MeasurementToolDetails from '@/src/components/MeasurementToolDetails.vue';
4+
import MeasurementRulerDetails from '@/src/components/MeasurementRulerDetails.vue';
5+
import { ToolID } from '@/src/types/annotation-tool';
6+
7+
vi.mock('@/src/store/tools/rulers', () => ({
8+
useRulerStore: () => ({
9+
lengthByID: { 'tool-1': 12.345 },
10+
}),
11+
}));
12+
13+
const stubs = {
14+
'v-row': { template: '<div><slot /></div>' },
15+
'v-col': { template: '<div><slot /></div>' },
16+
};
17+
18+
const baseTool = {
19+
id: 'tool-1' as ToolID,
20+
imageID: 'img-1',
21+
frameOfReference: {
22+
planeOrigin: [0, 0, 0] as [number, number, number],
23+
planeNormal: [0, 0, 1] as [number, number, number],
24+
},
25+
color: '#fff',
26+
name: 'Tool',
27+
axis: 'Axial',
28+
};
29+
30+
describe('MeasurementToolDetails', () => {
31+
it('shows slice number for a volume annotation', () => {
32+
const wrapper = mount(MeasurementToolDetails, {
33+
props: { tool: { ...baseTool, slice: 4 } },
34+
global: { stubs },
35+
});
36+
expect(wrapper.text()).toContain('Slice: 5');
37+
expect(wrapper.text()).not.toContain('Frame:');
38+
});
39+
40+
it('shows frame number for a cine annotation', () => {
41+
const wrapper = mount(MeasurementToolDetails, {
42+
props: { tool: { ...baseTool, slice: 0, frame: 7 } },
43+
global: { stubs },
44+
});
45+
expect(wrapper.text()).toContain('Frame: 8');
46+
expect(wrapper.text()).not.toContain('Slice:');
47+
});
48+
});
49+
50+
describe('MeasurementRulerDetails', () => {
51+
it('shows slice number for a volume ruler', () => {
52+
const wrapper = mount(MeasurementRulerDetails, {
53+
props: { tool: { ...baseTool, slice: 9 } },
54+
global: { stubs },
55+
});
56+
expect(wrapper.text()).toContain('Slice: 10');
57+
expect(wrapper.text()).not.toContain('Frame:');
58+
});
59+
60+
it('shows frame number for a cine ruler', () => {
61+
const wrapper = mount(MeasurementRulerDetails, {
62+
props: { tool: { ...baseTool, slice: 0, frame: 2 } },
63+
global: { stubs },
64+
});
65+
expect(wrapper.text()).toContain('Frame: 3');
66+
expect(wrapper.text()).not.toContain('Slice:');
67+
});
68+
});

0 commit comments

Comments
 (0)