@cornerstonejs/tools 0.61.5 → 0.61.6
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/esm/tools/CrosshairsTool.js +21 -29
- package/dist/esm/tools/CrosshairsTool.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.6",
|
|
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": "afbe457fbdc35e3fc5a75985525fec85294263e9"
|
|
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
|
|