@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "0.61.5",
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": "9301f3dd164dbd88664a0e1961f686234fe29919"
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. Compute the current world bounding box of the viewport from corner to corner
1468
- // 2. Check if the toolCenter is outside of the world bounding box
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
- const topLefWorld = viewport.canvasToWorld([0, 0]);
1474
- const bottomRightWorld = viewport.canvasToWorld([
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
- if (this.toolCenter[0] < minX - EPSILON) {
1525
- deltaPointsWorld = [minX - this.toolCenter[0] + pan, 0, 0];
1526
- } else if (this.toolCenter[0] > maxX + EPSILON) {
1527
- deltaPointsWorld = [maxX - this.toolCenter[0] - pan, 0, 0];
1528
- } else if (this.toolCenter[1] < minY - EPSILON) {
1529
- deltaPointsWorld = [0, minY - this.toolCenter[1] + pan, 0];
1530
- } else if (this.toolCenter[1] > maxY + EPSILON) {
1531
- deltaPointsWorld = [0, maxY - this.toolCenter[1] - pan, 0];
1532
- } else if (this.toolCenter[2] < minZ - EPSILON) {
1533
- deltaPointsWorld = [0, 0, minZ - this.toolCenter[2] + pan];
1534
- } else if (this.toolCenter[2] > maxZ + EPSILON) {
1535
- deltaPointsWorld = [0, 0, maxZ - this.toolCenter[2] - pan];
1536
- } else {
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