@3cr/viewer-browser 0.0.53 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/index.spec.ts +31 -0
- package/components.d.ts +2 -2
- package/coverage/3cr-viewer-browser/index.html +116 -0
- package/coverage/3cr-viewer-browser/index.ts.html +211 -0
- package/coverage/3cr-viewer-browser/src/App.vue.html +313 -0
- package/coverage/3cr-viewer-browser/src/components/WebGL3DR.vue.html +442 -0
- package/coverage/3cr-viewer-browser/src/components/icons/index.html +116 -0
- package/coverage/3cr-viewer-browser/src/components/icons/liver.vue.html +148 -0
- package/coverage/3cr-viewer-browser/src/components/index.html +116 -0
- package/coverage/3cr-viewer-browser/src/components/loading/LoadingSpinner.vue.html +556 -0
- package/coverage/3cr-viewer-browser/src/components/loading/index.html +116 -0
- package/coverage/3cr-viewer-browser/src/components/modal/MftpWebGL3DRModal.vue.html +3931 -0
- package/coverage/3cr-viewer-browser/src/components/modal/index.html +116 -0
- package/coverage/3cr-viewer-browser/src/components/selectors/ValueSelector.vue.html +331 -0
- package/coverage/3cr-viewer-browser/src/components/selectors/index.html +116 -0
- package/coverage/3cr-viewer-browser/src/components/sliders/DoubleSliderSelector.vue.html +445 -0
- package/coverage/3cr-viewer-browser/src/components/sliders/VerticalSliderSelector.vue.html +349 -0
- package/coverage/3cr-viewer-browser/src/components/sliders/index.html +131 -0
- package/coverage/3cr-viewer-browser/src/helpers/index.html +146 -0
- package/coverage/3cr-viewer-browser/src/helpers/layoutOverlayStyle.ts.html +406 -0
- package/coverage/3cr-viewer-browser/src/helpers/modelHelper.ts.html +412 -0
- package/coverage/3cr-viewer-browser/src/helpers/utils.ts.html +133 -0
- package/coverage/3cr-viewer-browser/src/index.html +131 -0
- package/coverage/3cr-viewer-browser/src/main.ts.html +124 -0
- package/coverage/3cr-viewer-browser/src/plugins/index.html +131 -0
- package/coverage/3cr-viewer-browser/src/plugins/index.ts.html +130 -0
- package/coverage/3cr-viewer-browser/src/plugins/vuetify.ts.html +220 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +251 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/dist/Viewer3CR.js +17 -11
- package/dist/Viewer3CR.mjs +5352 -5183
- package/dist/Viewer3CR.umd.js +17 -11
- package/index.html +4 -1
- package/index.ts +16 -12
- package/package.json +8 -3
- package/src/App.vue +1 -9
- package/src/__tests__/app.spec.ts +27 -0
- package/src/components/WebGL3DR.vue +49 -37
- package/src/components/__tests__/webgl3dr.spec.ts +56 -0
- package/src/components/icons/liver.vue +21 -0
- package/src/components/loading/__tests__/loading-spinner.spec.ts +11 -0
- package/src/components/modal/MftpWebGL3DRModal.vue +662 -394
- package/src/components/modal/__tests__/mftp-webgl-3dr-modal.spec.ts +690 -0
- package/src/components/selectors/__tests__/value-selector.spec.ts +35 -0
- package/src/components/sliders/DoubleSliderSelector.vue +30 -24
- package/src/components/sliders/VerticalSliderSelector.vue +25 -21
- package/src/components/sliders/__tests__/double-slider-selector.spec.ts +72 -0
- package/src/components/sliders/__tests__/vertical-slider-selector.spec.ts +61 -0
- package/src/helpers/__tests__/layout-overlay-style.spec.ts +288 -0
- package/src/helpers/__tests__/model-helper.spec.ts +118 -0
- package/src/helpers/__tests__/utils.spec.ts +70 -0
- package/src/helpers/layoutOverlayStyle.ts +50 -30
- package/src/plugins/__tests__/index.spec.ts +19 -0
- package/src/plugins/__tests__/vuetify.spec.ts +8 -0
- package/src/plugins/vuetify.ts +25 -8
- package/test/helper.ts +35 -0
- package/test/setup.ts +1 -0
- package/tsconfig.json +5 -2
- package/vite.config.mts +1 -0
- package/vitest.config.mts +44 -0
- package/src/components/expansion-panels/ExpansionHeaderMiniMenu.vue +0 -19
- package/src/helpers/models.ts +0 -69
- /package/src/components/{sliders/SliderSelector.vue → selectors/ValueSelector.vue} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {computed, defineEmits, ref, unref, watch} from
|
|
2
|
+
import { computed, defineEmits, ref, unref, watch } from "vue";
|
|
3
3
|
|
|
4
4
|
export interface Props {
|
|
5
5
|
value: Array<number>;
|
|
@@ -12,7 +12,7 @@ export interface Props {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const props = withDefaults(defineProps<Props>(), {
|
|
15
|
-
value: () =>
|
|
15
|
+
value: () => [0, 0],
|
|
16
16
|
loading: false,
|
|
17
17
|
label: "Test",
|
|
18
18
|
lower: 0,
|
|
@@ -22,38 +22,42 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const emit = defineEmits<{
|
|
25
|
-
|
|
25
|
+
"update:value": [Array<number>];
|
|
26
26
|
}>();
|
|
27
27
|
|
|
28
|
-
const prevValue = ref<Array<number>>([])
|
|
29
|
-
const showThumb = ref<"always" | boolean>(false)
|
|
30
|
-
const showThumbTimeout = ref<
|
|
28
|
+
const prevValue = ref<Array<number>>([]);
|
|
29
|
+
const showThumb = ref<"always" | boolean>(false);
|
|
30
|
+
const showThumbTimeout = ref<NodeJS.Timeout | undefined>(undefined);
|
|
31
31
|
const sliderValue = computed({
|
|
32
32
|
get() {
|
|
33
|
-
return props.value
|
|
33
|
+
return props.value;
|
|
34
34
|
},
|
|
35
35
|
set(value: Array<number>) {
|
|
36
|
-
emit(
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
watch(sliderValue, async (currentValue: Array<number>) => {
|
|
41
|
-
if (JSON.stringify(unref(prevValue)) !== JSON.stringify(currentValue)) {
|
|
42
|
-
clearTimeout(unref(showThumbTimeout));
|
|
43
|
-
showThumb.value = 'always';
|
|
44
|
-
showThumbTimeout.value = setTimeout(() => {
|
|
45
|
-
showThumb.value = true;
|
|
46
|
-
}, 1000);
|
|
47
|
-
}
|
|
48
|
-
prevValue.value = currentValue;
|
|
49
|
-
}, {deep: true})
|
|
50
|
-
|
|
36
|
+
emit("update:value", value);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
51
39
|
|
|
40
|
+
watch(
|
|
41
|
+
sliderValue,
|
|
42
|
+
async (currentValue: Array<number>) => {
|
|
43
|
+
if (JSON.stringify(unref(prevValue)) !== JSON.stringify(currentValue)) {
|
|
44
|
+
clearTimeout(unref(showThumbTimeout));
|
|
45
|
+
showThumb.value = "always";
|
|
46
|
+
showThumbTimeout.value = setTimeout(() => {
|
|
47
|
+
showThumb.value = true;
|
|
48
|
+
}, 1000);
|
|
49
|
+
}
|
|
50
|
+
prevValue.value = currentValue;
|
|
51
|
+
},
|
|
52
|
+
{ deep: true }
|
|
53
|
+
);
|
|
52
54
|
</script>
|
|
53
55
|
|
|
54
56
|
<template>
|
|
55
57
|
<div class="double-slider-selector">
|
|
56
|
-
<v-card-subtitle class="pb-0 pt-1 text-caption">{{
|
|
58
|
+
<v-card-subtitle class="pb-0 pt-1 text-caption">{{
|
|
59
|
+
label
|
|
60
|
+
}}</v-card-subtitle>
|
|
57
61
|
<v-card-actions class="px-2 pb-0">
|
|
58
62
|
<v-text-field
|
|
59
63
|
v-model="sliderValue[0]"
|
|
@@ -95,7 +99,9 @@ watch(sliderValue, async (currentValue: Array<number>) => {
|
|
|
95
99
|
.v-text-field.v-text-field--enclosed:not(.v-text-field--rounded)
|
|
96
100
|
> .v-input__control
|
|
97
101
|
> .v-input__slot,
|
|
98
|
-
.double-slider-selector
|
|
102
|
+
.double-slider-selector
|
|
103
|
+
.v-text-field.v-text-field--enclosed
|
|
104
|
+
.v-text-field__details {
|
|
99
105
|
padding: 0px 8px !important;
|
|
100
106
|
}
|
|
101
107
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {computed, defineEmits, ref, unref, watch} from
|
|
2
|
+
import { computed, defineEmits, ref, unref, watch } from "vue";
|
|
3
3
|
|
|
4
4
|
export interface Props {
|
|
5
5
|
value: number;
|
|
@@ -22,32 +22,35 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const emit = defineEmits<{
|
|
25
|
-
|
|
25
|
+
"update:value": [number];
|
|
26
26
|
}>();
|
|
27
27
|
|
|
28
|
-
const prevValue = ref<number>(0)
|
|
29
|
-
const showThumb = ref<"always" | boolean>(true)
|
|
30
|
-
const showThumbTimeout = ref<
|
|
28
|
+
const prevValue = ref<number>(0);
|
|
29
|
+
const showThumb = ref<"always" | boolean>(true);
|
|
30
|
+
const showThumbTimeout = ref<NodeJS.Timeout | undefined>(undefined);
|
|
31
31
|
const sliderValue = computed({
|
|
32
32
|
get() {
|
|
33
|
-
return props.value
|
|
33
|
+
return props.value;
|
|
34
34
|
},
|
|
35
35
|
set(value: number) {
|
|
36
|
-
emit(
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
watch(sliderValue, async (currentValue: number) => {
|
|
41
|
-
if (JSON.stringify(unref(prevValue)) !== JSON.stringify(currentValue)) {
|
|
42
|
-
clearTimeout(unref(showThumbTimeout));
|
|
43
|
-
showThumb.value = 'always';
|
|
44
|
-
showThumbTimeout.value = setTimeout(() => {
|
|
45
|
-
showThumb.value = true;
|
|
46
|
-
}, 1000);
|
|
47
|
-
}
|
|
48
|
-
prevValue.value = currentValue;
|
|
49
|
-
}, {deep: true})
|
|
36
|
+
emit("update:value", value);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
50
39
|
|
|
40
|
+
watch(
|
|
41
|
+
sliderValue,
|
|
42
|
+
async (currentValue: number) => {
|
|
43
|
+
if (JSON.stringify(unref(prevValue)) !== JSON.stringify(currentValue)) {
|
|
44
|
+
clearTimeout(unref(showThumbTimeout));
|
|
45
|
+
showThumb.value = "always";
|
|
46
|
+
showThumbTimeout.value = setTimeout(() => {
|
|
47
|
+
showThumb.value = true;
|
|
48
|
+
}, 1000);
|
|
49
|
+
}
|
|
50
|
+
prevValue.value = currentValue;
|
|
51
|
+
},
|
|
52
|
+
{ deep: true }
|
|
53
|
+
);
|
|
51
54
|
</script>
|
|
52
55
|
|
|
53
56
|
<template>
|
|
@@ -76,7 +79,8 @@ watch(sliderValue, async (currentValue: number) => {
|
|
|
76
79
|
<style lang="scss">
|
|
77
80
|
.vertical-slider-selector .v-slider-thumb__label {
|
|
78
81
|
width: 40px !important;
|
|
79
|
-
transform: translateY(-0px) translateX(-32px) translateX(-100%)
|
|
82
|
+
transform: translateY(-0px) translateX(-32px) translateX(-100%)
|
|
83
|
+
rotate(-180deg) !important;
|
|
80
84
|
& div {
|
|
81
85
|
transform: rotate(180deg);
|
|
82
86
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { checkComponentProps, mountVuetify } from "~/helper";
|
|
4
|
+
import DoubleSliderSelector from "@/components/sliders/DoubleSliderSelector.vue";
|
|
5
|
+
import { flushPromises } from "@vue/test-utils";
|
|
6
|
+
|
|
7
|
+
describe("DoubleSliderSelector.vue", () => {
|
|
8
|
+
let wrapper = mountVuetify(DoubleSliderSelector, {
|
|
9
|
+
value: [0, 0],
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
wrapper = mountVuetify(DoubleSliderSelector, {
|
|
14
|
+
value: [0, 0],
|
|
15
|
+
});
|
|
16
|
+
vi.useFakeTimers();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
vi.useRealTimers();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should inflate component", () => {
|
|
24
|
+
expect(wrapper).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should change from props", async () => {
|
|
28
|
+
await wrapper.setProps({
|
|
29
|
+
value: [1, 1],
|
|
30
|
+
});
|
|
31
|
+
await flushPromises();
|
|
32
|
+
expect(wrapper.vm.value).toStrictEqual([1, 1]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should timeout the thumb", async () => {
|
|
36
|
+
await wrapper.setProps({
|
|
37
|
+
value: [1, 1],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const slider = wrapper.findComponent(".v-range-slider");
|
|
41
|
+
|
|
42
|
+
await flushPromises();
|
|
43
|
+
expect(wrapper.vm.value).toStrictEqual([1, 1]);
|
|
44
|
+
await wrapper.setProps({
|
|
45
|
+
value: [1, 1],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
vi.advanceTimersByTime(999);
|
|
49
|
+
checkComponentProps(slider, "thumbLabel", "always");
|
|
50
|
+
// expect(slider.props()["thumbLabel"] as any).toBe("always");
|
|
51
|
+
vi.advanceTimersByTime(1);
|
|
52
|
+
await flushPromises();
|
|
53
|
+
expect(wrapper.vm.value).toStrictEqual([1, 1]);
|
|
54
|
+
checkComponentProps(slider, "thumbLabel", true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should set slider value", async () => {
|
|
58
|
+
const slider = wrapper.findComponent(".v-range-slider");
|
|
59
|
+
await slider.setValue([1, 2]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should set min text", async () => {
|
|
63
|
+
const slider = wrapper.findAllComponents(".v-text-field");
|
|
64
|
+
|
|
65
|
+
await slider[0].setValue(10);
|
|
66
|
+
});
|
|
67
|
+
it("should set max text", async () => {
|
|
68
|
+
const slider = wrapper.findAllComponents(".v-text-field");
|
|
69
|
+
|
|
70
|
+
await slider[1].setValue(20);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { checkComponentProps, mountVuetify } from "~/helper";
|
|
4
|
+
import { flushPromises } from "@vue/test-utils";
|
|
5
|
+
import VerticalSliderSelector from "@/components/sliders/VerticalSliderSelector.vue";
|
|
6
|
+
|
|
7
|
+
describe("VerticalSliderSelector.vue", () => {
|
|
8
|
+
let wrapper = mountVuetify(VerticalSliderSelector, {
|
|
9
|
+
value: 0,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
wrapper = mountVuetify(VerticalSliderSelector, {
|
|
14
|
+
value: 0,
|
|
15
|
+
});
|
|
16
|
+
vi.useFakeTimers();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
vi.useRealTimers();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should inflate component", () => {
|
|
24
|
+
expect(wrapper).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should change from props", async () => {
|
|
28
|
+
await wrapper.setProps({
|
|
29
|
+
value: 1,
|
|
30
|
+
});
|
|
31
|
+
await flushPromises();
|
|
32
|
+
expect(wrapper.vm.value).toStrictEqual(1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should timeout the thumb", async () => {
|
|
36
|
+
await wrapper.setProps({
|
|
37
|
+
value: 1,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const slider = wrapper.findComponent(".v-slider");
|
|
41
|
+
|
|
42
|
+
await flushPromises();
|
|
43
|
+
expect(wrapper.vm.value).toStrictEqual(1);
|
|
44
|
+
await wrapper.setProps({
|
|
45
|
+
value: 1,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
vi.advanceTimersByTime(999);
|
|
49
|
+
checkComponentProps(slider, "thumbLabel", "always");
|
|
50
|
+
// expect(slider.props()["thumbLabel"] as any).toBe("always");
|
|
51
|
+
vi.advanceTimersByTime(1);
|
|
52
|
+
await flushPromises();
|
|
53
|
+
expect(wrapper.vm.value).toStrictEqual(1);
|
|
54
|
+
checkComponentProps(slider, "thumbLabel", true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should set slider value", async () => {
|
|
58
|
+
const slider = wrapper.findComponent(".v-slider");
|
|
59
|
+
await slider.setValue(1);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { generateDivStyleForLayout } from "@/helpers/layoutOverlayStyle";
|
|
3
|
+
import { AnchorPoint, ScanView } from "@3cr/types-ts";
|
|
4
|
+
import { flushPromises } from "@vue/test-utils";
|
|
5
|
+
import { spyOn } from "@vitest/spy";
|
|
6
|
+
|
|
7
|
+
describe("generateDivStyleForLayout", () => {
|
|
8
|
+
it("should generateDivStyleForLayout AnchorPoint.TOP", () => {
|
|
9
|
+
expect(
|
|
10
|
+
generateDivStyleForLayout({
|
|
11
|
+
Anchor: AnchorPoint.TOP,
|
|
12
|
+
ActiveView: true,
|
|
13
|
+
AspectRatio: 0,
|
|
14
|
+
MaxSize: {
|
|
15
|
+
Version: "1.0.0",
|
|
16
|
+
X: 1,
|
|
17
|
+
Y: 1,
|
|
18
|
+
},
|
|
19
|
+
DefaultView: ScanView.Coronal,
|
|
20
|
+
Priority: 1,
|
|
21
|
+
Offset: {
|
|
22
|
+
Version: "1.0.0",
|
|
23
|
+
X: 1,
|
|
24
|
+
Y: 1,
|
|
25
|
+
},
|
|
26
|
+
Version: "1.0.0",
|
|
27
|
+
})
|
|
28
|
+
).toStrictEqual({
|
|
29
|
+
height: "calc(100% - 2px)",
|
|
30
|
+
left: "50%",
|
|
31
|
+
top: "0px",
|
|
32
|
+
transform: "translateX(-50%)",
|
|
33
|
+
width: "calc(100% - 0px)",
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should generateDivStyleForLayout AnchorPoint.BOTTOM", () => {
|
|
38
|
+
expect(
|
|
39
|
+
generateDivStyleForLayout({
|
|
40
|
+
Anchor: AnchorPoint.BOTTOM,
|
|
41
|
+
ActiveView: true,
|
|
42
|
+
AspectRatio: 0,
|
|
43
|
+
MaxSize: {
|
|
44
|
+
Version: "1.0.0",
|
|
45
|
+
X: 1,
|
|
46
|
+
Y: 1,
|
|
47
|
+
},
|
|
48
|
+
DefaultView: ScanView.Coronal,
|
|
49
|
+
Priority: 1,
|
|
50
|
+
Offset: {
|
|
51
|
+
Version: "1.0.0",
|
|
52
|
+
X: 1,
|
|
53
|
+
Y: 1,
|
|
54
|
+
},
|
|
55
|
+
Version: "1.0.0",
|
|
56
|
+
})
|
|
57
|
+
).toStrictEqual({
|
|
58
|
+
height: "calc(100% - 2px)",
|
|
59
|
+
left: "50%",
|
|
60
|
+
bottom: "4px",
|
|
61
|
+
transform: "translateX(-50%)",
|
|
62
|
+
width: "calc(100% - 0px)",
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should generateDivStyleForLayout AnchorPoint.LEFT", () => {
|
|
67
|
+
expect(
|
|
68
|
+
generateDivStyleForLayout({
|
|
69
|
+
Anchor: AnchorPoint.LEFT,
|
|
70
|
+
ActiveView: true,
|
|
71
|
+
AspectRatio: 0,
|
|
72
|
+
MaxSize: {
|
|
73
|
+
Version: "1.0.0",
|
|
74
|
+
X: 1,
|
|
75
|
+
Y: 1,
|
|
76
|
+
},
|
|
77
|
+
DefaultView: ScanView.Coronal,
|
|
78
|
+
Priority: 1,
|
|
79
|
+
Offset: {
|
|
80
|
+
Version: "1.0.0",
|
|
81
|
+
X: 1,
|
|
82
|
+
Y: 1,
|
|
83
|
+
},
|
|
84
|
+
Version: "1.0.0",
|
|
85
|
+
})
|
|
86
|
+
).toStrictEqual({
|
|
87
|
+
height: "calc(100% - 2px)",
|
|
88
|
+
left: "0px",
|
|
89
|
+
top: "50%",
|
|
90
|
+
transform: "translateY(-50%)",
|
|
91
|
+
width: "calc(100% - 0px)",
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("should generateDivStyleForLayout AnchorPoint.RIGHT", () => {
|
|
96
|
+
expect(
|
|
97
|
+
generateDivStyleForLayout({
|
|
98
|
+
Anchor: AnchorPoint.RIGHT,
|
|
99
|
+
ActiveView: true,
|
|
100
|
+
AspectRatio: 0,
|
|
101
|
+
MaxSize: {
|
|
102
|
+
Version: "1.0.0",
|
|
103
|
+
X: 1,
|
|
104
|
+
Y: 1,
|
|
105
|
+
},
|
|
106
|
+
DefaultView: ScanView.Coronal,
|
|
107
|
+
Priority: 1,
|
|
108
|
+
Offset: {
|
|
109
|
+
Version: "1.0.0",
|
|
110
|
+
X: 1,
|
|
111
|
+
Y: 1,
|
|
112
|
+
},
|
|
113
|
+
Version: "1.0.0",
|
|
114
|
+
})
|
|
115
|
+
).toStrictEqual({
|
|
116
|
+
height: "calc(100% - 2px)",
|
|
117
|
+
right: "0px",
|
|
118
|
+
top: "50%",
|
|
119
|
+
transform: "translateY(-50%)",
|
|
120
|
+
width: "calc(100% - 0px)",
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("should generateDivStyleForLayout AnchorPoint.TOP_LEFT", () => {
|
|
125
|
+
expect(
|
|
126
|
+
generateDivStyleForLayout({
|
|
127
|
+
Anchor: AnchorPoint.TOP_LEFT,
|
|
128
|
+
ActiveView: true,
|
|
129
|
+
AspectRatio: 0,
|
|
130
|
+
MaxSize: {
|
|
131
|
+
Version: "1.0.0",
|
|
132
|
+
X: 1,
|
|
133
|
+
Y: 1,
|
|
134
|
+
},
|
|
135
|
+
DefaultView: ScanView.Coronal,
|
|
136
|
+
Priority: 1,
|
|
137
|
+
Offset: {
|
|
138
|
+
Version: "1.0.0",
|
|
139
|
+
X: 1,
|
|
140
|
+
Y: 1,
|
|
141
|
+
},
|
|
142
|
+
Version: "1.0.0",
|
|
143
|
+
})
|
|
144
|
+
).toStrictEqual({
|
|
145
|
+
"border-top-left-radius": "0px",
|
|
146
|
+
height: "calc(100% - 2px)",
|
|
147
|
+
left: "0px",
|
|
148
|
+
top: "0px",
|
|
149
|
+
width: "calc(100% - 0px)",
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("should generateDivStyleForLayout AnchorPoint.CENTER", () => {
|
|
154
|
+
expect(
|
|
155
|
+
generateDivStyleForLayout({
|
|
156
|
+
Anchor: AnchorPoint.CENTER,
|
|
157
|
+
ActiveView: true,
|
|
158
|
+
AspectRatio: 0,
|
|
159
|
+
MaxSize: {
|
|
160
|
+
Version: "1.0.0",
|
|
161
|
+
X: 1,
|
|
162
|
+
Y: 1,
|
|
163
|
+
},
|
|
164
|
+
DefaultView: ScanView.Coronal,
|
|
165
|
+
Priority: 1,
|
|
166
|
+
Offset: {
|
|
167
|
+
Version: "1.0.0",
|
|
168
|
+
X: 1,
|
|
169
|
+
Y: 1,
|
|
170
|
+
},
|
|
171
|
+
Version: "1.0.0",
|
|
172
|
+
})
|
|
173
|
+
).toStrictEqual({
|
|
174
|
+
"border-bottom-left-radius": "0px",
|
|
175
|
+
"border-bottom-right-radius": "0px",
|
|
176
|
+
"border-top-left-radius": "0px",
|
|
177
|
+
"border-top-right-radius": "0px",
|
|
178
|
+
height: "calc(100% - 2px - 2px)",
|
|
179
|
+
left: "0px",
|
|
180
|
+
top: "0px",
|
|
181
|
+
width: "calc(100% - 0px - 0px)",
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("should generateDivStyleForLayout AspectRatio === 1", async () => {
|
|
186
|
+
spyOn(document, "getElementById").mockReturnValue({
|
|
187
|
+
id: "unity-canvas",
|
|
188
|
+
offsetWidth: 1,
|
|
189
|
+
offsetHeight: 2,
|
|
190
|
+
} as HTMLElement);
|
|
191
|
+
await flushPromises();
|
|
192
|
+
expect(
|
|
193
|
+
generateDivStyleForLayout({
|
|
194
|
+
Anchor: AnchorPoint.CENTER,
|
|
195
|
+
ActiveView: true,
|
|
196
|
+
AspectRatio: 1,
|
|
197
|
+
MaxSize: {
|
|
198
|
+
Version: "1.0.0",
|
|
199
|
+
X: 1,
|
|
200
|
+
Y: 1,
|
|
201
|
+
},
|
|
202
|
+
DefaultView: ScanView.Coronal,
|
|
203
|
+
Priority: 1,
|
|
204
|
+
Offset: {
|
|
205
|
+
Version: "1.0.0",
|
|
206
|
+
X: 1,
|
|
207
|
+
Y: 1,
|
|
208
|
+
},
|
|
209
|
+
Version: "1.0.0",
|
|
210
|
+
})
|
|
211
|
+
).toStrictEqual({
|
|
212
|
+
"border-bottom-left-radius": "0px",
|
|
213
|
+
"border-bottom-right-radius": "0px",
|
|
214
|
+
"border-top-left-radius": "0px",
|
|
215
|
+
"border-top-right-radius": "0px",
|
|
216
|
+
height: "calc(1px)",
|
|
217
|
+
left: "0px",
|
|
218
|
+
top: "0px",
|
|
219
|
+
width: "calc(2px)",
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("should generateDivStyleForLayout AspectRatio === 1", async () => {
|
|
224
|
+
spyOn(document, "getElementById").mockReturnValue(null);
|
|
225
|
+
await flushPromises();
|
|
226
|
+
expect(
|
|
227
|
+
generateDivStyleForLayout({
|
|
228
|
+
Anchor: AnchorPoint.CENTER,
|
|
229
|
+
ActiveView: true,
|
|
230
|
+
AspectRatio: 1,
|
|
231
|
+
MaxSize: {
|
|
232
|
+
Version: "1.0.0",
|
|
233
|
+
X: 1,
|
|
234
|
+
Y: 1,
|
|
235
|
+
},
|
|
236
|
+
DefaultView: ScanView.Coronal,
|
|
237
|
+
Priority: 1,
|
|
238
|
+
Offset: {
|
|
239
|
+
Version: "1.0.0",
|
|
240
|
+
X: 1,
|
|
241
|
+
Y: 1,
|
|
242
|
+
},
|
|
243
|
+
Version: "1.0.0",
|
|
244
|
+
})
|
|
245
|
+
).toStrictEqual({
|
|
246
|
+
"border-bottom-left-radius": "0px",
|
|
247
|
+
"border-bottom-right-radius": "0px",
|
|
248
|
+
"border-top-left-radius": "0px",
|
|
249
|
+
"border-top-right-radius": "0px",
|
|
250
|
+
height: "calc(0px)",
|
|
251
|
+
left: "0px",
|
|
252
|
+
top: "0px",
|
|
253
|
+
width: "calc(0px)",
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it("should generateDivStyleForLayout AspectRatio === 1 | MaxSize === 0", async () => {
|
|
258
|
+
expect(
|
|
259
|
+
generateDivStyleForLayout({
|
|
260
|
+
Anchor: AnchorPoint.CENTER,
|
|
261
|
+
ActiveView: true,
|
|
262
|
+
AspectRatio: 1,
|
|
263
|
+
MaxSize: {
|
|
264
|
+
Version: "1.0.0",
|
|
265
|
+
X: 0,
|
|
266
|
+
Y: 0,
|
|
267
|
+
},
|
|
268
|
+
DefaultView: ScanView.Coronal,
|
|
269
|
+
Priority: 1,
|
|
270
|
+
Offset: {
|
|
271
|
+
Version: "1.0.0",
|
|
272
|
+
X: 1,
|
|
273
|
+
Y: 1,
|
|
274
|
+
},
|
|
275
|
+
Version: "1.0.0",
|
|
276
|
+
})
|
|
277
|
+
).toStrictEqual({
|
|
278
|
+
"border-bottom-left-radius": "0px",
|
|
279
|
+
"border-bottom-right-radius": "0px",
|
|
280
|
+
"border-top-left-radius": "0px",
|
|
281
|
+
"border-top-right-radius": "0px",
|
|
282
|
+
height: "calc(0% - 2px - 2px)",
|
|
283
|
+
left: "0px",
|
|
284
|
+
top: "0px",
|
|
285
|
+
width: "calc(0% - 0px - 0px)",
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { AnchorPoint, ScanView, ViewInteractiveMode } from "@3cr/types-ts";
|
|
3
|
+
import {
|
|
4
|
+
inflateInitialScanState,
|
|
5
|
+
inflateScanState,
|
|
6
|
+
} from "@/helpers/modelHelper";
|
|
7
|
+
|
|
8
|
+
describe("inflateScanState", () => {
|
|
9
|
+
it("should inflateScanState", () => {
|
|
10
|
+
expect(inflateScanState()).toStrictEqual({
|
|
11
|
+
Version: "1.0.0",
|
|
12
|
+
Display: {
|
|
13
|
+
Version: "1.0.0",
|
|
14
|
+
Brightness: 50,
|
|
15
|
+
Contrast: 50,
|
|
16
|
+
Opacity: 50,
|
|
17
|
+
WindowLower: 0,
|
|
18
|
+
WindowUpper: 100,
|
|
19
|
+
ThresholdLower: 0,
|
|
20
|
+
ThresholdUpper: 100,
|
|
21
|
+
},
|
|
22
|
+
CurrentView: ScanView.Volume,
|
|
23
|
+
Slice: {
|
|
24
|
+
Version: "1.0.0",
|
|
25
|
+
TransverseLower: 0,
|
|
26
|
+
TransverseUpper: 0,
|
|
27
|
+
SagittalLower: 0,
|
|
28
|
+
SagittalUpper: 0,
|
|
29
|
+
CoronalLower: 0,
|
|
30
|
+
CoronalUpper: 0,
|
|
31
|
+
},
|
|
32
|
+
InteractionSettings: {
|
|
33
|
+
Version: "1.0.0",
|
|
34
|
+
PanSensivitity: 0,
|
|
35
|
+
ZoomSensitivity: 0,
|
|
36
|
+
RotateSensitivity: 0,
|
|
37
|
+
CameraRotateSensitivity: 0,
|
|
38
|
+
KeyboardEnabled: true,
|
|
39
|
+
MouseEnabled: true,
|
|
40
|
+
InteractionMode: ViewInteractiveMode.STATIC,
|
|
41
|
+
},
|
|
42
|
+
Orientations: {
|
|
43
|
+
Version: "1.0.0",
|
|
44
|
+
Transverse: {
|
|
45
|
+
Version: "1.0.0",
|
|
46
|
+
View: ScanView.Transverse,
|
|
47
|
+
VFlip: false,
|
|
48
|
+
HFlip: false,
|
|
49
|
+
Rotation: 0,
|
|
50
|
+
Slice: 0,
|
|
51
|
+
},
|
|
52
|
+
Sagittal: {
|
|
53
|
+
Version: "1.0.0",
|
|
54
|
+
View: ScanView.Transverse,
|
|
55
|
+
VFlip: false,
|
|
56
|
+
HFlip: false,
|
|
57
|
+
Rotation: 0,
|
|
58
|
+
Slice: 0,
|
|
59
|
+
},
|
|
60
|
+
Coronal: {
|
|
61
|
+
Version: "1.0.0",
|
|
62
|
+
View: ScanView.Transverse,
|
|
63
|
+
VFlip: false,
|
|
64
|
+
HFlip: false,
|
|
65
|
+
Rotation: 0,
|
|
66
|
+
Slice: 0,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
Layout: {
|
|
70
|
+
Version: "1.0.0",
|
|
71
|
+
SwitchOnViewChange: false,
|
|
72
|
+
PositionData: [],
|
|
73
|
+
},
|
|
74
|
+
NavigationCube: {
|
|
75
|
+
Version: "1.0.0",
|
|
76
|
+
Transform: {
|
|
77
|
+
Version: "1.0.0",
|
|
78
|
+
AnchorPoint: AnchorPoint.DEFAULT,
|
|
79
|
+
Position: {
|
|
80
|
+
Version: "1.0.0",
|
|
81
|
+
X: 0,
|
|
82
|
+
Y: 0,
|
|
83
|
+
},
|
|
84
|
+
Size: {
|
|
85
|
+
Version: "1.0.0",
|
|
86
|
+
X: 0,
|
|
87
|
+
Y: 0,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
Visibility: {
|
|
91
|
+
Version: "1.0.0",
|
|
92
|
+
Value: false,
|
|
93
|
+
},
|
|
94
|
+
Interactivity: {
|
|
95
|
+
Version: "1.0.0",
|
|
96
|
+
Value: false,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe("inflateInitialScanState", () => {
|
|
104
|
+
it("should inflateInitialScanState", () => {
|
|
105
|
+
expect(inflateInitialScanState()).toStrictEqual({
|
|
106
|
+
Version: "1.0.0",
|
|
107
|
+
XSlices: 0,
|
|
108
|
+
YSlices: 0,
|
|
109
|
+
ZSlices: 0,
|
|
110
|
+
Modality: "CT",
|
|
111
|
+
HuUpper: 0,
|
|
112
|
+
HuLower: 0,
|
|
113
|
+
DefaultDisplaySettings: inflateScanState(),
|
|
114
|
+
GreyscalePresets: [],
|
|
115
|
+
ColourPresets: [],
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|