Skip to content

Commit 696ba9a

Browse files
committed
fix(ScalarProbe): calculate position from IJK
Better shortening of long values and layer names
1 parent 448cdee commit 696ba9a

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/components/ProbeView.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ const formattedProbeItems = computed(() => {
1616
// Add additional item for Position
1717
const positionItem = {
1818
label: 'Position',
19-
value: probeData.value.pos.map(Math.round).join(', '),
19+
value: Array.from(probeData.value.pos)
20+
.map((value) => {
21+
return Number(value).toPrecision(4);
22+
})
23+
.join(', '),
2024
};
2125
2226
return [...sampleItems, positionItem];
@@ -30,11 +34,17 @@ const formattedProbeItems = computed(() => {
3034
v-for="(item, index) in formattedProbeItems"
3135
:key="index"
3236
class="d-flex"
37+
style="max-width: 100%"
3338
>
34-
<span class="text-left text-truncate mr-2">
39+
<span
40+
class="text-left text-truncate mr-2 flex-grow-0 flex-shrink-1"
41+
style="min-width: 6rem; max-width: 50%"
42+
>
3543
{{ item.label }}
3644
</span>
37-
<span class="text-right ml-auto font-weight-bold">
45+
<span
46+
class="text-right font-weight-bold text-truncate flex-grow-1 flex-shrink-1"
47+
>
3848
{{ item.value }}
3949
</span>
4050
</div>

src/components/tools/ScalarProbe.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { inject, watch, computed, toRefs } from 'vue';
3+
import type { ReadonlyVec3 } from 'gl-matrix';
34
import { onVTKEvent } from '@/src/composables/onVTKEvent';
45
import { VtkViewContext } from '@/src/components/vtk/context';
56
import { useCurrentImage } from '@/src/composables/useCurrentImage';
@@ -101,10 +102,13 @@ watch(
101102
);
102103
103104
const getImageSamples = (x: number, y: number) => {
105+
const firstToSample = sampleSet.value[0];
106+
if (!firstToSample) return undefined;
107+
104108
pointPicker.pick([x, y, 1.0], view.renderer);
105109
if (pointPicker.getActors().length === 0) return undefined;
106110
107-
const ijk = pointPicker.getPointIJK();
111+
const ijk = pointPicker.getPointIJK() as unknown as ReadonlyVec3;
108112
const samples = sampleSet.value.map((item: any) => {
109113
const dims = item.image.getDimensions();
110114
const scalarData = item.image.getPointData().getScalars();
@@ -123,8 +127,10 @@ const getImageSamples = (x: number, y: number) => {
123127
return { ...baseInfo, displayValue: scalars };
124128
});
125129
130+
const position = firstToSample.image.indexToWorld(ijk);
131+
126132
return {
127-
pos: pointPicker.getPickPosition(),
133+
pos: position,
128134
samples,
129135
};
130136
};

src/store/probe.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ref } from 'vue';
22
import { defineStore } from 'pinia';
3+
import { vec3 } from 'gl-matrix';
34

45
export type ProbeSample = {
56
id: string;
@@ -9,7 +10,7 @@ export type ProbeSample = {
910

1011
export type ProbeData =
1112
| {
12-
pos: number[];
13+
pos: vec3;
1314
samples: ProbeSample[];
1415
}
1516
| undefined;

0 commit comments

Comments
 (0)