Skip to content

Commit d1fc292

Browse files
authored
format: adapters (#2499)
1 parent 782d0a3 commit d1fc292

24 files changed

Lines changed: 3161 additions & 3266 deletions

packages/adapters/src/adapters/Cornerstone/Angle.js

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
1-
import { utilities } from "dcmjs";
1+
import { utilities } from 'dcmjs';
22

3-
import MeasurementReport from "./MeasurementReport";
4-
import CORNERSTONE_4_TAG from "./cornerstone4Tag";
3+
import MeasurementReport from './MeasurementReport';
4+
import CORNERSTONE_4_TAG from './cornerstone4Tag';
55

66
const { Angle: TID300Angle } = utilities.TID300;
77

8-
const ANGLE = "Angle";
8+
const ANGLE = 'Angle';
99

1010
class Angle {
11-
/**
12-
* Generate TID300 measurement data for a plane angle measurement - use a Angle, but label it as Angle
13-
*/
14-
static getMeasurementData(MeasurementGroup) {
15-
const { defaultState, NUMGroup, SCOORDGroup } =
16-
MeasurementReport.getSetupMeasurementData(MeasurementGroup);
17-
18-
const state = {
19-
...defaultState,
20-
rAngle: NUMGroup.MeasuredValueSequence.NumericValue,
21-
toolType: Angle.toolType,
22-
handles: {
23-
start: {},
24-
middle: {},
25-
end: {},
26-
textBox: {
27-
hasMoved: false,
28-
movesIndependently: false,
29-
drawnIndependently: true,
30-
allowedOutsideImage: true,
31-
hasBoundingBox: true
32-
}
33-
}
34-
};
35-
36-
[
37-
state.handles.start.x,
38-
state.handles.start.y,
39-
state.handles.middle.x,
40-
state.handles.middle.y,
41-
state.handles.middle.x,
42-
state.handles.middle.y,
43-
state.handles.end.x,
44-
state.handles.end.y
45-
] = SCOORDGroup.GraphicData;
46-
47-
return state;
48-
}
49-
50-
static getTID300RepresentationArguments(tool) {
51-
const { handles, finding, findingSites } = tool;
52-
const point1 = handles.start;
53-
const point2 = handles.middle;
54-
const point3 = handles.middle;
55-
const point4 = handles.end;
56-
const rAngle = tool.rAngle;
57-
58-
const trackingIdentifierTextValue = "cornerstoneTools@^4.0.0:Angle";
59-
60-
return {
61-
point1,
62-
point2,
63-
point3,
64-
point4,
65-
rAngle,
66-
trackingIdentifierTextValue,
67-
finding,
68-
findingSites: findingSites || []
69-
};
70-
}
11+
/**
12+
* Generate TID300 measurement data for a plane angle measurement - use a Angle, but label it as Angle
13+
*/
14+
static getMeasurementData(MeasurementGroup) {
15+
const { defaultState, NUMGroup, SCOORDGroup } =
16+
MeasurementReport.getSetupMeasurementData(MeasurementGroup);
17+
18+
const state = {
19+
...defaultState,
20+
rAngle: NUMGroup.MeasuredValueSequence.NumericValue,
21+
toolType: Angle.toolType,
22+
handles: {
23+
start: {},
24+
middle: {},
25+
end: {},
26+
textBox: {
27+
hasMoved: false,
28+
movesIndependently: false,
29+
drawnIndependently: true,
30+
allowedOutsideImage: true,
31+
hasBoundingBox: true,
32+
},
33+
},
34+
};
35+
36+
[
37+
state.handles.start.x,
38+
state.handles.start.y,
39+
state.handles.middle.x,
40+
state.handles.middle.y,
41+
state.handles.middle.x,
42+
state.handles.middle.y,
43+
state.handles.end.x,
44+
state.handles.end.y,
45+
] = SCOORDGroup.GraphicData;
46+
47+
return state;
48+
}
49+
50+
static getTID300RepresentationArguments(tool) {
51+
const { handles, finding, findingSites } = tool;
52+
const point1 = handles.start;
53+
const point2 = handles.middle;
54+
const point3 = handles.middle;
55+
const point4 = handles.end;
56+
const rAngle = tool.rAngle;
57+
58+
const trackingIdentifierTextValue = 'cornerstoneTools@^4.0.0:Angle';
59+
60+
return {
61+
point1,
62+
point2,
63+
point3,
64+
point4,
65+
rAngle,
66+
trackingIdentifierTextValue,
67+
finding,
68+
findingSites: findingSites || [],
69+
};
70+
}
7171
}
7272

7373
Angle.toolType = ANGLE;
7474
Angle.utilityToolType = ANGLE;
7575
Angle.TID300Representation = TID300Angle;
76-
Angle.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
77-
if (!TrackingIdentifier.includes(":")) {
78-
return false;
79-
}
76+
Angle.isValidCornerstoneTrackingIdentifier = (TrackingIdentifier) => {
77+
if (!TrackingIdentifier.includes(':')) {
78+
return false;
79+
}
8080

81-
const [cornerstone4Tag, toolType] = TrackingIdentifier.split(":");
81+
const [cornerstone4Tag, toolType] = TrackingIdentifier.split(':');
8282

83-
if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
84-
return false;
85-
}
83+
if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
84+
return false;
85+
}
8686

