@cornerstonejs/codemods 6.0.0-beta.0 → 6.0.0-beta.2
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/.oxlintrc.json +4 -0
- package/package.json +1 -1
- package/registry/cornerstone3d/6/README.md +46 -0
- package/registry/cornerstone3d/6/classes-and-types/README.md +16 -0
- package/registry/cornerstone3d/6/classes-and-types/scripts/classes-and-types.ts +32 -90
- package/registry/cornerstone3d/6/classes-and-types/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/expected.js +31 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/input.js +31 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/jsx-in-a-js-file/metrics.json +46 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +34 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +34 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/positive-classes/metrics.json +10 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/expected.ts +61 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/input.ts +65 -0
- package/registry/cornerstone3d/6/classes-and-types/tests/typescript/renamed-classes-make-two-operands-one/metrics.json +36 -0
- package/registry/cornerstone3d/6/display-sets/README.md +4 -0
- package/registry/cornerstone3d/6/display-sets/scripts/display-sets.ts +4 -2
- package/registry/cornerstone3d/6/display-sets/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/expected.js +45 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/input.js +39 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/jsx-in-a-js-file/metrics.json +84 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +42 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +42 -0
- package/registry/cornerstone3d/6/display-sets/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/events/README.md +4 -0
- package/registry/cornerstone3d/6/events/scripts/events.ts +5 -3
- package/registry/cornerstone3d/6/events/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/expected.js +18 -0
- package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/input.js +18 -0
- package/registry/cornerstone3d/6/events/tests/tsx/jsx-in-a-js-file/metrics.json +38 -0
- package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +21 -0
- package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +21 -0
- package/registry/cornerstone3d/6/events/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/settings/README.md +4 -0
- package/registry/cornerstone3d/6/settings/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/settings/scripts/settings.ts +5 -3
- package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/expected.js +18 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/input.js +18 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/jsx-in-a-js-file/metrics.json +46 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +21 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +21 -0
- package/registry/cornerstone3d/6/settings/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/tools/README.md +5 -0
- package/registry/cornerstone3d/6/tools/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/tools/scripts/tools.ts +6 -3
- package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/expected.js +35 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/input.js +35 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/jsx-in-a-js-file/metrics.json +52 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +38 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +38 -0
- package/registry/cornerstone3d/6/tools/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-members/README.md +5 -0
- package/registry/cornerstone3d/6/viewport-members/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/viewport-members/scripts/viewport-members.ts +5 -3
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/expected.js +41 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/input.js +41 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/jsx-in-a-js-file/metrics.json +108 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +44 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +44 -0
- package/registry/cornerstone3d/6/viewport-members/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/README.md +35 -0
- package/registry/cornerstone3d/6/viewport-types/scripts/lib.ts +864 -16
- package/registry/cornerstone3d/6/viewport-types/scripts/viewport-types.ts +192 -4
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/expected.js +76 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/input.js +76 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/jsx-in-a-js-file/metrics.json +102 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/expected.tsx +79 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/input.tsx +79 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/expected.js +78 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/input.js +78 -0
- package/registry/cornerstone3d/6/viewport-types/tests/tsx/not-analysed-a-name-declared-twice-in-a-js-file/metrics.json +12 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/expected.ts +173 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/input.ts +173 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-returns-of-two-types-become-one/metrics.json +166 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/expected.ts +103 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/input.ts +103 -0
- package/registry/cornerstone3d/6/viewport-types/tests/typescript/ohif-two-operands-become-one/metrics.json +78 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
const { ViewportType } = Enums;
|
|
5
|
+
|
|
6
|
+
function inputFor(
|
|
7
|
+
viewportInput,
|
|
8
|
+
isStack,
|
|
9
|
+
options
|
|
10
|
+
) {
|
|
11
|
+
if (viewportInput.type === ViewportType.STACK) {
|
|
12
|
+
return viewportInput;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
switch (viewportInput.type) {
|
|
16
|
+
case ViewportType.ORTHOGRAPHIC:
|
|
17
|
+
return viewportInput;
|
|
18
|
+
default:
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
viewportId: 'conditional',
|
|
25
|
+
element: document.createElement('div'),
|
|
26
|
+
type: isStack ? ViewportType.STACK : ViewportType.ORTHOGRAPHIC,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
viewportId: 'perspective',
|
|
30
|
+
element: document.createElement('div'),
|
|
31
|
+
type: ViewportType.PERSPECTIVE,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
viewportId: 'shorthand',
|
|
35
|
+
element: document.createElement('div'),
|
|
36
|
+
type: ViewportType.ORTHOGRAPHIC,
|
|
37
|
+
defaultOptions,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
viewportId: 'stretched',
|
|
41
|
+
element: document.createElement('div'),
|
|
42
|
+
type: 'perspective',
|
|
43
|
+
defaultOptions: { displayArea: options.displayArea },
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const storedLayout = 'planarNext';
|
|
49
|
+
|
|
50
|
+
export function Viewer({ engine }) {
|
|
51
|
+
return (
|
|
52
|
+
<div data-type={storedLayout} data-engine={engine.id}>
|
|
53
|
+
{String(inputFor)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getType(kind) {
|
|
59
|
+
if (kind === 'stack') {
|
|
60
|
+
return ViewportType.STACK;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return ViewportType.ORTHOGRAPHIC;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function is3D(type) {
|
|
67
|
+
return (
|
|
68
|
+
type === ViewportType.VOLUME_3D || type === ViewportType.VOLUME_3D_NEXT
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const Label = ({ type }) => (
|
|
73
|
+
<span>
|
|
74
|
+
{type === ViewportType.ECG || type === ViewportType.ECG_NEXT ? 'ECG' : ''}
|
|
75
|
+
</span>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const { ViewportType } = Enums;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
const { ViewportType } = Enums;
|
|
5
|
+
|
|
6
|
+
function inputFor(
|
|
7
|
+
viewportInput,
|
|
8
|
+
isStack,
|
|
9
|
+
options
|
|
10
|
+
) {
|
|
11
|
+
if (viewportInput.type === ViewportType.STACK) {
|
|
12
|
+
return viewportInput;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
switch (viewportInput.type) {
|
|
16
|
+
case ViewportType.ORTHOGRAPHIC:
|
|
17
|
+
return viewportInput;
|
|
18
|
+
default:
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
viewportId: 'conditional',
|
|
25
|
+
element: document.createElement('div'),
|
|
26
|
+
type: isStack ? ViewportType.STACK : ViewportType.ORTHOGRAPHIC,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
viewportId: 'perspective',
|
|
30
|
+
element: document.createElement('div'),
|
|
31
|
+
type: ViewportType.PERSPECTIVE,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
viewportId: 'shorthand',
|
|
35
|
+
element: document.createElement('div'),
|
|
36
|
+
type: ViewportType.ORTHOGRAPHIC,
|
|
37
|
+
defaultOptions,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
viewportId: 'stretched',
|
|
41
|
+
element: document.createElement('div'),
|
|
42
|
+
type: 'perspective',
|
|
43
|
+
defaultOptions: { displayArea: options.displayArea },
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const storedLayout = 'planarNext';
|
|
49
|
+
|
|
50
|
+
export function Viewer({ engine }) {
|
|
51
|
+
return (
|
|
52
|
+
<div data-type={storedLayout} data-engine={engine.id}>
|
|
53
|
+
{String(inputFor)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getType(kind) {
|
|
59
|
+
if (kind === 'stack') {
|
|
60
|
+
return ViewportType.STACK;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return ViewportType.ORTHOGRAPHIC;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function is3D(type) {
|
|
67
|
+
return (
|
|
68
|
+
type === ViewportType.VOLUME_3D || type === ViewportType.VOLUME_3D_NEXT
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const Label = ({ type }) => (
|
|
73
|
+
<span>
|
|
74
|
+
{type === ViewportType.ECG || type === ViewportType.ECG_NEXT ? 'ECG' : ''}
|
|
75
|
+
</span>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const { ViewportType } = Enums;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Enums } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
const { ViewportType } = Enums;
|
|
4
|
+
|
|
5
|
+
const STACK = 'stack';
|
|
6
|
+
const VOLUME = 'volume';
|
|
7
|
+
const VOLUME_3D = 'volume3d';
|
|
8
|
+
|
|
9
|
+
export default function getCornerstoneViewportType(
|
|
10
|
+
viewportType: string,
|
|
11
|
+
useNextViewports = false
|
|
12
|
+
): Enums.ViewportType {
|
|
13
|
+
const lowerViewportType = viewportType.toLowerCase();
|
|
14
|
+
|
|
15
|
+
switch (lowerViewportType) {
|
|
16
|
+
case 'planarnext':
|
|
17
|
+
return Enums.ViewportType.PLANAR;
|
|
18
|
+
case 'volume3dnext':
|
|
19
|
+
return Enums.ViewportType.VOLUME_3D;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (useNextViewports) {
|
|
23
|
+
switch (lowerViewportType) {
|
|
24
|
+
case STACK:
|
|
25
|
+
case VOLUME:
|
|
26
|
+
return Enums.ViewportType.PLANAR;
|
|
27
|
+
case VOLUME_3D:
|
|
28
|
+
return Enums.ViewportType.VOLUME_3D;
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Invalid viewport type: ${viewportType}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (lowerViewportType === STACK) {
|
|
35
|
+
return Enums.ViewportType.PLANAR;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (lowerViewportType === VOLUME) {
|
|
39
|
+
return Enums.ViewportType.PLANAR;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (lowerViewportType === VOLUME_3D) {
|
|
43
|
+
return Enums.ViewportType.VOLUME_3D;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
throw new Error(`Invalid viewport type: ${viewportType}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function bySwitch(kind: string) {
|
|
50
|
+
switch (kind) {
|
|
51
|
+
case 'stack':
|
|
52
|
+
return ViewportType.PLANAR;
|
|
53
|
+
case 'volume':
|
|
54
|
+
return ViewportType.PLANAR;
|
|
55
|
+
default:
|
|
56
|
+
return ViewportType.VOLUME_3D;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function byConstants(kind: string) {
|
|
61
|
+
const stackType = ViewportType.PLANAR;
|
|
62
|
+
const volumeType = ViewportType.PLANAR;
|
|
63
|
+
|
|
64
|
+
if (kind === 'stack') {
|
|
65
|
+
return stackType;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return volumeType;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const STACK_TYPE = ViewportType.PLANAR;
|
|
72
|
+
const VOLUME_TYPE = ViewportType.PLANAR;
|
|
73
|
+
|
|
74
|
+
export const byModuleConstants = (isStack: boolean) =>
|
|
75
|
+
isStack ? STACK_TYPE : VOLUME_TYPE;
|
|
76
|
+
|
|
77
|
+
export function byVariablesWithOneValue(isStack: boolean) {
|
|
78
|
+
let stackType = ViewportType.PLANAR;
|
|
79
|
+
let volumeType = ViewportType.PLANAR;
|
|
80
|
+
|
|
81
|
+
return isStack ? stackType : (volumeType as Enums.ViewportType);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class Shapes {
|
|
85
|
+
shapeOf(isStack: boolean) {
|
|
86
|
+
if (isStack) {
|
|
87
|
+
return ViewportType.PLANAR;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return ViewportType.PLANAR;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function assignedOnly(kind: string) {
|
|
95
|
+
let type;
|
|
96
|
+
|
|
97
|
+
if (kind === 'stack') {
|
|
98
|
+
type = ViewportType.STACK;
|
|
99
|
+
} else {
|
|
100
|
+
type = ViewportType.ORTHOGRAPHIC;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return type;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function assignedAfterTheDeclaration(kind: string) {
|
|
107
|
+
let type = ViewportType.PLANAR;
|
|
108
|
+
|
|
109
|
+
if (kind === 'volume') {
|
|
110
|
+
type = ViewportType.ORTHOGRAPHIC;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return type;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function writtenInAnotherWay(kinds: string[]) {
|
|
117
|
+
let type = ViewportType.PLANAR;
|
|
118
|
+
const volumeType = ViewportType.PLANAR;
|
|
119
|
+
|
|
120
|
+
[type] = kinds as Enums.ViewportType[];
|
|
121
|
+
|
|
122
|
+
return kinds.length ? type : volumeType;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function inAConditional(isStack: boolean) {
|
|
126
|
+
return isStack ? ViewportType.STACK : ViewportType.ORTHOGRAPHIC;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function legacyAndNextThroughAVariable(useNext: boolean) {
|
|
130
|
+
let type = ViewportType.VOLUME_3D;
|
|
131
|
+
|
|
132
|
+
if (useNext) {
|
|
133
|
+
type = ViewportType.VOLUME_3D;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return type;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function legacyAndNextInAConditional(useNext: boolean) {
|
|
140
|
+
return useNext ? ViewportType.VIDEO : ViewportType.VIDEO;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function stackOnly() {
|
|
144
|
+
return ViewportType.PLANAR;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function volumeOnly() {
|
|
148
|
+
return ViewportType.PLANAR;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function sameTypeTwice(early: boolean) {
|
|
152
|
+
if (early) {
|
|
153
|
+
return ViewportType.PLANAR;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return ViewportType.PLANAR;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function innerFunctionReturnsTheOther(kinds: string[]) {
|
|
160
|
+
kinds.map(() => {
|
|
161
|
+
return ViewportType.PLANAR;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return ViewportType.PLANAR;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function alreadyOnSix(is3D: boolean) {
|
|
168
|
+
if (is3D) {
|
|
169
|
+
return ViewportType.VOLUME_3D;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return ViewportType.PLANAR;
|
|
173
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Enums } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
const { ViewportType } = Enums;
|
|
4
|
+
|
|
5
|
+
const STACK = 'stack';
|
|
6
|
+
const VOLUME = 'volume';
|
|
7
|
+
const VOLUME_3D = 'volume3d';
|
|
8
|
+
|
|
9
|
+
export default function getCornerstoneViewportType(
|
|
10
|
+
viewportType: string,
|
|
11
|
+
useNextViewports = false
|
|
12
|
+
): Enums.ViewportType {
|
|
13
|
+
const lowerViewportType = viewportType.toLowerCase();
|
|
14
|
+
|
|
15
|
+
switch (lowerViewportType) {
|
|
16
|
+
case 'planarnext':
|
|
17
|
+
return Enums.ViewportType.PLANAR_NEXT;
|
|
18
|
+
case 'volume3dnext':
|
|
19
|
+
return Enums.ViewportType.VOLUME_3D_NEXT;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (useNextViewports) {
|
|
23
|
+
switch (lowerViewportType) {
|
|
24
|
+
case STACK:
|
|
25
|
+
case VOLUME:
|
|
26
|
+
return Enums.ViewportType.PLANAR_NEXT;
|
|
27
|
+
case VOLUME_3D:
|
|
28
|
+
return Enums.ViewportType.VOLUME_3D_NEXT;
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Invalid viewport type: ${viewportType}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (lowerViewportType === STACK) {
|
|
35
|
+
return Enums.ViewportType.STACK;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (lowerViewportType === VOLUME) {
|
|
39
|
+
return Enums.ViewportType.ORTHOGRAPHIC;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (lowerViewportType === VOLUME_3D) {
|
|
43
|
+
return Enums.ViewportType.VOLUME_3D;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
throw new Error(`Invalid viewport type: ${viewportType}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function bySwitch(kind: string) {
|
|
50
|
+
switch (kind) {
|
|
51
|
+
case 'stack':
|
|
52
|
+
return ViewportType.STACK;
|
|
53
|
+
case 'volume':
|
|
54
|
+
return ViewportType.ORTHOGRAPHIC;
|
|
55
|
+
default:
|
|
56
|
+
return ViewportType.VOLUME_3D;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function byConstants(kind: string) {
|
|
61
|
+
const stackType = ViewportType.STACK;
|
|
62
|
+
const volumeType = ViewportType.ORTHOGRAPHIC;
|
|
63
|
+
|
|
64
|
+
if (kind === 'stack') {
|
|
65
|
+
return stackType;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return volumeType;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const STACK_TYPE = ViewportType.STACK;
|
|
72
|
+
const VOLUME_TYPE = ViewportType.ORTHOGRAPHIC;
|
|
73
|
+
|
|
74
|
+
export const byModuleConstants = (isStack: boolean) =>
|
|
75
|
+
isStack ? STACK_TYPE : VOLUME_TYPE;
|
|
76
|
+
|
|
77
|
+
export function byVariablesWithOneValue(isStack: boolean) {
|
|
78
|
+
let stackType = ViewportType.STACK;
|
|
79
|
+
let volumeType = ViewportType.ORTHOGRAPHIC;
|
|
80
|
+
|
|
81
|
+
return isStack ? stackType : (volumeType as Enums.ViewportType);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class Shapes {
|
|
85
|
+
shapeOf(isStack: boolean) {
|
|
86
|
+
if (isStack) {
|
|
87
|
+
return ViewportType.STACK;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return ViewportType.ORTHOGRAPHIC;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function assignedOnly(kind: string) {
|
|
95
|
+
let type;
|
|
96
|
+
|
|
97
|
+
if (kind === 'stack') {
|
|
98
|
+
type = ViewportType.STACK;
|
|
99
|
+
} else {
|
|
100
|
+
type = ViewportType.ORTHOGRAPHIC;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return type;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function assignedAfterTheDeclaration(kind: string) {
|
|
107
|
+
let type = ViewportType.STACK;
|
|
108
|
+
|
|
109
|
+
if (kind === 'volume') {
|
|
110
|
+
type = ViewportType.ORTHOGRAPHIC;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return type;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function writtenInAnotherWay(kinds: string[]) {
|
|
117
|
+
let type = ViewportType.STACK;
|
|
118
|
+
const volumeType = ViewportType.ORTHOGRAPHIC;
|
|
119
|
+
|
|
120
|
+
[type] = kinds as Enums.ViewportType[];
|
|
121
|
+
|
|
122
|
+
return kinds.length ? type : volumeType;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function inAConditional(isStack: boolean) {
|
|
126
|
+
return isStack ? ViewportType.STACK : ViewportType.ORTHOGRAPHIC;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function legacyAndNextThroughAVariable(useNext: boolean) {
|
|
130
|
+
let type = ViewportType.VOLUME_3D;
|
|
131
|
+
|
|
132
|
+
if (useNext) {
|
|
133
|
+
type = ViewportType.VOLUME_3D_NEXT;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return type;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function legacyAndNextInAConditional(useNext: boolean) {
|
|
140
|
+
return useNext ? ViewportType.VIDEO_NEXT : ViewportType.VIDEO;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function stackOnly() {
|
|
144
|
+
return ViewportType.STACK;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function volumeOnly() {
|
|
148
|
+
return ViewportType.ORTHOGRAPHIC;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function sameTypeTwice(early: boolean) {
|
|
152
|
+
if (early) {
|
|
153
|
+
return ViewportType.STACK;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return ViewportType.STACK;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function innerFunctionReturnsTheOther(kinds: string[]) {
|
|
160
|
+
kinds.map(() => {
|
|
161
|
+
return ViewportType.ORTHOGRAPHIC;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return ViewportType.STACK;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function alreadyOnSix(is3D: boolean) {
|
|
168
|
+
if (is3D) {
|
|
169
|
+
return ViewportType.VOLUME_3D;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return ViewportType.PLANAR;
|
|
173
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cornerstone3d-6-manual": [
|
|
3
|
+
{
|
|
4
|
+
"cardinality": {
|
|
5
|
+
"file": "input.ts",
|
|
6
|
+
"line": "100",
|
|
7
|
+
"rule": "ViewportType.ORTHOGRAPHIC"
|
|
8
|
+
},
|
|
9
|
+
"count": 1
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"cardinality": {
|
|
13
|
+
"file": "input.ts",
|
|
14
|
+
"line": "110",
|
|
15
|
+
"rule": "ViewportType.ORTHOGRAPHIC"
|
|
16
|
+
},
|
|
17
|
+
"count": 1
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"cardinality": {
|
|
21
|
+
"file": "input.ts",
|
|
22
|
+
"line": "126",
|
|
23
|
+
"rule": "ViewportType.ORTHOGRAPHIC"
|
|
24
|
+
},
|
|
25
|
+
"count": 1
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"cardinality": {
|
|
29
|
+
"file": "input.ts",
|
|
30
|
+
"line": "126",
|
|
31
|
+
"rule": "ViewportType.STACK"
|
|
32
|
+
},
|
|
33
|
+
"count": 1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"cardinality": {
|
|
37
|
+
"file": "input.ts",
|
|
38
|
+
"line": "98",
|
|
39
|
+
"rule": "ViewportType.STACK"
|
|
40
|
+
},
|
|
41
|
+
"count": 1
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"cornerstone3d-6-review": [
|
|
45
|
+
{
|
|
46
|
+
"cardinality": {
|
|
47
|
+
"file": "input.ts",
|
|
48
|
+
"line": "118",
|
|
49
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
50
|
+
},
|
|
51
|
+
"count": 1
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"cardinality": {
|
|
55
|
+
"file": "input.ts",
|
|
56
|
+
"line": "148",
|
|
57
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
58
|
+
},
|
|
59
|
+
"count": 1
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"cardinality": {
|
|
63
|
+
"file": "input.ts",
|
|
64
|
+
"line": "161",
|
|
65
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
66
|
+
},
|
|
67
|
+
"count": 1
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"cardinality": {
|
|
71
|
+
"file": "input.ts",
|
|
72
|
+
"line": "39",
|
|
73
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
74
|
+
},
|
|
75
|
+
"count": 1
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"cardinality": {
|
|
79
|
+
"file": "input.ts",
|
|
80
|
+
"line": "49",
|
|
81
|
+
"rule": "ViewportType.PLANAR: one function returned STACK and ORTHOGRAPHIC, read what its callers do with the answer"
|
|
82
|
+
},
|
|
83
|
+
"count": 1
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"cardinality": {
|
|
87
|
+
"file": "input.ts",
|
|
88
|
+
"line": "54",
|
|
89
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
90
|
+
},
|
|
91
|
+
"count": 1
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"cardinality": {
|
|
95
|
+
"file": "input.ts",
|
|
96
|
+
"line": "60",
|
|
97
|
+
"rule": "ViewportType.PLANAR: one function returned STACK and ORTHOGRAPHIC, read what its callers do with the answer"
|
|
98
|
+
},
|
|
99
|
+
"count": 1
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"cardinality": {
|
|
103
|
+
"file": "input.ts",
|
|
104
|
+
"line": "62",
|
|
105
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
106
|
+
},
|
|
107
|
+
"count": 1
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"cardinality": {
|
|
111
|
+
"file": "input.ts",
|
|
112
|
+
"line": "72",
|
|
113
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
114
|
+
},
|
|
115
|
+
"count": 1
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"cardinality": {
|
|
119
|
+
"file": "input.ts",
|
|
120
|
+
"line": "74",
|
|
121
|
+
"rule": "ViewportType.PLANAR: one function returned STACK and ORTHOGRAPHIC, read what its callers do with the answer"
|
|
122
|
+
},
|
|
123
|
+
"count": 1
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"cardinality": {
|
|
127
|
+
"file": "input.ts",
|
|
128
|
+
"line": "77",
|
|
129
|
+
"rule": "ViewportType.PLANAR: one function returned STACK and ORTHOGRAPHIC, read what its callers do with the answer"
|
|
130
|
+
},
|
|
131
|
+
"count": 1
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"cardinality": {
|
|
135
|
+
"file": "input.ts",
|
|
136
|
+
"line": "79",
|
|
137
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
138
|
+
},
|
|
139
|
+
"count": 1
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"cardinality": {
|
|
143
|
+
"file": "input.ts",
|
|
144
|
+
"line": "85",
|
|
145
|
+
"rule": "ViewportType.PLANAR: one function returned STACK and ORTHOGRAPHIC, read what its callers do with the answer"
|
|
146
|
+
},
|
|
147
|
+
"count": 1
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"cardinality": {
|
|
151
|
+
"file": "input.ts",
|
|
152
|
+
"line": "9",
|
|
153
|
+
"rule": "ViewportType.PLANAR: one function returned STACK and ORTHOGRAPHIC, read what its callers do with the answer"
|
|
154
|
+
},
|
|
155
|
+
"count": 1
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"cardinality": {
|
|
159
|
+
"file": "input.ts",
|
|
160
|
+
"line": "90",
|
|
161
|
+
"rule": "ViewportType.ORTHOGRAPHIC: orientation"
|
|
162
|
+
},
|
|
163
|
+
"count": 1
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|