@cornerstonejs/tools 0.61.5 → 0.61.7
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/dist/cjs/tools/CrosshairsTool.js +21 -29
- package/dist/cjs/tools/CrosshairsTool.js.map +1 -1
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js +26 -0
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/esm/tools/CrosshairsTool.js +21 -29
- package/dist/esm/tools/CrosshairsTool.js.map +1 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +26 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
- package/src/tools/CrosshairsTool.ts +33 -62
- package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +41 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.7",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"type": "individual",
|
|
53
53
|
"url": "https://ohif.org/donate"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "0bb66c6cb814db95508e50cca647e71ae6e7e7b7"
|
|
56
56
|
}
|
|
@@ -1464,79 +1464,50 @@ class CrosshairsTool extends AnnotationTool {
|
|
|
1464
1464
|
viewportId: string,
|
|
1465
1465
|
renderingEngine: Types.IRenderingEngine
|
|
1466
1466
|
): void {
|
|
1467
|
-
// 1.
|
|
1468
|
-
// 2.
|
|
1469
|
-
// 3. If it is outside, pan the viewport to fit in the toolCenter
|
|
1467
|
+
// 1. Check if the toolCenter is outside the viewport
|
|
1468
|
+
// 2. If it is outside, pan the viewport to fit in the toolCenter
|
|
1470
1469
|
|
|
1471
1470
|
const viewport = renderingEngine.getViewport(viewportId);
|
|
1472
1471
|
const { clientWidth, clientHeight } = viewport.canvas;
|
|
1473
|
-
|
|
1474
|
-
const
|
|
1475
|
-
clientWidth,
|
|
1476
|
-
clientHeight,
|
|
1477
|
-
]);
|
|
1478
|
-
const topRightWorld = viewport.canvasToWorld([clientWidth, 0]);
|
|
1479
|
-
const bottomLeftWorld = viewport.canvasToWorld([0, clientHeight]);
|
|
1480
|
-
|
|
1481
|
-
// find the minimum and maximum world coordinates in each x,y,z
|
|
1482
|
-
const minX = Math.min(
|
|
1483
|
-
topLefWorld[0],
|
|
1484
|
-
bottomRightWorld[0],
|
|
1485
|
-
topRightWorld[0],
|
|
1486
|
-
bottomLeftWorld[0]
|
|
1487
|
-
);
|
|
1488
|
-
const maxX = Math.max(
|
|
1489
|
-
topLefWorld[0],
|
|
1490
|
-
bottomRightWorld[0],
|
|
1491
|
-
topRightWorld[0],
|
|
1492
|
-
bottomLeftWorld[0]
|
|
1493
|
-
);
|
|
1494
|
-
const minY = Math.min(
|
|
1495
|
-
topLefWorld[1],
|
|
1496
|
-
bottomRightWorld[1],
|
|
1497
|
-
topRightWorld[1],
|
|
1498
|
-
bottomLeftWorld[1]
|
|
1499
|
-
);
|
|
1500
|
-
const maxY = Math.max(
|
|
1501
|
-
topLefWorld[1],
|
|
1502
|
-
bottomRightWorld[1],
|
|
1503
|
-
topRightWorld[1],
|
|
1504
|
-
bottomLeftWorld[1]
|
|
1505
|
-
);
|
|
1506
|
-
const minZ = Math.min(
|
|
1507
|
-
topLefWorld[2],
|
|
1508
|
-
bottomRightWorld[2],
|
|
1509
|
-
topRightWorld[2],
|
|
1510
|
-
bottomLeftWorld[2]
|
|
1511
|
-
);
|
|
1512
|
-
const maxZ = Math.max(
|
|
1513
|
-
topLefWorld[2],
|
|
1514
|
-
bottomRightWorld[2],
|
|
1515
|
-
topRightWorld[2],
|
|
1516
|
-
bottomLeftWorld[2]
|
|
1517
|
-
);
|
|
1472
|
+
|
|
1473
|
+
const toolCenterCanvas = viewport.worldToCanvas(this.toolCenter);
|
|
1518
1474
|
|
|
1519
1475
|
// pan the viewport to fit the toolCenter in the direction
|
|
1520
1476
|
// that is out of bounds
|
|
1521
|
-
let deltaPointsWorld;
|
|
1522
1477
|
const pan = this.configuration.autoPan.panSize;
|
|
1523
1478
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1479
|
+
const visiblePointCanvas = <Types.Point2>[
|
|
1480
|
+
toolCenterCanvas[0],
|
|
1481
|
+
toolCenterCanvas[1],
|
|
1482
|
+
];
|
|
1483
|
+
|
|
1484
|
+
if (toolCenterCanvas[0] < 0) {
|
|
1485
|
+
visiblePointCanvas[0] = pan;
|
|
1486
|
+
} else if (toolCenterCanvas[0] > clientWidth) {
|
|
1487
|
+
visiblePointCanvas[0] = clientWidth - pan;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
if (toolCenterCanvas[1] < 0) {
|
|
1491
|
+
visiblePointCanvas[1] = pan;
|
|
1492
|
+
} else if (toolCenterCanvas[1] > clientHeight) {
|
|
1493
|
+
visiblePointCanvas[1] = clientHeight - pan;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
if (
|
|
1497
|
+
visiblePointCanvas[0] === toolCenterCanvas[0] &&
|
|
1498
|
+
visiblePointCanvas[1] === toolCenterCanvas[1]
|
|
1499
|
+
) {
|
|
1537
1500
|
return;
|
|
1538
1501
|
}
|
|
1539
1502
|
|
|
1503
|
+
const visiblePointWorld = viewport.canvasToWorld(visiblePointCanvas);
|
|
1504
|
+
|
|
1505
|
+
const deltaPointsWorld = [
|
|
1506
|
+
visiblePointWorld[0] - this.toolCenter[0],
|
|
1507
|
+
visiblePointWorld[1] - this.toolCenter[1],
|
|
1508
|
+
visiblePointWorld[2] - this.toolCenter[2],
|
|
1509
|
+
];
|
|
1510
|
+
|
|
1540
1511
|
const camera = viewport.getCamera();
|
|
1541
1512
|
const { focalPoint, position } = camera;
|
|
1542
1513
|
|
|
@@ -134,6 +134,40 @@ function removeSegmentationRepresentation(
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Checks if a segmentation data have the same frameOfReference as the series
|
|
139
|
+
* displayed in a given viewport
|
|
140
|
+
* @param viewport
|
|
141
|
+
* @param referencedVolumeId volume id of the segmentation reference series
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
function isSameFrameOfReference(viewport, referencedVolumeId) {
|
|
145
|
+
// if the referencedVolumeId is not defined, we acted as before to not break
|
|
146
|
+
// applications as referencedVolumeId is inserted in this change
|
|
147
|
+
// Can modify that in the future commits
|
|
148
|
+
if (!referencedVolumeId) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
const defaultActor = viewport.getDefaultActor();
|
|
152
|
+
if (!defaultActor) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
const { uid: defaultActorUID } = defaultActor;
|
|
156
|
+
const volume = cache.getVolume(defaultActorUID);
|
|
157
|
+
|
|
158
|
+
if (volume) {
|
|
159
|
+
const referencedVolume = cache.getVolume(referencedVolumeId);
|
|
160
|
+
if (
|
|
161
|
+
referencedVolume &&
|
|
162
|
+
volume.metadata.FrameOfReferenceUID ===
|
|
163
|
+
referencedVolume.metadata.FrameOfReferenceUID
|
|
164
|
+
) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
137
171
|
/**
|
|
138
172
|
* It takes the enabled element, the segmentation Id, and the configuration, and
|
|
139
173
|
* it sets the segmentation for the enabled element as a labelmap
|
|
@@ -166,6 +200,9 @@ async function render(
|
|
|
166
200
|
throw new Error(`No Labelmap found for volumeId: ${labelmapUID}`);
|
|
167
201
|
}
|
|
168
202
|
|
|
203
|
+
if (!isSameFrameOfReference(viewport, labelmapData?.referencedVolumeId)) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
169
206
|
let actorEntry = viewport.getActor(segmentationRepresentationUID);
|
|
170
207
|
|
|
171
208
|
if (!actorEntry) {
|
|
@@ -182,6 +219,10 @@ async function render(
|
|
|
182
219
|
actorEntry = viewport.getActor(segmentationRepresentationUID);
|
|
183
220
|
}
|
|
184
221
|
|
|
222
|
+
if (!actorEntry) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
185
226
|
const { cfun, ofun } = renderingConfig as LabelmapRenderingConfig;
|
|
186
227
|
|
|
187
228
|
const renderInactiveSegmentations =
|