@3cr/viewer-browser 0.0.162 → 0.0.195
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/.circleci/config.yml +8 -6
- package/__tests__/index.spec.ts +31 -24
- package/components.d.ts +32 -0
- package/dist/Viewer3CR.js +44 -27
- package/dist/Viewer3CR.mjs +22731 -17742
- package/dist/Viewer3CR.umd.js +44 -27
- package/index.html +5 -8
- package/index.ts +7 -2
- package/package.json +4 -2
- package/playground/index.html +6 -4
- package/src/App.vue +12 -4
- package/src/__tests__/app.spec.ts +2 -13
- package/src/assets/magic_wand.svg +24 -0
- package/src/components/WebGL3DR.vue +53 -92
- package/src/components/__tests__/webgl3dr.spec.ts +29 -48
- package/src/{demo → components/demo}/DemoModal.vue +1 -1
- package/src/{demo → components/demo}/DemoPatientModal.vue +4 -1
- package/src/components/demo/__tests__/DemoModal.spec.ts +25 -0
- package/src/components/demo/__tests__/DemoPatientModal.spec.ts +37 -0
- package/src/components/demo/__tests__/options.spec.ts +25 -0
- package/src/components/demo/licence/DemoLicenceEnableCloudStorageModal.vue +64 -0
- package/src/{demo → components/demo}/licence/DemoLicenceInfoModal.vue +5 -4
- package/src/{demo → components/demo}/licence/DemoLicenceSendToPartyModal.vue +6 -4
- package/src/{demo → components/demo}/licence/DemoLicenceShareToMobileModal.vue +8 -6
- package/src/components/demo/licence/__tests__/DemoLicenceEnableCloudStorageModal.spec.ts +37 -0
- package/src/components/demo/licence/__tests__/DemoLicenceInfoModal.spec.ts +37 -0
- package/src/components/demo/licence/__tests__/DemoLicenceSendToPartyModal.spec.ts +36 -0
- package/src/components/demo/licence/__tests__/DemoLicenceShareToMobileModal.spec.ts +51 -0
- package/src/{demo → components/demo}/options.ts +18 -20
- package/src/components/demo/patient/DemoPatientEnableCloudStorageModal.vue +64 -0
- package/src/{demo → components/demo}/patient/DemoPatientInfoModal.vue +5 -4
- package/src/{demo → components/demo}/patient/DemoPatientSendToPartyModal.vue +4 -3
- package/src/{demo → components/demo}/patient/DemoPatientShareToMobileModal.vue +8 -6
- package/src/components/demo/patient/__tests__/DemoPatientEnableCloudStorageModal.spec.ts +37 -0
- package/src/components/demo/patient/__tests__/DemoPatientInfoModal.spec.ts +37 -0
- package/src/components/demo/patient/__tests__/DemoPatientSendToPartyModal.spec.ts +36 -0
- package/src/components/demo/patient/__tests__/DemoPatientShareToMobileModal.spec.ts +51 -0
- package/src/components/loading/LoadingSpinner.vue +1 -1
- package/src/components/modal/ActionRail.vue +96 -0
- package/src/components/modal/AskAI.vue +250 -0
- package/src/components/modal/CloseViewerModal.vue +104 -0
- package/src/components/modal/MftpWebGL3DRModal.vue +415 -834
- package/src/components/modal/ViewerActionRail.vue +123 -0
- package/src/components/modal/ViewerAnnotationModal.vue +115 -0
- package/src/components/modal/ViewerAnnotations.vue +283 -0
- package/src/components/modal/ViewerDisplaySettings.vue +102 -0
- package/src/components/modal/ViewerNavigationDrawer.vue +90 -0
- package/src/components/modal/ViewerNavigationDrawerContent.vue +126 -0
- package/src/components/modal/ViewerNavigationDrawerFooter.vue +111 -0
- package/src/components/modal/ViewerNavigationDrawerHeader.vue +63 -0
- package/src/components/modal/__tests__/CloseViewerModal.spec.ts +60 -0
- package/src/components/modal/__tests__/{mftp-webgl-3dr-modal.spec.ts → MftpWebGL3DRModal.spec.ts} +47 -298
- package/src/components/modal/__tests__/ViewerAnnotationModal.spec.ts +79 -0
- package/src/components/modal/__tests__/ViewerDisplaySettings.spec.ts +61 -0
- package/src/components/modal/__tests__/ViewerNavigationDrawer.spec.ts +32 -0
- package/src/components/modal/__tests__/ViewerNavigationDrawerContent.spec.ts +29 -0
- package/src/components/modal/__tests__/ViewerNavigationDrawerFooter.spec.ts +43 -0
- package/src/components/modal/__tests__/ViewerNavigationDrawerHeader.spec.ts +37 -0
- package/src/components/modal/actions/Action.vue +40 -0
- package/src/components/modal/actions/Flip3dAction.vue +79 -0
- package/src/components/modal/actions/FlipHorizontalAction.vue +36 -0
- package/src/components/modal/actions/FlipVerticalAction.vue +36 -0
- package/src/components/modal/actions/FullscreenAction.vue +47 -0
- package/src/components/modal/actions/NavigationCubeAction.vue +33 -0
- package/src/components/modal/actions/PanAction.vue +78 -0
- package/src/components/modal/actions/ResetViewAction.vue +29 -0
- package/src/components/modal/actions/Rotate2dAction.vue +78 -0
- package/src/components/modal/actions/Slice3dAction.vue +71 -0
- package/src/components/modal/actions/ZoomAction.vue +70 -0
- package/src/components/modal/actions/__tests__/Action.spec.ts +29 -0
- package/src/components/modal/actions/__tests__/Flip3dAction.spec.ts +48 -0
- package/src/components/modal/actions/__tests__/FlipHorizontalAction.spec.ts +17 -0
- package/src/components/modal/actions/__tests__/FlipVerticalAction.spec.ts +17 -0
- package/src/components/modal/actions/__tests__/FullscreenAction.spec.ts +28 -0
- package/src/components/modal/actions/__tests__/NavigationCubeAction.spec.ts +25 -0
- package/src/components/modal/actions/__tests__/PanAction.spec.ts +46 -0
- package/src/components/modal/actions/__tests__/ResetViewAction.spec.ts +17 -0
- package/src/components/modal/actions/__tests__/Rotate2dAction.spec.ts +23 -0
- package/src/components/modal/actions/__tests__/Slice3dAction.spec.ts +14 -0
- package/src/components/modal/actions/__tests__/ZoomAction.spec.ts +34 -0
- package/src/components/modal/composables/__tests__/useNavigationCubeObserver.spec.ts +56 -0
- package/src/components/modal/composables/useEventListener.ts +22 -0
- package/src/components/modal/composables/useNavigationCubeObserver.ts +104 -0
- package/src/components/selectors/ValueSelector.vue +30 -33
- package/src/components/selectors/__tests__/value-selector.spec.ts +1 -1
- package/src/components/sliders/DoubleSliderSelector.vue +79 -71
- package/src/components/sliders/VerticalSliderSelector.vue +12 -17
- package/src/components/sliders/__tests__/double-slider-selector.spec.ts +1 -1
- package/src/components/sliders/__tests__/vertical-slider-selector.spec.ts +1 -1
- package/src/dataLayer/__tests__/clamp.spec.ts +16 -0
- package/src/dataLayer/__tests__/eventHandlers.spec.ts +38 -0
- package/src/dataLayer/__tests__/getIconForPreset.spec.ts +40 -0
- package/src/dataLayer/__tests__/patchDataOverlay.spec.ts +88 -0
- package/src/dataLayer/__tests__/scanState.spec.ts +93 -0
- package/src/dataLayer/__tests__/useViewer3cr.spec.ts +10 -0
- package/src/dataLayer/__tests__/viewer3cr.spec.ts +331 -0
- package/src/dataLayer/clamp.ts +9 -0
- package/src/dataLayer/eventHandlers.ts +26 -0
- package/src/dataLayer/patchDataOverlay.ts +101 -0
- package/src/dataLayer/scanState.ts +105 -26
- package/src/dataLayer/useViewer3cr.ts +7 -0
- package/src/dataLayer/viewer3cr.ts +410 -0
- package/src/helpers/__tests__/layout-overlay-style.spec.ts +24 -22
- package/src/helpers/__tests__/model-helper.spec.ts +44 -13
- package/src/helpers/layoutOverlayStyle.ts +16 -27
- package/src/helpers/modelHelper.ts +62 -10
- package/src/models/Callbacks.ts +2 -2
- package/src/models/LoadViewerOptions.ts +2 -0
- package/src/models/LoadViewerPayload.ts +1 -0
- package/src/notifications/notification.ts +3 -4
- package/src/plugins/vuetify.ts +5 -0
- package/src/services/gpt/__tests__/gpt.service.spec.ts +27 -0
- package/src/services/gpt/gpt.service.ts +27 -0
- package/static/3cr-types-browser/index.ts +74 -0
- package/static/3cr-types-browser/types/Action.ts +6 -0
- package/static/3cr-types-browser/types/ActionData.ts +4 -0
- package/static/3cr-types-browser/types/AlphaKeys.ts +5 -0
- package/static/3cr-types-browser/types/AnchorPoint.ts +12 -0
- package/static/3cr-types-browser/types/CallToAction.ts +5 -0
- package/static/3cr-types-browser/types/ColourData.ts +7 -0
- package/static/3cr-types-browser/types/ColourPresetData.ts +9 -0
- package/static/3cr-types-browser/types/CurrentDataOverlayState.ts +6 -0
- package/static/3cr-types-browser/types/CurrentScanState.ts +22 -0
- package/static/3cr-types-browser/types/DataOverlay.ts +22 -0
- package/static/3cr-types-browser/types/DataOverlayActions.ts +14 -0
- package/static/3cr-types-browser/types/DataOverlayData.ts +8 -0
- package/static/3cr-types-browser/types/DataOverlayEvent.ts +8 -0
- package/static/3cr-types-browser/types/DecryptionKey.ts +4 -0
- package/static/3cr-types-browser/types/DisplaySettings.ts +10 -0
- package/static/3cr-types-browser/types/EmptyPayload.ts +3 -0
- package/static/3cr-types-browser/types/EnumPayload.ts +4 -0
- package/static/3cr-types-browser/types/FileManagementActions.ts +11 -0
- package/static/3cr-types-browser/types/FlipValue.ts +7 -0
- package/static/3cr-types-browser/types/FrontEndInterfaces.ts +14 -0
- package/static/3cr-types-browser/types/GradientKeys.ts +7 -0
- package/static/3cr-types-browser/types/GreyscalePresetData.ts +6 -0
- package/static/3cr-types-browser/types/InitialDataOverlayState.ts +6 -0
- package/static/3cr-types-browser/types/InitialScanState.ts +19 -0
- package/static/3cr-types-browser/types/InteractionType.ts +8 -0
- package/static/3cr-types-browser/types/InteractivityActions.ts +6 -0
- package/static/3cr-types-browser/types/InteractivityState.ts +4 -0
- package/static/3cr-types-browser/types/InvertTransformData.ts +6 -0
- package/static/3cr-types-browser/types/LayoutActions.ts +6 -0
- package/static/3cr-types-browser/types/LayoutData.ts +7 -0
- package/static/3cr-types-browser/types/LoadDataSet.ts +6 -0
- package/static/3cr-types-browser/types/LoadSessionState.ts +4 -0
- package/static/3cr-types-browser/types/LocalLoadDataset.ts +3 -0
- package/static/3cr-types-browser/types/MovementData.ts +7 -0
- package/static/3cr-types-browser/types/NavigationCubeActions.ts +8 -0
- package/static/3cr-types-browser/types/NavigationCubeData.ts +12 -0
- package/static/3cr-types-browser/types/NavigationCubeTransform.ts +9 -0
- package/static/3cr-types-browser/types/NotificationPayload.ts +7 -0
- package/static/3cr-types-browser/types/NotificationsActions.ts +6 -0
- package/static/3cr-types-browser/types/Object.ts +1 -0
- package/static/3cr-types-browser/types/ObjectColour.ts +7 -0
- package/static/3cr-types-browser/types/ObjectIcon.ts +5 -0
- package/static/3cr-types-browser/types/ObjectInvert.ts +7 -0
- package/static/3cr-types-browser/types/ObjectSize.ts +7 -0
- package/static/3cr-types-browser/types/ObjectSize2D.ts +7 -0
- package/static/3cr-types-browser/types/ObjectVisible.ts +5 -0
- package/static/3cr-types-browser/types/PositionData.ts +14 -0
- package/static/3cr-types-browser/types/PresetsActions.ts +4 -0
- package/static/3cr-types-browser/types/RotationValue.ts +7 -0
- package/static/3cr-types-browser/types/ScanMovementActions.ts +27 -0
- package/static/3cr-types-browser/types/ScanMovementData.ts +3 -0
- package/static/3cr-types-browser/types/ScanOrientationActions.ts +6 -0
- package/static/3cr-types-browser/types/ScanStateActions.ts +4 -0
- package/static/3cr-types-browser/types/ScanView.ts +6 -0
- package/static/3cr-types-browser/types/SettingsData.ts +12 -0
- package/static/3cr-types-browser/types/SlicerData.ts +9 -0
- package/static/3cr-types-browser/types/SliderValue.ts +4 -0
- package/static/3cr-types-browser/types/SlidersActions.ts +18 -0
- package/static/3cr-types-browser/types/Vector2Data.ts +5 -0
- package/static/3cr-types-browser/types/Vector3Data.ts +6 -0
- package/static/3cr-types-browser/types/VectorMovementData.ts +8 -0
- package/static/3cr-types-browser/types/ViewInteractiveMode.ts +5 -0
- package/static/3cr-types-browser/types/ViewOrientation.ts +8 -0
- package/static/3cr-types-browser/types/ViewOrientations.ts +10 -0
- package/static/3cr-types-browser/types/ViewSelectionActions.ts +9 -0
- package/static/3cr-types-browser/types/ViewToggleData.ts +7 -0
- package/static/3cr-types-browser/types/VolumeOrientation.ts +7 -0
- package/test/helper.ts +10 -1
- package/test/setup.ts +13 -0
- package/tsconfig.json +1 -0
- package/vite.config.mts +1 -0
- package/src/dataLayer/__tests__/payload-handler.spec.ts +0 -214
- package/src/dataLayer/payloadHandler.ts +0 -138
- /package/src/dataLayer/{iconData.ts → getIconForPreset.ts} +0 -0
package/test/helper.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { mount, shallowMount } from "@vue/test-utils";
|
|
1
|
+
import { mount, shallowMount, VueWrapper } from "@vue/test-utils";
|
|
2
2
|
import { createVuetify } from "vuetify";
|
|
3
3
|
import { expect } from "vitest";
|
|
4
|
+
import { VDialog } from "vuetify/components";
|
|
5
|
+
import { nextTick } from "vue";
|
|
4
6
|
|
|
5
7
|
export function mountVuetify<T>(
|
|
6
8
|
component: T,
|
|
@@ -33,3 +35,10 @@ export function checkComponentProps(
|
|
|
33
35
|
) {
|
|
34
36
|
expect(component.props()[propKey] as any).toBe(equal);
|
|
35
37
|
}
|
|
38
|
+
|
|
39
|
+
export async function openAllModals<T>(wrapper: VueWrapper<T>) {
|
|
40
|
+
for (const modal of wrapper.findAllComponents(VDialog)) {
|
|
41
|
+
await modal.setValue(true);
|
|
42
|
+
}
|
|
43
|
+
await nextTick();
|
|
44
|
+
}
|
package/test/setup.ts
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
+
import {vi} from "vitest";
|
|
2
|
+
|
|
1
3
|
global.ResizeObserver = require("resize-observer-polyfill");
|
|
4
|
+
|
|
5
|
+
vi.mock("@3cr/sdk-browser", async (importOriginal) => {
|
|
6
|
+
const mod = (await importOriginal()) as object;
|
|
7
|
+
return {
|
|
8
|
+
...mod,
|
|
9
|
+
registerVersion: vi.fn(),
|
|
10
|
+
createInstance: vi.fn(),
|
|
11
|
+
executePayload: vi.fn(),
|
|
12
|
+
registerOnPayloadHandler: vi.fn(),
|
|
13
|
+
};
|
|
14
|
+
});
|
package/tsconfig.json
CHANGED
package/vite.config.mts
CHANGED
|
@@ -67,6 +67,7 @@ if (globalThis.Viewer3CR) {
|
|
|
67
67
|
},
|
|
68
68
|
resolve: {
|
|
69
69
|
alias: {
|
|
70
|
+
'@3cr/types-ts': fileURLToPath(new URL('./static/3cr-types-browser', import.meta.url)),
|
|
70
71
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
71
72
|
'~': fileURLToPath(new URL('./test', import.meta.url)),
|
|
72
73
|
},
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { emptyPayload, PayloadHandler } from "@/dataLayer/payloadHandler";
|
|
3
|
-
import { Ref, unref, UnwrapRef } from "vue";
|
|
4
|
-
import WebGL3DR from "@/components/WebGL3DR.vue";
|
|
5
|
-
import { spyOn } from "@vitest/spy";
|
|
6
|
-
import {
|
|
7
|
-
ColourPresetData,
|
|
8
|
-
FrontEndInterfaces,
|
|
9
|
-
LayoutActions,
|
|
10
|
-
PresetsActions,
|
|
11
|
-
ScanMovementActions,
|
|
12
|
-
ScanOrientationActions,
|
|
13
|
-
ScanView,
|
|
14
|
-
SlidersActions,
|
|
15
|
-
} from "@3cr/types-ts";
|
|
16
|
-
import { toNumber } from "@/helpers/utils";
|
|
17
|
-
import {
|
|
18
|
-
currentColourPreset,
|
|
19
|
-
previousLayout,
|
|
20
|
-
transactionStarted,
|
|
21
|
-
} from "@/dataLayer/scanState";
|
|
22
|
-
|
|
23
|
-
const sendPayloadFunction = vi.fn();
|
|
24
|
-
const mockWebglInstance = {
|
|
25
|
-
value: {
|
|
26
|
-
sendPayload: sendPayloadFunction,
|
|
27
|
-
},
|
|
28
|
-
} as unknown as Ref<UnwrapRef<typeof WebGL3DR | null>>;
|
|
29
|
-
|
|
30
|
-
describe("payloadHandler.ts", () => {
|
|
31
|
-
it("should create instance", () => {
|
|
32
|
-
expect(new PayloadHandler(mockWebglInstance)).toBeTruthy();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe("payload functions", () => {
|
|
36
|
-
let instance: PayloadHandler;
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
transactionStarted.value = false;
|
|
39
|
-
previousLayout.value = LayoutActions.lo01;
|
|
40
|
-
currentColourPreset.value = {} as ColourPresetData;
|
|
41
|
-
vi.resetAllMocks();
|
|
42
|
-
instance = new PayloadHandler(mockWebglInstance);
|
|
43
|
-
console.log(instance);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should sendPayload", async () => {
|
|
47
|
-
expect(sendPayloadFunction).not.toHaveBeenCalled();
|
|
48
|
-
|
|
49
|
-
await instance.sendPayload("123", "123", {});
|
|
50
|
-
|
|
51
|
-
expect(sendPayloadFunction).toHaveBeenCalledWith(
|
|
52
|
-
JSON.stringify({
|
|
53
|
-
Version: "0.0.1",
|
|
54
|
-
Interface: "123",
|
|
55
|
-
Action: "123",
|
|
56
|
-
Message: JSON.stringify({}),
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should rotateByDeg", async () => {
|
|
62
|
-
const view = ScanView.Coronal;
|
|
63
|
-
const deg = 100;
|
|
64
|
-
const spy = spyOn(instance, "sendPayload");
|
|
65
|
-
expect(spy).not.toHaveBeenCalled();
|
|
66
|
-
|
|
67
|
-
await instance.rotateByDeg(view, deg);
|
|
68
|
-
|
|
69
|
-
expect(spy).toHaveBeenCalledWith(
|
|
70
|
-
FrontEndInterfaces.scan_orientation,
|
|
71
|
-
ScanOrientationActions.so01,
|
|
72
|
-
{
|
|
73
|
-
Version: "0.0.1",
|
|
74
|
-
View: view,
|
|
75
|
-
Angle: deg,
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("should sliderHandler", async () => {
|
|
81
|
-
const action = SlidersActions.sl08;
|
|
82
|
-
const value = 100;
|
|
83
|
-
const spy = spyOn(instance, "sendPayload");
|
|
84
|
-
expect(spy).not.toHaveBeenCalled();
|
|
85
|
-
|
|
86
|
-
await instance.sliderHandler(action, value);
|
|
87
|
-
|
|
88
|
-
expect(spy).toHaveBeenCalledWith(FrontEndInterfaces.sliders, action, {
|
|
89
|
-
Version: "0.0.1",
|
|
90
|
-
Value: toNumber(value),
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("should not sliderHandler transactionStarted", async () => {
|
|
95
|
-
transactionStarted.value = true;
|
|
96
|
-
const action = SlidersActions.sl08;
|
|
97
|
-
const value = 100;
|
|
98
|
-
const spy = spyOn(instance, "sendPayload");
|
|
99
|
-
expect(spy).not.toHaveBeenCalled();
|
|
100
|
-
|
|
101
|
-
await instance.sliderHandler(action, value);
|
|
102
|
-
|
|
103
|
-
expect(spy).not.toHaveBeenCalledWith(FrontEndInterfaces.sliders, action, {
|
|
104
|
-
Version: "0.0.1",
|
|
105
|
-
Value: toNumber(value),
|
|
106
|
-
});
|
|
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
|
-
});
|
|
213
|
-
});
|
|
214
|
-
});
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { Ref, unref, UnwrapRef } from "vue";
|
|
2
|
-
import WebGL3DR from "@/components/WebGL3DR.vue";
|
|
3
|
-
import {
|
|
4
|
-
FrontEndInterfaces,
|
|
5
|
-
InteractivityActions,
|
|
6
|
-
LayoutActions,
|
|
7
|
-
NavigationCubeActions,
|
|
8
|
-
PresetsActions,
|
|
9
|
-
ScanMovementActions,
|
|
10
|
-
ScanOrientationActions,
|
|
11
|
-
ScanView,
|
|
12
|
-
SlidersActions,
|
|
13
|
-
ViewSelectionActions,
|
|
14
|
-
} from "@3cr/types-ts";
|
|
15
|
-
import {
|
|
16
|
-
currentColourPreset,
|
|
17
|
-
previousLayout,
|
|
18
|
-
transactionStarted,
|
|
19
|
-
} from "@/dataLayer/scanState";
|
|
20
|
-
import { toNumber } from "@/helpers/utils";
|
|
21
|
-
|
|
22
|
-
export const emptyPayload = { Version: "1.1.0" };
|
|
23
|
-
|
|
24
|
-
export class PayloadHandler {
|
|
25
|
-
private readonly instance: Ref<UnwrapRef<typeof WebGL3DR | null>>;
|
|
26
|
-
constructor(protected webglInstance: Ref<UnwrapRef<typeof WebGL3DR | null>>) {
|
|
27
|
-
this.instance = webglInstance;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async sendPayload(interfaceType: string, actionType: string, message: any) {
|
|
31
|
-
await this.instance.value?.sendPayload(
|
|
32
|
-
JSON.stringify({
|
|
33
|
-
Version: "0.0.1",
|
|
34
|
-
Interface: interfaceType,
|
|
35
|
-
Action: actionType,
|
|
36
|
-
Message: JSON.stringify(message),
|
|
37
|
-
})
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
async rotateByDeg(view: ScanView, deg: number) {
|
|
41
|
-
await this.sendPayload(
|
|
42
|
-
FrontEndInterfaces.scan_orientation,
|
|
43
|
-
ScanOrientationActions.so01,
|
|
44
|
-
{
|
|
45
|
-
Version: "0.0.1",
|
|
46
|
-
View: view,
|
|
47
|
-
Angle: deg,
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
async viewSelection(action: ViewSelectionActions) {
|
|
52
|
-
await this.sendPayload(
|
|
53
|
-
FrontEndInterfaces.view_selection,
|
|
54
|
-
action,
|
|
55
|
-
emptyPayload
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async sliderHandler(action: SlidersActions, value: number) {
|
|
60
|
-
if (unref(transactionStarted)) return;
|
|
61
|
-
await this.slider(action, value);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async scanMovementHandler(action: ScanMovementActions, value: number) {
|
|
65
|
-
if (unref(transactionStarted)) return;
|
|
66
|
-
await this.scanMovement(action, value);
|
|
67
|
-
}
|
|
68
|
-
async layouts(action: LayoutActions) {
|
|
69
|
-
if (action !== LayoutActions.lo01) previousLayout.value = action;
|
|
70
|
-
await this.sendPayload(FrontEndInterfaces.layout, action, emptyPayload);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async setPreset(action: PresetsActions, preset: any) {
|
|
74
|
-
await this.sendPayload(FrontEndInterfaces.presets, action, preset);
|
|
75
|
-
if (action === PresetsActions.pr02) {
|
|
76
|
-
currentColourPreset.value = preset;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async setNavCubeVisibility(visibility: any) {
|
|
81
|
-
await this.sendPayload(
|
|
82
|
-
FrontEndInterfaces.navigation_cube,
|
|
83
|
-
NavigationCubeActions.nc02,
|
|
84
|
-
{
|
|
85
|
-
Version: "0.0.1",
|
|
86
|
-
Value: visibility,
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async hoverOverCanvas(isHovering: boolean) {
|
|
92
|
-
await this.sendPayload(
|
|
93
|
-
FrontEndInterfaces.interactivity,
|
|
94
|
-
InteractivityActions.in01,
|
|
95
|
-
{
|
|
96
|
-
Version: "0.0.1",
|
|
97
|
-
Value: isHovering,
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
await this.sendPayload(
|
|
101
|
-
FrontEndInterfaces.interactivity,
|
|
102
|
-
InteractivityActions.in02,
|
|
103
|
-
{
|
|
104
|
-
Version: "0.0.1",
|
|
105
|
-
Value: isHovering,
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private async scanMovement(action: ScanMovementActions, value: number) {
|
|
111
|
-
await this.sendPayload(FrontEndInterfaces.scan_movement, action, {
|
|
112
|
-
Version: "0.0.1",
|
|
113
|
-
Value: toNumber(value),
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
private async slider(action: SlidersActions, value: number) {
|
|
117
|
-
await this.sendPayload(FrontEndInterfaces.sliders, action, {
|
|
118
|
-
Version: "0.0.1",
|
|
119
|
-
Value: toNumber(value),
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export async function sendPayload(
|
|
125
|
-
instance: Ref<UnwrapRef<typeof WebGL3DR | null>>,
|
|
126
|
-
interfaceType: string,
|
|
127
|
-
actionType: string,
|
|
128
|
-
message: any
|
|
129
|
-
) {
|
|
130
|
-
await unref(instance)?.sendPayload(
|
|
131
|
-
JSON.stringify({
|
|
132
|
-
Version: "0.0.1",
|
|
133
|
-
Interface: interfaceType,
|
|
134
|
-
Action: actionType,
|
|
135
|
-
Message: JSON.stringify(message),
|
|
136
|
-
})
|
|
137
|
-
);
|
|
138
|
-
}
|
|
File without changes
|