@3cr/viewer-browser 0.0.86 → 0.0.93
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/coverage/3cr-viewer-browser/index.html +1 -1
- package/coverage/3cr-viewer-browser/index.ts.html +1 -1
- package/coverage/3cr-viewer-browser/src/App.vue.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/WebGL3DR.vue.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/icons/index.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/icons/liver.vue.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/index.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/loading/LoadingSpinner.vue.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/loading/index.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/modal/MftpWebGL3DRModal.vue.html +77 -200
- package/coverage/3cr-viewer-browser/src/components/modal/index.html +17 -17
- package/coverage/3cr-viewer-browser/src/components/selectors/ValueSelector.vue.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/selectors/index.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/sliders/DoubleSliderSelector.vue.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/sliders/VerticalSliderSelector.vue.html +1 -1
- package/coverage/3cr-viewer-browser/src/components/sliders/index.html +1 -1
- package/coverage/3cr-viewer-browser/src/dataLayer/iconData.ts.html +1 -1
- package/coverage/3cr-viewer-browser/src/dataLayer/index.html +27 -27
- package/coverage/3cr-viewer-browser/src/dataLayer/payloadHandler.ts.html +185 -74
- package/coverage/3cr-viewer-browser/src/dataLayer/scanState.ts.html +11 -41
- package/coverage/3cr-viewer-browser/src/helpers/index.html +1 -1
- package/coverage/3cr-viewer-browser/src/helpers/layoutOverlayStyle.ts.html +1 -1
- package/coverage/3cr-viewer-browser/src/helpers/modelHelper.ts.html +1 -1
- package/coverage/3cr-viewer-browser/src/helpers/utils.ts.html +3 -3
- package/coverage/3cr-viewer-browser/src/index.html +1 -1
- package/coverage/3cr-viewer-browser/src/main.ts.html +1 -1
- package/coverage/3cr-viewer-browser/src/models/LoadViewerOptions.ts.html +10 -10
- package/coverage/3cr-viewer-browser/src/models/index.html +7 -7
- package/coverage/3cr-viewer-browser/src/notifications/index.html +17 -17
- package/coverage/3cr-viewer-browser/src/notifications/notification.ts.html +79 -70
- package/coverage/3cr-viewer-browser/src/plugins/index.html +1 -1
- package/coverage/3cr-viewer-browser/src/plugins/index.ts.html +1 -1
- package/coverage/3cr-viewer-browser/src/plugins/vuetify.ts.html +1 -1
- package/coverage/index.html +41 -41
- package/dist/Viewer3CR.js +11 -11
- package/dist/Viewer3CR.mjs +5371 -5375
- package/dist/Viewer3CR.umd.js +11 -11
- package/package.json +1 -1
- package/src/components/modal/MftpWebGL3DRModal.vue +33 -74
- package/src/components/modal/__tests__/mftp-webgl-3dr-modal.spec.ts +100 -148
- package/src/dataLayer/__tests__/payload-handler.spec.ts +119 -3
- package/src/dataLayer/payloadHandler.ts +39 -2
- package/src/dataLayer/scanState.ts +3 -13
- package/src/models/__tests__/load-viewer-options.spec.ts +22 -0
- package/src/notifications/__tests__/notification.spec.ts +120 -0
- package/src/notifications/notification.ts +4 -1
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
InteractivityActions,
|
|
13
13
|
NotificationPayload,
|
|
14
14
|
PositionData,
|
|
15
|
-
PresetsActions,
|
|
16
15
|
ScanMovementActions,
|
|
17
16
|
ScanStateActions,
|
|
18
17
|
ScanView,
|
|
@@ -22,12 +21,17 @@ import { flushPromises } from "@vue/test-utils";
|
|
|
22
21
|
import { PayloadHandler } from "@/dataLayer/payloadHandler";
|
|
23
22
|
import { spyOn } from "@vitest/spy";
|
|
24
23
|
import {
|
|
24
|
+
cSlider,
|
|
25
25
|
currentGreyscalePreset,
|
|
26
26
|
isLayout1x3,
|
|
27
27
|
isLayout2x2,
|
|
28
28
|
setScanState,
|
|
29
|
+
sSlider,
|
|
30
|
+
transactionStarted,
|
|
31
|
+
tSlider,
|
|
29
32
|
} from "@/dataLayer/scanState";
|
|
30
33
|
import { unref } from "vue";
|
|
34
|
+
import { isDemo } from "@/demo/options";
|
|
31
35
|
|
|
32
36
|
vi.mock("@3cr/sdk-browser", async (importOriginal) => {
|
|
33
37
|
const mod = (await importOriginal()) as object;
|
|
@@ -48,12 +52,10 @@ vi.mock("@kyvg/vue3-notification", async (importOriginal) => {
|
|
|
48
52
|
}),
|
|
49
53
|
};
|
|
50
54
|
});
|
|
51
|
-
|
|
55
|
+
let spy = spyOn(PayloadHandler.prototype, "sendPayload").mockImplementation(
|
|
56
|
+
(interfaceType: string, actionType: string, message: any) => Promise.resolve()
|
|
57
|
+
);
|
|
52
58
|
describe("MftpWebGL3DRModal.vue", () => {
|
|
53
|
-
let spy = spyOn(PayloadHandler.prototype, "sendPayload").mockImplementation(
|
|
54
|
-
(interfaceType: string, actionType: string, message: any) =>
|
|
55
|
-
Promise.resolve()
|
|
56
|
-
);
|
|
57
59
|
let wrapper = shallowMountVuetify(
|
|
58
60
|
MftpWebGL3DRModal,
|
|
59
61
|
{}
|
|
@@ -61,6 +63,7 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
61
63
|
);
|
|
62
64
|
|
|
63
65
|
beforeEach(() => {
|
|
66
|
+
transactionStarted.value = false;
|
|
64
67
|
spy = spyOn(PayloadHandler.prototype, "sendPayload").mockImplementation(
|
|
65
68
|
(interfaceType: string, actionType: string, message: any) =>
|
|
66
69
|
Promise.resolve()
|
|
@@ -77,6 +80,7 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
77
80
|
|
|
78
81
|
afterEach(() => {
|
|
79
82
|
vi.useRealTimers();
|
|
83
|
+
isDemo.value = false;
|
|
80
84
|
});
|
|
81
85
|
|
|
82
86
|
it("inflates", () => {
|
|
@@ -84,106 +88,85 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
84
88
|
});
|
|
85
89
|
describe("watchers", () => {
|
|
86
90
|
it("scanState.value.Display.Brightness", async () => {
|
|
87
|
-
await testWatcherForDisplay(
|
|
91
|
+
await testWatcherForDisplay("Brightness", SlidersActions.sl01);
|
|
88
92
|
});
|
|
89
93
|
|
|
90
94
|
it("scanState.value.Display.Contrast", async () => {
|
|
91
|
-
await testWatcherForDisplay(
|
|
95
|
+
await testWatcherForDisplay("Contrast", SlidersActions.sl02);
|
|
92
96
|
});
|
|
93
97
|
|
|
94
98
|
it("scanState.value.Display.Opacity", async () => {
|
|
95
|
-
await testWatcherForDisplay(
|
|
99
|
+
await testWatcherForDisplay("Opacity", SlidersActions.sl03);
|
|
96
100
|
});
|
|
97
101
|
|
|
98
102
|
it("scanState.value.Display.WindowLower", async () => {
|
|
99
|
-
await testWatcherForDisplay(
|
|
103
|
+
await testWatcherForDisplay("WindowLower", SlidersActions.sl04);
|
|
100
104
|
});
|
|
101
105
|
|
|
102
106
|
it("scanState.value.Display.WindowUpper", async () => {
|
|
103
|
-
await testWatcherForDisplay(
|
|
107
|
+
await testWatcherForDisplay("WindowUpper", SlidersActions.sl05);
|
|
104
108
|
});
|
|
105
109
|
|
|
106
110
|
it("scanState.value.Display.ThresholdLower", async () => {
|
|
107
|
-
await testWatcherForDisplay(
|
|
108
|
-
wrapper,
|
|
109
|
-
"ThresholdLower",
|
|
110
|
-
SlidersActions.sl06
|
|
111
|
-
);
|
|
111
|
+
await testWatcherForDisplay("ThresholdLower", SlidersActions.sl06);
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
it("scanState.value.Display.ThresholdUpper", async () => {
|
|
115
|
-
await testWatcherForDisplay(
|
|
116
|
-
wrapper,
|
|
117
|
-
"ThresholdUpper",
|
|
118
|
-
SlidersActions.sl07
|
|
119
|
-
);
|
|
115
|
+
await testWatcherForDisplay("ThresholdUpper", SlidersActions.sl07);
|
|
120
116
|
});
|
|
121
117
|
|
|
122
118
|
it("scanState.value.Slice.TransverseLower", async () => {
|
|
123
|
-
await testWatcherForSlice(
|
|
124
|
-
wrapper,
|
|
125
|
-
"TransverseLower",
|
|
126
|
-
SlidersActions.sl08
|
|
127
|
-
);
|
|
119
|
+
await testWatcherForSlice("TransverseLower", SlidersActions.sl08);
|
|
128
120
|
});
|
|
129
121
|
|
|
130
122
|
it("scanState.value.Orientations.Transverse.Slice", async () => {
|
|
131
|
-
await testWatcherForOrientation(
|
|
132
|
-
wrapper,
|
|
133
|
-
"Transverse",
|
|
134
|
-
SlidersActions.sl09
|
|
135
|
-
);
|
|
123
|
+
await testWatcherForOrientation("Transverse", SlidersActions.sl09);
|
|
136
124
|
});
|
|
137
125
|
|
|
138
126
|
it("scanState.value.Slice.TransverseUpper", async () => {
|
|
139
|
-
await testWatcherForSlice(
|
|
140
|
-
wrapper,
|
|
141
|
-
"TransverseUpper",
|
|
142
|
-
SlidersActions.sl10
|
|
143
|
-
);
|
|
127
|
+
await testWatcherForSlice("TransverseUpper", SlidersActions.sl10);
|
|
144
128
|
});
|
|
145
129
|
|
|
146
130
|
it("scanState.value.Slice.SagittalLower", async () => {
|
|
147
|
-
await testWatcherForSlice(
|
|
131
|
+
await testWatcherForSlice("SagittalLower", SlidersActions.sl11);
|
|
148
132
|
});
|
|
149
133
|
|
|
150
134
|
it("scanState.value.Orientations.Sagittal.Slice", async () => {
|
|
151
|
-
await testWatcherForOrientation(
|
|
135
|
+
await testWatcherForOrientation("Sagittal", SlidersActions.sl12);
|
|
152
136
|
});
|
|
153
137
|
|
|
154
138
|
it("scanState.value.Slice.SagittalUpper", async () => {
|
|
155
|
-
await testWatcherForSlice(
|
|
139
|
+
await testWatcherForSlice("SagittalUpper", SlidersActions.sl13);
|
|
156
140
|
});
|
|
157
141
|
|
|
158
142
|
it("scanState.value.Slice.CoronalLower", async () => {
|
|
159
|
-
await testWatcherForSlice(
|
|
143
|
+
await testWatcherForSlice("CoronalLower", SlidersActions.sl14);
|
|
160
144
|
});
|
|
161
145
|
|
|
162
146
|
it("scanState.value.Orientations.Coronal.Slice", async () => {
|
|
163
|
-
await testWatcherForOrientation(
|
|
147
|
+
await testWatcherForOrientation("Coronal", SlidersActions.sl15);
|
|
164
148
|
});
|
|
165
149
|
|
|
166
150
|
it("scanState.value.Slice.CoronalUpper", async () => {
|
|
167
|
-
await testWatcherForSlice(
|
|
151
|
+
await testWatcherForSlice("CoronalUpper", SlidersActions.sl16);
|
|
168
152
|
});
|
|
169
153
|
|
|
170
154
|
it("scanState.value.Slice.CoronalUpper transaction disabled", async () => {
|
|
171
|
-
|
|
172
|
-
await testWatcherForSlice(
|
|
155
|
+
transactionStarted.value = true;
|
|
156
|
+
await testWatcherForSlice("CoronalUpper", SlidersActions.sl16, true);
|
|
173
157
|
});
|
|
174
158
|
|
|
175
159
|
it("scanState.value.InteractionSettings.PanSensivitity transaction disabled", async () => {
|
|
176
|
-
|
|
160
|
+
transactionStarted.value = true;
|
|
177
161
|
await testWatcherForInteractionSettings(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
162
|
+
"PanSensivitity1",
|
|
163
|
+
ScanMovementActions.sm05,
|
|
164
|
+
true
|
|
181
165
|
);
|
|
182
166
|
});
|
|
183
167
|
|
|
184
168
|
it("scanState.value.InteractionSettings.PanSensivitity", async () => {
|
|
185
169
|
await testWatcherForInteractionSettings(
|
|
186
|
-
wrapper,
|
|
187
170
|
"PanSensivitity",
|
|
188
171
|
ScanMovementActions.sm05
|
|
189
172
|
);
|
|
@@ -191,7 +174,6 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
191
174
|
|
|
192
175
|
it("scanState.value.InteractionSettings.ZoomSensitivity", async () => {
|
|
193
176
|
await testWatcherForInteractionSettings(
|
|
194
|
-
wrapper,
|
|
195
177
|
"ZoomSensitivity",
|
|
196
178
|
ScanMovementActions.sm08
|
|
197
179
|
);
|
|
@@ -199,7 +181,6 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
199
181
|
|
|
200
182
|
it("scanState.value.InteractionSettings.RotateSensitivity", async () => {
|
|
201
183
|
await testWatcherForInteractionSettings(
|
|
202
|
-
wrapper,
|
|
203
184
|
"RotateSensitivity",
|
|
204
185
|
ScanMovementActions.sm10
|
|
205
186
|
);
|
|
@@ -207,9 +188,8 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
207
188
|
|
|
208
189
|
it("scanState.value.InteractionSettings.CameraRotateSensitivity", async () => {
|
|
209
190
|
await testWatcherForInteractionSettings(
|
|
210
|
-
wrapper,
|
|
211
191
|
"CameraRotateSensitivity",
|
|
212
|
-
ScanMovementActions.
|
|
192
|
+
ScanMovementActions.sm12
|
|
213
193
|
);
|
|
214
194
|
});
|
|
215
195
|
});
|
|
@@ -266,15 +246,15 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
266
246
|
});
|
|
267
247
|
|
|
268
248
|
it("tSlider should be set", () => {
|
|
269
|
-
expect(
|
|
249
|
+
expect(unref(tSlider)).toStrictEqual([0, 0]);
|
|
270
250
|
});
|
|
271
251
|
|
|
272
252
|
it("sSlider should be set", () => {
|
|
273
|
-
expect(
|
|
253
|
+
expect(unref(sSlider)).toStrictEqual([0, 0]);
|
|
274
254
|
});
|
|
275
255
|
|
|
276
256
|
it("cSlider should be set", () => {
|
|
277
|
-
expect(
|
|
257
|
+
expect(unref(cSlider)).toStrictEqual([0, 0]);
|
|
278
258
|
});
|
|
279
259
|
|
|
280
260
|
it("windowSlider should set", async () => {
|
|
@@ -402,12 +382,6 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
402
382
|
expect(unref(isLayout2x2)).toBeFalsy();
|
|
403
383
|
});
|
|
404
384
|
|
|
405
|
-
it("should snap", async () => {
|
|
406
|
-
await wrapper.vm.snap();
|
|
407
|
-
|
|
408
|
-
expect(wrapper.emitted()["snap"]).toStrictEqual([[]]);
|
|
409
|
-
});
|
|
410
|
-
|
|
411
385
|
it("should getCurrentGreyscalePreset", async () => {
|
|
412
386
|
const initial = inflateInitialScanState();
|
|
413
387
|
|
|
@@ -431,6 +405,12 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
431
405
|
expect(unref(currentGreyscalePreset)).toBe("testing");
|
|
432
406
|
});
|
|
433
407
|
|
|
408
|
+
it("should isDemo execute option", async () => {
|
|
409
|
+
isDemo.value = true;
|
|
410
|
+
|
|
411
|
+
wrapper.vm.closeModal();
|
|
412
|
+
});
|
|
413
|
+
|
|
434
414
|
it("should getCurrentGreyscalePreset", async () => {
|
|
435
415
|
const initial = inflateInitialScanState();
|
|
436
416
|
|
|
@@ -501,53 +481,6 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
501
481
|
);
|
|
502
482
|
});
|
|
503
483
|
|
|
504
|
-
it("should layouts", async () => {
|
|
505
|
-
// vi.spyOn(wrapper.vm, "sendPayload").mockImplementationOnce(
|
|
506
|
-
// (it: string, a: string, m: any) => {
|
|
507
|
-
// expect(it).toBe(FrontEndInterfaces.layout);
|
|
508
|
-
// expect(a).toBe("lo_02");
|
|
509
|
-
// expect(m).toStrictEqual({
|
|
510
|
-
// Version: "0.0.1",
|
|
511
|
-
// });
|
|
512
|
-
// return Promise.resolve();
|
|
513
|
-
// }
|
|
514
|
-
// );
|
|
515
|
-
|
|
516
|
-
await wrapper.vm.layouts("lo_02");
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
it("should setPreset", async () => {
|
|
520
|
-
const action = PresetsActions.pr01;
|
|
521
|
-
const preset = {};
|
|
522
|
-
|
|
523
|
-
// vi.spyOn(wrapper.vm, "sendPayload").mockImplementationOnce(
|
|
524
|
-
// (it: string, a: string, m: any) => {
|
|
525
|
-
// expect(it).toBe(FrontEndInterfaces.presets);
|
|
526
|
-
// expect(a).toBe(action);
|
|
527
|
-
// expect(m).toStrictEqual(preset);
|
|
528
|
-
// return Promise.resolve();
|
|
529
|
-
// }
|
|
530
|
-
// );
|
|
531
|
-
|
|
532
|
-
await wrapper.vm.setPreset(action, preset);
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
it("should setPreset pr02", async () => {
|
|
536
|
-
const action = PresetsActions.pr02;
|
|
537
|
-
const preset = {};
|
|
538
|
-
|
|
539
|
-
// vi.spyOn(wrapper.vm, "sendPayload").mockImplementationOnce(
|
|
540
|
-
// (it: string, a: string, m: any) => {
|
|
541
|
-
// expect(it).toBe(FrontEndInterfaces.presets);
|
|
542
|
-
// expect(a).toBe(action);
|
|
543
|
-
// expect(m).toStrictEqual(preset);
|
|
544
|
-
// return Promise.resolve();
|
|
545
|
-
// }
|
|
546
|
-
// );
|
|
547
|
-
|
|
548
|
-
await wrapper.vm.setPreset(action, preset);
|
|
549
|
-
});
|
|
550
|
-
|
|
551
484
|
it("should getCurrentGreyscalePreset", async () => {
|
|
552
485
|
expect(unref(currentGreyscalePreset)).toBe(undefined);
|
|
553
486
|
});
|
|
@@ -639,83 +572,102 @@ describe("MftpWebGL3DRModal.vue", () => {
|
|
|
639
572
|
});
|
|
640
573
|
|
|
641
574
|
async function testWatcherForDisplay(
|
|
642
|
-
wrapper: any,
|
|
643
575
|
key: string,
|
|
644
|
-
action: SlidersActions
|
|
576
|
+
action: SlidersActions,
|
|
577
|
+
not: boolean = false
|
|
645
578
|
) {
|
|
646
579
|
const scanState = inflateScanState();
|
|
647
580
|
(scanState.Display as any)[key] = 60;
|
|
648
581
|
|
|
649
|
-
|
|
650
|
-
Version: "0.0.1",
|
|
651
|
-
Value: (scanState.Display as any)[key],
|
|
652
|
-
});
|
|
653
|
-
setScanState(JSON.stringify(scanState));
|
|
582
|
+
await setScanState(JSON.stringify(scanState));
|
|
654
583
|
|
|
655
584
|
await flushPromises();
|
|
585
|
+
if (not) {
|
|
586
|
+
expect(spy).not.toHaveBeenCalledWith(FrontEndInterfaces.sliders, action, {
|
|
587
|
+
Version: "0.0.1",
|
|
588
|
+
Value: (scanState.Display as any)[key],
|
|
589
|
+
});
|
|
590
|
+
} else {
|
|
591
|
+
expect(spy).toHaveBeenCalledWith(FrontEndInterfaces.sliders, action, {
|
|
592
|
+
Version: "0.0.1",
|
|
593
|
+
Value: (scanState.Display as any)[key],
|
|
594
|
+
});
|
|
595
|
+
}
|
|
656
596
|
}
|
|
657
597
|
|
|
658
598
|
async function testWatcherForSlice(
|
|
659
|
-
wrapper: any,
|
|
660
599
|
key: string,
|
|
661
|
-
action: SlidersActions
|
|
600
|
+
action: SlidersActions,
|
|
601
|
+
not: boolean = false
|
|
662
602
|
) {
|
|
663
603
|
const scanState = inflateScanState();
|
|
664
604
|
(scanState.Slice as any)[key] = 100;
|
|
665
605
|
|
|
666
|
-
setupPayloadSpy(wrapper, FrontEndInterfaces.sliders, action, {
|
|
667
|
-
Version: "0.0.1",
|
|
668
|
-
Value: (scanState.Slice as any)[key],
|
|
669
|
-
});
|
|
670
606
|
setScanState(JSON.stringify(scanState));
|
|
671
607
|
|
|
672
608
|
await flushPromises();
|
|
609
|
+
|
|
610
|
+
if (not) {
|
|
611
|
+
expect(spy).not.toHaveBeenCalledWith(FrontEndInterfaces.sliders, action, {
|
|
612
|
+
Version: "0.0.1",
|
|
613
|
+
Value: (scanState.Slice as any)[key],
|
|
614
|
+
});
|
|
615
|
+
} else {
|
|
616
|
+
expect(spy).toHaveBeenCalledWith(FrontEndInterfaces.sliders, action, {
|
|
617
|
+
Version: "0.0.1",
|
|
618
|
+
Value: (scanState.Slice as any)[key],
|
|
619
|
+
});
|
|
620
|
+
}
|
|
673
621
|
}
|
|
674
622
|
|
|
675
623
|
async function testWatcherForOrientation(
|
|
676
|
-
wrapper: any,
|
|
677
624
|
key: string,
|
|
678
|
-
action: SlidersActions
|
|
625
|
+
action: SlidersActions,
|
|
626
|
+
not: boolean = false
|
|
679
627
|
) {
|
|
680
628
|
const scanState = inflateScanState();
|
|
681
629
|
(scanState.Orientations as any)[key].Slice = 100;
|
|
682
630
|
|
|
683
|
-
setupPayloadSpy(wrapper, FrontEndInterfaces.sliders, action, {
|
|
684
|
-
Version: "0.0.1",
|
|
685
|
-
Value: (scanState.Orientations as any)[key].Slice,
|
|
686
|
-
});
|
|
687
631
|
setScanState(JSON.stringify(scanState));
|
|
688
632
|
|
|
689
633
|
await flushPromises();
|
|
634
|
+
if (not) {
|
|
635
|
+
expect(spy).not.toHaveBeenCalledWith(FrontEndInterfaces.sliders, action, {
|
|
636
|
+
Version: "0.0.1",
|
|
637
|
+
Value: (scanState.Orientations as any)[key].Slice,
|
|
638
|
+
});
|
|
639
|
+
} else {
|
|
640
|
+
expect(spy).toHaveBeenCalledWith(FrontEndInterfaces.sliders, action, {
|
|
641
|
+
Version: "0.0.1",
|
|
642
|
+
Value: (scanState.Orientations as any)[key].Slice,
|
|
643
|
+
});
|
|
644
|
+
}
|
|
690
645
|
}
|
|
691
646
|
|
|
692
647
|
async function testWatcherForInteractionSettings(
|
|
693
|
-
wrapper: any,
|
|
694
648
|
key: string,
|
|
695
|
-
action: ScanMovementActions
|
|
649
|
+
action: ScanMovementActions,
|
|
650
|
+
not: boolean = false
|
|
696
651
|
) {
|
|
697
652
|
const scanState = inflateScanState();
|
|
698
653
|
(scanState.InteractionSettings as any)[key] = 100;
|
|
699
654
|
|
|
700
|
-
setupPayloadSpy(wrapper, FrontEndInterfaces.scan_movement, action, {
|
|
701
|
-
Version: "0.0.1",
|
|
702
|
-
Value: (scanState.InteractionSettings as any)[key],
|
|
703
|
-
});
|
|
704
655
|
setScanState(JSON.stringify(scanState));
|
|
705
656
|
|
|
706
657
|
await flushPromises();
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
expect(
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
658
|
+
if (not) {
|
|
659
|
+
expect(spy).not.toHaveBeenCalledWith(
|
|
660
|
+
FrontEndInterfaces.scan_movement,
|
|
661
|
+
action,
|
|
662
|
+
{
|
|
663
|
+
Version: "0.0.1",
|
|
664
|
+
Value: (scanState.InteractionSettings as any)[key],
|
|
665
|
+
}
|
|
666
|
+
);
|
|
667
|
+
} else {
|
|
668
|
+
expect(spy).toHaveBeenCalledWith(FrontEndInterfaces.scan_movement, action, {
|
|
669
|
+
Version: "0.0.1",
|
|
670
|
+
Value: (scanState.InteractionSettings as any)[key],
|
|
671
|
+
});
|
|
672
|
+
}
|
|
721
673
|
}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { PayloadHandler } from "@/dataLayer/payloadHandler";
|
|
3
|
-
import { Ref, UnwrapRef } from "vue";
|
|
2
|
+
import { emptyPayload, PayloadHandler } from "@/dataLayer/payloadHandler";
|
|
3
|
+
import { Ref, unref, UnwrapRef } from "vue";
|
|
4
4
|
import WebGL3DR from "@/components/WebGL3DR.vue";
|
|
5
5
|
import { spyOn } from "@vitest/spy";
|
|
6
6
|
import {
|
|
7
|
+
ColourPresetData,
|
|
7
8
|
FrontEndInterfaces,
|
|
9
|
+
LayoutActions,
|
|
10
|
+
PresetsActions,
|
|
11
|
+
ScanMovementActions,
|
|
8
12
|
ScanOrientationActions,
|
|
9
13
|
ScanView,
|
|
10
14
|
SlidersActions,
|
|
11
15
|
} from "@3cr/types-ts";
|
|
12
16
|
import { toNumber } from "@/helpers/utils";
|
|
13
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
currentColourPreset,
|
|
19
|
+
previousLayout,
|
|
20
|
+
transactionStarted,
|
|
21
|
+
} from "@/dataLayer/scanState";
|
|
14
22
|
|
|
15
23
|
const sendPayloadFunction = vi.fn();
|
|
16
24
|
const mockWebglInstance = {
|
|
@@ -27,6 +35,9 @@ describe("payloadHandler.ts", () => {
|
|
|
27
35
|
describe("payload functions", () => {
|
|
28
36
|
let instance: PayloadHandler;
|
|
29
37
|
beforeEach(() => {
|
|
38
|
+
transactionStarted.value = false;
|
|
39
|
+
previousLayout.value = LayoutActions.lo01;
|
|
40
|
+
currentColourPreset.value = {} as ColourPresetData;
|
|
30
41
|
vi.resetAllMocks();
|
|
31
42
|
instance = new PayloadHandler(mockWebglInstance);
|
|
32
43
|
console.log(instance);
|
|
@@ -94,5 +105,110 @@ describe("payloadHandler.ts", () => {
|
|
|
94
105
|
Value: toNumber(value),
|
|
95
106
|
});
|
|
96
107
|
});
|
|
108
|
+
|
|
109
|
+
it("should scanMovementHandler", async () => {
|
|
110
|
+
const action = ScanMovementActions.sm05;
|
|
111
|
+
const value = 100;
|
|
112
|
+
const spy = spyOn(instance, "sendPayload");
|
|
113
|
+
expect(spy).not.toHaveBeenCalled();
|
|
114
|
+
|
|
115
|
+
await instance.scanMovementHandler(action, value);
|
|
116
|
+
|
|
117
|
+
expect(spy).toHaveBeenCalledWith(
|
|
118
|
+
FrontEndInterfaces.scan_movement,
|
|
119
|
+
action,
|
|
120
|
+
{
|
|
121
|
+
Version: "0.0.1",
|
|
122
|
+
Value: toNumber(value),
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("should not scanMovementHandler transactionStarted", async () => {
|
|
128
|
+
transactionStarted.value = true;
|
|
129
|
+
const action = ScanMovementActions.sm05;
|
|
130
|
+
const value = 100;
|
|
131
|
+
const spy = spyOn(instance, "sendPayload");
|
|
132
|
+
expect(spy).not.toHaveBeenCalled();
|
|
133
|
+
|
|
134
|
+
await instance.scanMovementHandler(action, value);
|
|
135
|
+
|
|
136
|
+
expect(spy).not.toHaveBeenCalledWith(
|
|
137
|
+
FrontEndInterfaces.scan_movement,
|
|
138
|
+
action,
|
|
139
|
+
{
|
|
140
|
+
Version: "0.0.1",
|
|
141
|
+
Value: toNumber(value),
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("should layouts", async () => {
|
|
147
|
+
const action = LayoutActions.lo01;
|
|
148
|
+
const spy = spyOn(instance, "sendPayload");
|
|
149
|
+
expect(spy).not.toHaveBeenCalled();
|
|
150
|
+
|
|
151
|
+
await instance.layouts(action);
|
|
152
|
+
|
|
153
|
+
expect(spy).toHaveBeenCalledWith(
|
|
154
|
+
FrontEndInterfaces.layout,
|
|
155
|
+
action,
|
|
156
|
+
emptyPayload
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("should set prevLayout", async () => {
|
|
161
|
+
const action = LayoutActions.lo02;
|
|
162
|
+
const spy = spyOn(instance, "sendPayload");
|
|
163
|
+
expect(spy).not.toHaveBeenCalled();
|
|
164
|
+
expect(unref(previousLayout)).not.toBe(LayoutActions.lo02);
|
|
165
|
+
|
|
166
|
+
await instance.layouts(action);
|
|
167
|
+
|
|
168
|
+
expect(unref(previousLayout)).toBe(LayoutActions.lo02);
|
|
169
|
+
expect(spy).toHaveBeenCalledWith(
|
|
170
|
+
FrontEndInterfaces.layout,
|
|
171
|
+
action,
|
|
172
|
+
emptyPayload
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("should set setPreset", async () => {
|
|
177
|
+
const action = PresetsActions.pr01;
|
|
178
|
+
const data = {
|
|
179
|
+
asd: "123",
|
|
180
|
+
};
|
|
181
|
+
const spy = spyOn(instance, "sendPayload");
|
|
182
|
+
expect(spy).not.toHaveBeenCalled();
|
|
183
|
+
expect(unref(currentColourPreset)).not.toBe(data);
|
|
184
|
+
|
|
185
|
+
await instance.setPreset(action, data);
|
|
186
|
+
|
|
187
|
+
expect(unref(currentColourPreset)).not.toBe(data);
|
|
188
|
+
expect(spy).toHaveBeenCalledWith(
|
|
189
|
+
FrontEndInterfaces.presets,
|
|
190
|
+
action,
|
|
191
|
+
data
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("should set setPreset change colour", async () => {
|
|
196
|
+
const action = PresetsActions.pr02;
|
|
197
|
+
const data = {
|
|
198
|
+
asd: "123",
|
|
199
|
+
};
|
|
200
|
+
const spy = spyOn(instance, "sendPayload");
|
|
201
|
+
expect(spy).not.toHaveBeenCalled();
|
|
202
|
+
expect(unref(currentColourPreset)).not.toBe(data);
|
|
203
|
+
|
|
204
|
+
await instance.setPreset(action, data);
|
|
205
|
+
|
|
206
|
+
expect(unref(currentColourPreset)).toStrictEqual(data);
|
|
207
|
+
expect(spy).toHaveBeenCalledWith(
|
|
208
|
+
FrontEndInterfaces.presets,
|
|
209
|
+
action,
|
|
210
|
+
data
|
|
211
|
+
);
|
|
212
|
+
});
|
|
97
213
|
});
|
|
98
214
|
});
|
|
@@ -2,16 +2,23 @@ import { Ref, unref, UnwrapRef } from "vue";
|
|
|
2
2
|
import WebGL3DR from "@/components/WebGL3DR.vue";
|
|
3
3
|
import {
|
|
4
4
|
FrontEndInterfaces,
|
|
5
|
+
InteractivityActions,
|
|
6
|
+
LayoutActions,
|
|
7
|
+
PresetsActions,
|
|
5
8
|
ScanMovementActions,
|
|
6
9
|
ScanOrientationActions,
|
|
7
10
|
ScanView,
|
|
8
11
|
SlidersActions,
|
|
9
12
|
ViewSelectionActions,
|
|
10
13
|
} from "@3cr/types-ts";
|
|
11
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
currentColourPreset,
|
|
16
|
+
previousLayout,
|
|
17
|
+
transactionStarted,
|
|
18
|
+
} from "@/dataLayer/scanState";
|
|
12
19
|
import { toNumber } from "@/helpers/utils";
|
|
13
20
|
|
|
14
|
-
const emptyPayload = { Version: "1.1.0" };
|
|
21
|
+
export const emptyPayload = { Version: "1.1.0" };
|
|
15
22
|
|
|
16
23
|
export class PayloadHandler {
|
|
17
24
|
private readonly instance: Ref<UnwrapRef<typeof WebGL3DR | null>>;
|
|
@@ -57,6 +64,36 @@ export class PayloadHandler {
|
|
|
57
64
|
if (unref(transactionStarted)) return;
|
|
58
65
|
await this.scanMovement(action, value);
|
|
59
66
|
}
|
|
67
|
+
async layouts(action: LayoutActions) {
|
|
68
|
+
if (action !== LayoutActions.lo01) previousLayout.value = action;
|
|
69
|
+
await this.sendPayload(FrontEndInterfaces.layout, action, emptyPayload);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async setPreset(action: PresetsActions, preset: any) {
|
|
73
|
+
await this.sendPayload(FrontEndInterfaces.presets, action, preset);
|
|
74
|
+
if (action === PresetsActions.pr02) {
|
|
75
|
+
currentColourPreset.value = preset;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async hoverOverCanvas(isHovering: boolean) {
|
|
80
|
+
await this.sendPayload(
|
|
81
|
+
FrontEndInterfaces.interactivity,
|
|
82
|
+
InteractivityActions.in01,
|
|
83
|
+
{
|
|
84
|
+
Version: "0.0.1",
|
|
85
|
+
Value: isHovering,
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
await this.sendPayload(
|
|
89
|
+
FrontEndInterfaces.interactivity,
|
|
90
|
+
InteractivityActions.in02,
|
|
91
|
+
{
|
|
92
|
+
Version: "0.0.1",
|
|
93
|
+
Value: isHovering,
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
60
97
|
|
|
61
98
|
private async scanMovement(action: ScanMovementActions, value: number) {
|
|
62
99
|
await this.sendPayload(FrontEndInterfaces.scan_movement, action, {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { computed, nextTick, ref, unref
|
|
1
|
+
import { computed, nextTick, ref, unref } from "vue";
|
|
2
2
|
import {
|
|
3
3
|
AnchorPoint,
|
|
4
4
|
ColourPresetData,
|
|
5
5
|
CurrentScanState,
|
|
6
6
|
InitialScanState,
|
|
7
|
-
|
|
7
|
+
LayoutActions,
|
|
8
8
|
} from "@3cr/types-ts";
|
|
9
9
|
import {
|
|
10
10
|
inflateInitialScanState,
|
|
11
11
|
inflateScanState,
|
|
12
12
|
} from "@/helpers/modelHelper";
|
|
13
|
-
import { PayloadHandler } from "@/dataLayer/payloadHandler";
|
|
14
13
|
|
|
15
14
|
export const currentColourPreset = ref<ColourPresetData | undefined>(undefined);
|
|
16
15
|
|
|
@@ -20,6 +19,7 @@ export const scanState = ref<CurrentScanState>(inflateScanState());
|
|
|
20
19
|
export const initialScanState = ref<InitialScanState>(
|
|
21
20
|
inflateInitialScanState()
|
|
22
21
|
);
|
|
22
|
+
export const previousLayout = ref<LayoutActions>(LayoutActions.lo02);
|
|
23
23
|
|
|
24
24
|
export const huMinMax = ref({
|
|
25
25
|
min: -999999,
|
|
@@ -169,13 +169,3 @@ export async function setInitialScanStateFromPayload(
|
|
|
169
169
|
export function setScanState(message: string) {
|
|
170
170
|
scanState.value = JSON.parse(message) as CurrentScanState;
|
|
171
171
|
}
|
|
172
|
-
|
|
173
|
-
export function generateWatcherForScanMovement(
|
|
174
|
-
payloadHandler: PayloadHandler,
|
|
175
|
-
sliderAction: ScanMovementActions,
|
|
176
|
-
source: WatchSource<number>
|
|
177
|
-
) {
|
|
178
|
-
watch(source, async (value: number) => {
|
|
179
|
-
await payloadHandler.scanMovementHandler(sliderAction, value);
|
|
180
|
-
});
|
|
181
|
-
}
|