87-
return toolType === ANGLE;
87+
return toolType === ANGLE;
8888
};
8989

9090
MeasurementReport.registerTool(Angle);

packages/adapters/src/adapters/Cornerstone/ArrowAnnotate.js

Lines changed: 76 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,96 @@
1-
import { utilities } from "dcmjs";
1+
import { utilities } from 'dcmjs';
22

3-
import MeasurementReport from "./MeasurementReport";
4-
import CORNERSTONE_4_TAG from "./cornerstone4Tag";
3+
import MeasurementReport from './MeasurementReport';
4+
import CORNERSTONE_4_TAG from './cornerstone4Tag';
55

66
const { Point: TID300Point } = utilities.TID300;
77

8-
const ARROW_ANNOTATE = "ArrowAnnotate";
9-
const CORNERSTONEFREETEXT = "CORNERSTONEFREETEXT";
8+
const ARROW_ANNOTATE = 'ArrowAnnotate';
9+
const CORNERSTONEFREETEXT = 'CORNERSTONEFREETEXT';
1010

1111
class ArrowAnnotate {
12-
static getMeasurementData(MeasurementGroup) {
13-
const { defaultState, SCOORDGroup, findingGroup } =
14-
MeasurementReport.getSetupMeasurementData(MeasurementGroup);
15-
16-
const { GraphicData } = SCOORDGroup;
17-
18-
const state = {
19-
...defaultState,
20-
toolType: ArrowAnnotate.toolType,
21-
active: false,
22-
handles: {
23-
start: {
24-
x: GraphicData[0],
25-
y: GraphicData[1],
26-
highlight: true,
27-
active: false
28-
},
29-
// Use a generic offset if the stored data doesn't have the endpoint, otherwise
30-
// use the actual endpoint.
31-
end: {
32-
x:
33-
GraphicData.length == 4
34-
? GraphicData[2]
35-
: GraphicData[0] + 20,
36-
y:
37-
GraphicData.length == 4
38-
? GraphicData[3]
39-
: GraphicData[1] + 20,
40-
highlight: true,
41-
active: false
42-
},
43-
textBox: {
44-
hasMoved: false,
45-
movesIndependently: false,
46-
drawnIndependently: true,
47-
allowedOutsideImage: true,
48-
hasBoundingBox: true
49-
}
50-
},
51-
invalidated: true,
52-
visible: true
53-
};
54-
55-
return state;
12+
static getMeasurementData(MeasurementGroup) {
13+
const { defaultState, SCOORDGroup, findingGroup } =
14+
MeasurementReport.getSetupMeasurementData(MeasurementGroup);
15+
16+
const { GraphicData } = SCOORDGroup;
17+
18+
const state = {
19+
...defaultState,
20+
toolType: ArrowAnnotate.toolType,
21+
active: false,
22+
handles: {
23+
start: {
24+
x: GraphicData[0],
25+
y: GraphicData[1],
26+
highlight: true,
27+
active: false,
28+
},
29+
// Use a generic offset if the stored data doesn't have the endpoint, otherwise
30+
// use the actual endpoint.
31+
end: {
32+
x: GraphicData.length == 4 ? GraphicData[2] : GraphicData[0] + 20,
33+
y: GraphicData.length == 4 ? GraphicData[3] : GraphicData[1] + 20,
34+
highlight: true,
35+
active: false,
36+
},
37+
textBox: {
38+
hasMoved: false,
39+
movesIndependently: false,
40+
drawnIndependently: true,
41+
allowedOutsideImage: true,
42+
hasBoundingBox: true,
43+
},
44+
},
45+
invalidated: true,
46+
visible: true,
47+
};
48+
49+
return state;
50+
}
51+
52+
static getTID300RepresentationArguments(tool) {
53+
const points = [tool.handles.start, tool.handles.end];
54+
55+
const { findingSites } = tool;
56+
let { finding } = tool;
57+
58+
const TID300RepresentationArguments = {
59+
points,
60+
trackingIdentifierTextValue: `cornerstoneTools@^4.0.0:ArrowAnnotate`,
61+
findingSites: findingSites || [],
62+
};
63+
64+
// If freetext finding isn't present, add it from the tool label.
65+
if (!finding || finding.CodeValue !== CORNERSTONEFREETEXT) {
66+
finding = {
67+
CodeValue: CORNERSTONEFREETEXT,
68+
CodingSchemeDesignator: 'CST4',
69+
CodeMeaning: tool.label,
70+
};
5671
}
5772

58-
static getTID300RepresentationArguments(tool) {
59-
const points = [tool.handles.start, tool.handles.end];
73+
TID300RepresentationArguments.finding = finding;
6074

61-
const { findingSites } = tool;
62-
let { finding } = tool;
63-
64-
const TID300RepresentationArguments = {
65-
points,
66-
trackingIdentifierTextValue: `cornerstoneTools@^4.0.0:ArrowAnnotate`,
67-
findingSites: findingSites || []
68-
};
69-
70-
// If freetext finding isn't present, add it from the tool label.
71-
if (!finding || finding.CodeValue !== CORNERSTONEFREETEXT) {
72-
finding = {
73-
CodeValue: CORNERSTONEFREETEXT,
74-
CodingSchemeDesignator: "CST4",
75-
CodeMeaning: tool.label
76-
};
77-
}
78-
79-
TID300RepresentationArguments.finding = finding;
80-
81-
return TID300RepresentationArguments;
82-
}
75+
return TID300RepresentationArguments;
76+
}
8377
}
8478

8579
ArrowAnnotate.toolType = ARROW_ANNOTATE;
8680
ArrowAnnotate.utilityToolType = ARROW_ANNOTATE;
8781
ArrowAnnotate.TID300Representation = TID300Point;
88-
ArrowAnnotate.isValidCornerstoneTrackingIdentifier = TrackingIdentifier => {
89-
if (!TrackingIdentifier.includes(":")) {
90-
return false;
91-
}
82+
ArrowAnnotate.isValidCornerstoneTrackingIdentifier = (TrackingIdentifier) => {
83+
if (!TrackingIdentifier.includes(':')) {
84+
return false;
85+
}
9286

93-
const [cornerstone4Tag, toolType] = TrackingIdentifier.split(":");
87+
const [cornerstone4Tag, toolType] = TrackingIdentifier.split(':');
9488

95-
if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
96-
return false;
97-
}
89+
if (cornerstone4Tag !== CORNERSTONE_4_TAG) {
90+
return false;
91+
}
9892

99-
return toolType === ARROW_ANNOTATE;
93+
return toolType === ARROW_ANNOTATE;
10094
};
10195

10296
MeasurementReport.registerTool(ArrowAnnotate);

0 commit comments

Comments
 (0)