@ohif/app 3.8.0-beta.34 → 3.8.0-beta.36
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/{170.bundle.4fbae6bee18b7029ee16.js → 170.bundle.68030fbeb41c3b9f8fc5.js} +9 -9
- package/dist/{181.bundle.ae92b8a551d041d06e90.js → 181.bundle.d2fe517852935b82368b.js} +4 -4
- package/dist/{185.bundle.b9c07345d013fd7703a3.js → 185.bundle.c0123f4dc6721f89c3fb.js} +2 -2
- package/dist/{199.bundle.938af45362af3b5f0177.js → 199.bundle.ad2d8fe29adaf8351892.js} +2 -2
- package/dist/{250.bundle.09c69d348a5d965debc8.js → 250.bundle.ba94ff371388e395cd05.js} +2 -2
- package/dist/{456.bundle.8ab9a01c88d2f2e9fcad.js → 456.bundle.23c8a1864c8a73d61431.js} +5 -5
- package/dist/{466.bundle.090a8294f4c8f72646a4.js → 466.bundle.dfbfe891b1796dcd3202.js} +4 -4
- package/dist/{483.bundle.c6fabbd21a990ac6d919.js → 483.bundle.bba6af7fc56c0bdd7f47.js} +4 -4
- package/dist/{566.bundle.4840518afd323372c70f.js → 514.bundle.e89082f91e5a7ef3e039.js} +865 -9
- package/dist/{738.bundle.0d7b7957708216809133.js → 738.bundle.e3b5dfe1641d2fa31a4a.js} +2 -2
- package/dist/{822.bundle.55759fd8e9b0b489cc6b.js → 822.bundle.f5ae3f366ce742fb060a.js} +2 -2
- package/dist/{95.bundle.d7a9f450bed3b770504d.js → 95.bundle.830304446bffa705883c.js} +2 -2
- package/dist/{app.bundle.14bd3b70f68243dd822d.js → app.bundle.355b2090b636cb6685e7.js} +185 -17
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +18 -18
- /package/dist/{12.bundle.f6b8fca3d7d631530f77.js → 12.bundle.b04783905602e7a39e75.js} +0 -0
- /package/dist/{19.bundle.a88db025c4d3aa455a25.js → 19.bundle.c99afb9553eff394fb21.js} +0 -0
- /package/dist/{281.bundle.8a1b8a2d2daec1cfd2b5.js → 281.bundle.8072673a742f48b1635f.js} +0 -0
- /package/dist/{359.bundle.74802060f22ec11e22b8.js → 359.bundle.5a4fef973fa991f39e7e.js} +0 -0
- /package/dist/{410.bundle.e16f52b715e1f3b0e130.js → 410.bundle.a31626fae42ed2d37134.js} +0 -0
- /package/dist/{506.bundle.862683a37c9addfc0a36.js → 506.bundle.521f7917257d3d6d2724.js} +0 -0
- /package/dist/{613.bundle.26c7bb7e2d7e7bd60597.js → 613.bundle.7b076c886664b281547f.js} +0 -0
- /package/dist/{687.bundle.1a5281313b618c99b42a.js → 687.bundle.6bd52991c7a20d72eac0.js} +0 -0
- /package/dist/{814.bundle.dfd2a2f651cc777e745f.js → 814.bundle.1b8ff6e92b6bb0187729.js} +0 -0
- /package/dist/{965.bundle.fecaa890411a2618060a.js → 965.bundle.7e3a36592b72e036ddaa.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[
|
|
1
|
+
(globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[514],{
|
|
2
2
|
|
|
3
|
-
/***/
|
|
3
|
+
/***/ 4514:
|
|
4
4
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
@@ -27,6 +27,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
Enums: () => (/* reexport */ enums_namespaceObject),
|
|
28
28
|
KeyImageTool: () => (/* reexport */ annotation_KeyImageTool),
|
|
29
29
|
LengthTool: () => (/* reexport */ annotation_LengthTool),
|
|
30
|
+
LivewireContourTool: () => (/* reexport */ annotation_LivewireContourTool),
|
|
30
31
|
MIPJumpToClickTool: () => (/* reexport */ tools_MIPJumpToClickTool),
|
|
31
32
|
MagnifyTool: () => (/* reexport */ tools_MagnifyTool),
|
|
32
33
|
OrientationMarkerTool: () => (/* reexport */ tools_OrientationMarkerTool),
|
|
@@ -648,8 +649,8 @@ __webpack_require__.d(synchronizers_namespaceObject, {
|
|
|
648
649
|
var types_namespaceObject = {};
|
|
649
650
|
__webpack_require__.r(types_namespaceObject);
|
|
650
651
|
|
|
651
|
-
// EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js +
|
|
652
|
-
var esm = __webpack_require__(
|
|
652
|
+
// EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js + 368 modules
|
|
653
|
+
var esm = __webpack_require__(62881);
|
|
653
654
|
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/enums/ToolBindings.js
|
|
654
655
|
var MouseBindings;
|
|
655
656
|
(function (MouseBindings) {
|
|
@@ -2862,7 +2863,7 @@ function isStackSegmentation(operationData) {
|
|
|
2862
2863
|
undefined);
|
|
2863
2864
|
}
|
|
2864
2865
|
function isVolumeSegmentation(operationData) {
|
|
2865
|
-
return (operationData
|
|
2866
|
+
return (operationData?.volumeId !== undefined);
|
|
2866
2867
|
}
|
|
2867
2868
|
|
|
2868
2869
|
|
|
@@ -4137,7 +4138,6 @@ const CORNERSTONE_COLOR_LUT = [
|
|
|
4137
4138
|
|
|
4138
4139
|
|
|
4139
4140
|
|
|
4140
|
-
|
|
4141
4141
|
async function addSegmentationRepresentation_addSegmentationRepresentation(toolGroupId, representationInput, toolGroupSpecificConfig) {
|
|
4142
4142
|
const { segmentationId, options = {} } = representationInput;
|
|
4143
4143
|
const segmentationRepresentationUID = esm.utilities.uuidv4();
|
|
@@ -4158,7 +4158,7 @@ async function addSegmentationRepresentation_addSegmentationRepresentation(toolG
|
|
|
4158
4158
|
const toolGroupSpecificRepresentation = {
|
|
4159
4159
|
segmentationId,
|
|
4160
4160
|
segmentationRepresentationUID,
|
|
4161
|
-
type:
|
|
4161
|
+
type: representationInput.type,
|
|
4162
4162
|
segmentsHidden,
|
|
4163
4163
|
colorLUTIndex: colorLUTIndexToUse,
|
|
4164
4164
|
active: true,
|
|
@@ -14798,7 +14798,7 @@ class VolumeRotateMouseWheelTool extends base_BaseTool {
|
|
|
14798
14798
|
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
14799
14799
|
configuration: {
|
|
14800
14800
|
direction: DIRECTIONS.Z,
|
|
14801
|
-
rotateIncrementDegrees:
|
|
14801
|
+
rotateIncrementDegrees: 30,
|
|
14802
14802
|
},
|
|
14803
14803
|
}) {
|
|
14804
14804
|
super(toolProps, defaultToolProps);
|
|
@@ -14813,7 +14813,7 @@ class VolumeRotateMouseWheelTool extends base_BaseTool {
|
|
|
14813
14813
|
const { direction: deltaY } = wheel;
|
|
14814
14814
|
const [cx, cy, cz] = focalPoint;
|
|
14815
14815
|
const [ax, ay, az] = direction;
|
|
14816
|
-
const angle = deltaY * rotateIncrementDegrees;
|
|
14816
|
+
const angle = (deltaY * (rotateIncrementDegrees * Math.PI)) / 180;
|
|
14817
14817
|
const newPosition = [0, 0, 0];
|
|
14818
14818
|
const newFocalPoint = [0, 0, 0];
|
|
14819
14819
|
const newViewUp = [0, 0, 0];
|
|
@@ -26357,6 +26357,861 @@ function PlanarFreehandROITool_defaultGetTextLines(data, targetId) {
|
|
|
26357
26357
|
PlanarFreehandROITool.toolName = 'PlanarFreehandROI';
|
|
26358
26358
|
/* harmony default export */ const annotation_PlanarFreehandROITool = (PlanarFreehandROITool);
|
|
26359
26359
|
|
|
26360
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/BucketQueue.js
|
|
26361
|
+
class BucketQueue {
|
|
26362
|
+
constructor({ numBits, getPriority, areEqual, }) {
|
|
26363
|
+
this._bucketCount = 1 << numBits;
|
|
26364
|
+
this._mask = this._bucketCount - 1;
|
|
26365
|
+
this._size = 0;
|
|
26366
|
+
this._currentBucketIndex = 0;
|
|
26367
|
+
this._buckets = this._buildArray(this._bucketCount);
|
|
26368
|
+
this._getPriority =
|
|
26369
|
+
typeof getPriority !== 'undefined'
|
|
26370
|
+
? getPriority
|
|
26371
|
+
: (item) => item;
|
|
26372
|
+
this._areEqual =
|
|
26373
|
+
typeof areEqual === 'function'
|
|
26374
|
+
? areEqual
|
|
26375
|
+
: (itemA, itemB) => itemA === itemB;
|
|
26376
|
+
}
|
|
26377
|
+
push(item) {
|
|
26378
|
+
const bucketIndex = this._getBucketIndex(item);
|
|
26379
|
+
const oldHead = this._buckets[bucketIndex];
|
|
26380
|
+
const newHead = {
|
|
26381
|
+
value: item,
|
|
26382
|
+
next: oldHead,
|
|
26383
|
+
};
|
|
26384
|
+
this._buckets[bucketIndex] = newHead;
|
|
26385
|
+
this._size++;
|
|
26386
|
+
}
|
|
26387
|
+
pop() {
|
|
26388
|
+
if (this._size === 0) {
|
|
26389
|
+
throw new Error('Cannot pop because the queue is empty.');
|
|
26390
|
+
}
|
|
26391
|
+
while (this._buckets[this._currentBucketIndex] === null) {
|
|
26392
|
+
this._currentBucketIndex =
|
|
26393
|
+
(this._currentBucketIndex + 1) % this._bucketCount;
|
|
26394
|
+
}
|
|
26395
|
+
const ret = this._buckets[this._currentBucketIndex];
|
|
26396
|
+
this._buckets[this._currentBucketIndex] = ret.next;
|
|
26397
|
+
this._size--;
|
|
26398
|
+
return ret.value;
|
|
26399
|
+
}
|
|
26400
|
+
remove(item) {
|
|
26401
|
+
if (!item) {
|
|
26402
|
+
return false;
|
|
26403
|
+
}
|
|
26404
|
+
const bucketIndex = this._getBucketIndex(item);
|
|
26405
|
+
const firstBucketNode = this._buckets[bucketIndex];
|
|
26406
|
+
let node = firstBucketNode;
|
|
26407
|
+
let prevNode;
|
|
26408
|
+
while (node !== null) {
|
|
26409
|
+
if (this._areEqual(item, node.value)) {
|
|
26410
|
+
break;
|
|
26411
|
+
}
|
|
26412
|
+
prevNode = node;
|
|
26413
|
+
node = node.next;
|
|
26414
|
+
}
|
|
26415
|
+
if (node === null) {
|
|
26416
|
+
return false;
|
|
26417
|
+
}
|
|
26418
|
+
if (node === firstBucketNode) {
|
|
26419
|
+
this._buckets[bucketIndex] = node.next;
|
|
26420
|
+
}
|
|
26421
|
+
else {
|
|
26422
|
+
prevNode.next = node.next;
|
|
26423
|
+
}
|
|
26424
|
+
this._size--;
|
|
26425
|
+
return true;
|
|
26426
|
+
}
|
|
26427
|
+
isEmpty() {
|
|
26428
|
+
return this._size === 0;
|
|
26429
|
+
}
|
|
26430
|
+
_getBucketIndex(item) {
|
|
26431
|
+
return this._getPriority(item) & this._mask;
|
|
26432
|
+
}
|
|
26433
|
+
_buildArray(size) {
|
|
26434
|
+
const buckets = new Array(size);
|
|
26435
|
+
buckets.fill(null);
|
|
26436
|
+
return buckets;
|
|
26437
|
+
}
|
|
26438
|
+
}
|
|
26439
|
+
|
|
26440
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/livewire/LivewireScissors.js
|
|
26441
|
+
|
|
26442
|
+
const MAX_UINT32 = 4294967295;
|
|
26443
|
+
const TWO_THIRD_PI = 2 / (3 * Math.PI);
|
|
26444
|
+
class LivewireScissors {
|
|
26445
|
+
constructor(grayscalePixelData, width, height) {
|
|
26446
|
+
this._getPointIndex = (row, col) => {
|
|
26447
|
+
const { width } = this;
|
|
26448
|
+
return row * width + col;
|
|
26449
|
+
};
|
|
26450
|
+
this._getPointCoordinate = (index) => {
|
|
26451
|
+
const x = index % this.width;
|
|
26452
|
+
const y = Math.floor(index / this.width);
|
|
26453
|
+
return [x, y];
|
|
26454
|
+
};
|
|
26455
|
+
this._getPointCost = (pointIndex) => {
|
|
26456
|
+
return Math.round(this.searchGranularity * this.costs[pointIndex]);
|
|
26457
|
+
};
|
|
26458
|
+
const numPixels = grayscalePixelData.length;
|
|
26459
|
+
this.searchGranularityBits = 8;
|
|
26460
|
+
this.searchGranularity = 1 << this.searchGranularityBits;
|
|
26461
|
+
this.width = width;
|
|
26462
|
+
this.height = height;
|
|
26463
|
+
this.grayscalePixelData = grayscalePixelData;
|
|
26464
|
+
this.laplace = null;
|
|
26465
|
+
this.gradXNew = null;
|
|
26466
|
+
this.gradYNew = null;
|
|
26467
|
+
this.laplace = this._computeLaplace();
|
|
26468
|
+
this.gradMagnitude = this._computeGradient();
|
|
26469
|
+
this.gradXNew = this._computeGradientX();
|
|
26470
|
+
this.gradYNew = this._computeGradientY();
|
|
26471
|
+
this.visited = new Array(numPixels);
|
|
26472
|
+
this.parents = new Uint32Array(numPixels);
|
|
26473
|
+
this.costs = new Float32Array(numPixels);
|
|
26474
|
+
}
|
|
26475
|
+
startSearch(startPoint) {
|
|
26476
|
+
const startPointIndex = this._getPointIndex(startPoint[1], startPoint[0]);
|
|
26477
|
+
this.startPoint = null;
|
|
26478
|
+
this.visited.fill(false);
|
|
26479
|
+
this.parents.fill(MAX_UINT32);
|
|
26480
|
+
this.costs.fill(Infinity);
|
|
26481
|
+
this.priorityQueueNew = new BucketQueue({
|
|
26482
|
+
numBits: this.searchGranularityBits,
|
|
26483
|
+
getPriority: this._getPointCost,
|
|
26484
|
+
});
|
|
26485
|
+
this.startPoint = startPoint;
|
|
26486
|
+
this.costs[startPointIndex] = 0;
|
|
26487
|
+
this.priorityQueueNew.push(startPointIndex);
|
|
26488
|
+
}
|
|
26489
|
+
findPathToPoint(targetPoint) {
|
|
26490
|
+
if (!this.startPoint) {
|
|
26491
|
+
throw new Error('There is no search in progress');
|
|
26492
|
+
}
|
|
26493
|
+
const { startPoint, _getPointIndex: index, _getPointCoordinate: coord, } = this;
|
|
26494
|
+
const startPointIndex = index(startPoint[1], startPoint[0]);
|
|
26495
|
+
const targetPointIndex = index(targetPoint[1], targetPoint[0]);
|
|
26496
|
+
const { visited: visited, parents: parents, costs: cost, priorityQueueNew: priorityQueue, } = this;
|
|
26497
|
+
if (targetPointIndex === startPointIndex) {
|
|
26498
|
+
return [];
|
|
26499
|
+
}
|
|
26500
|
+
while (!priorityQueue.isEmpty() &&
|
|
26501
|
+
parents[targetPointIndex] === MAX_UINT32) {
|
|
26502
|
+
const pointIndex = priorityQueue.pop();
|
|
26503
|
+
if (visited[pointIndex]) {
|
|
26504
|
+
continue;
|
|
26505
|
+
}
|
|
26506
|
+
const point = coord(pointIndex);
|
|
26507
|
+
const neighborsPoints = this._getNeighborPoints(point);
|
|
26508
|
+
visited[pointIndex] = true;
|
|
26509
|
+
for (let i = 0, len = neighborsPoints.length; i < len; i++) {
|
|
26510
|
+
const neighborPoint = neighborsPoints[i];
|
|
26511
|
+
const neighbordPointIndex = index(neighborPoint[1], neighborPoint[0]);
|
|
26512
|
+
const dist = this._getWeightedDistance(point, neighborPoint);
|
|
26513
|
+
const neighborCost = cost[pointIndex] + dist;
|
|
26514
|
+
if (neighborCost < cost[neighbordPointIndex]) {
|
|
26515
|
+
if (cost[neighbordPointIndex] !== Infinity) {
|
|
26516
|
+
priorityQueue.remove(neighbordPointIndex);
|
|
26517
|
+
}
|
|
26518
|
+
cost[neighbordPointIndex] = neighborCost;
|
|
26519
|
+
parents[neighbordPointIndex] = pointIndex;
|
|
26520
|
+
priorityQueue.push(neighbordPointIndex);
|
|
26521
|
+
}
|
|
26522
|
+
}
|
|
26523
|
+
}
|
|
26524
|
+
const pathPoints = [];
|
|
26525
|
+
let pathPointIndex = targetPointIndex;
|
|
26526
|
+
while (pathPointIndex !== MAX_UINT32) {
|
|
26527
|
+
pathPoints.push(coord(pathPointIndex));
|
|
26528
|
+
pathPointIndex = parents[pathPointIndex];
|
|
26529
|
+
}
|
|
26530
|
+
return pathPoints.reverse();
|
|
26531
|
+
}
|
|
26532
|
+
_getDeltaX(x, y) {
|
|
26533
|
+
const { grayscalePixelData: data, width } = this;
|
|
26534
|
+
let index = this._getPointIndex(y, x);
|
|
26535
|
+
if (x + 1 === width) {
|
|
26536
|
+
index--;
|
|
26537
|
+
}
|
|
26538
|
+
return data[index + 1] - data[index];
|
|
26539
|
+
}
|
|
26540
|
+
_getDeltaY(x, y) {
|
|
26541
|
+
const { grayscalePixelData: data, width, height } = this;
|
|
26542
|
+
let index = this._getPointIndex(y, x);
|
|
26543
|
+
if (y + 1 === height) {
|
|
26544
|
+
index -= height;
|
|
26545
|
+
}
|
|
26546
|
+
return data[index] - data[index + width];
|
|
26547
|
+
}
|
|
26548
|
+
_getGradientMagnitude(x, y) {
|
|
26549
|
+
const dx = this._getDeltaX(x, y);
|
|
26550
|
+
const dy = this._getDeltaY(x, y);
|
|
26551
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
26552
|
+
}
|
|
26553
|
+
_getLaplace(x, y) {
|
|
26554
|
+
const { grayscalePixelData: data, _getPointIndex: index } = this;
|
|
26555
|
+
const p02 = data[index(y - 2, x)];
|
|
26556
|
+
const p11 = data[index(y - 1, x - 1)];
|
|
26557
|
+
const p12 = data[index(y - 1, x)];
|
|
26558
|
+
const p13 = data[index(y - 1, x + 1)];
|
|
26559
|
+
const p20 = data[index(y, x - 2)];
|
|
26560
|
+
const p21 = data[index(y, x - 1)];
|
|
26561
|
+
const p22 = data[index(y, x)];
|
|
26562
|
+
const p23 = data[index(y, x + 1)];
|
|
26563
|
+
const p24 = data[index(y, x + 2)];
|
|
26564
|
+
const p31 = data[index(y + 1, x - 1)];
|
|
26565
|
+
const p32 = data[index(y + 1, x)];
|
|
26566
|
+
const p33 = data[index(y + 1, x + 1)];
|
|
26567
|
+
const p42 = data[index(y + 2, x)];
|
|
26568
|
+
let lap = p02;
|
|
26569
|
+
lap += p11 + 2 * p12 + p13;
|
|
26570
|
+
lap += p20 + 2 * p21 - 16 * p22 + 2 * p23 + p24;
|
|
26571
|
+
lap += p31 + 2 * p32 + p33;
|
|
26572
|
+
lap += p42;
|
|
26573
|
+
return lap;
|
|
26574
|
+
}
|
|
26575
|
+
_computeGradient() {
|
|
26576
|
+
const { width, height } = this;
|
|
26577
|
+
const gradient = new Float32Array(width * height);
|
|
26578
|
+
let pixelIndex = 0;
|
|
26579
|
+
let max = 0;
|
|
26580
|
+
let x = 0;
|
|
26581
|
+
let y = 0;
|
|
26582
|
+
for (y = 0; y < height - 1; y++) {
|
|
26583
|
+
for (x = 0; x < width - 1; x++) {
|
|
26584
|
+
gradient[pixelIndex] = this._getGradientMagnitude(x, y);
|
|
26585
|
+
max = Math.max(gradient[pixelIndex], max);
|
|
26586
|
+
pixelIndex++;
|
|
26587
|
+
}
|
|
26588
|
+
gradient[pixelIndex] = gradient[pixelIndex - 1];
|
|
26589
|
+
pixelIndex++;
|
|
26590
|
+
}
|
|
26591
|
+
for (let len = gradient.length; pixelIndex < len; pixelIndex++) {
|
|
26592
|
+
gradient[pixelIndex] = gradient[pixelIndex - width];
|
|
26593
|
+
}
|
|
26594
|
+
for (let i = 0, len = gradient.length; i < len; i++) {
|
|
26595
|
+
gradient[i] = 1 - gradient[i] / max;
|
|
26596
|
+
}
|
|
26597
|
+
return gradient;
|
|
26598
|
+
}
|
|
26599
|
+
_computeLaplace() {
|
|
26600
|
+
const { width, height, _getPointIndex: index } = this;
|
|
26601
|
+
const laplace = new Float32Array(width * height);
|
|
26602
|
+
laplace.fill(1, 0, index(2, 0));
|
|
26603
|
+
for (let y = 2; y < height - 2; y++) {
|
|
26604
|
+
laplace[index(y, 0)] = 1;
|
|
26605
|
+
laplace[index(y, 1)] = 1;
|
|
26606
|
+
for (let x = 2; x < width - 2; x++) {
|
|
26607
|
+
laplace[index(y, x)] = this._getLaplace(x, y) > 0.33 ? 0 : 1;
|
|
26608
|
+
}
|
|
26609
|
+
laplace[index(y, width - 2)] = 1;
|
|
26610
|
+
laplace[index(y, width - 1)] = 1;
|
|
26611
|
+
}
|
|
26612
|
+
laplace.fill(1, index(height - 2, 0));
|
|
26613
|
+
return laplace;
|
|
26614
|
+
}
|
|
26615
|
+
_computeGradientX() {
|
|
26616
|
+
const { width, height } = this;
|
|
26617
|
+
const gradX = new Float32Array(width * height);
|
|
26618
|
+
let pixelIndex = 0;
|
|
26619
|
+
for (let y = 0; y < height; y++) {
|
|
26620
|
+
for (let x = 0; x < width - 1; x++) {
|
|
26621
|
+
gradX[pixelIndex++] = this._getDeltaX(x, y);
|
|
26622
|
+
}
|
|
26623
|
+
gradX[pixelIndex] = gradX[pixelIndex - 1];
|
|
26624
|
+
pixelIndex++;
|
|
26625
|
+
}
|
|
26626
|
+
return gradX;
|
|
26627
|
+
}
|
|
26628
|
+
_computeGradientY() {
|
|
26629
|
+
const { width, height } = this;
|
|
26630
|
+
const gradY = new Float32Array(width * height);
|
|
26631
|
+
let pixelIndex = 0;
|
|
26632
|
+
for (let y = 0; y < height - 1; y++) {
|
|
26633
|
+
for (let x = 0; x < width; x++) {
|
|
26634
|
+
gradY[pixelIndex++] = this._getDeltaY(x, y);
|
|
26635
|
+
}
|
|
26636
|
+
}
|
|
26637
|
+
for (let len = gradY.length; pixelIndex < len; pixelIndex++) {
|
|
26638
|
+
gradY[pixelIndex] = gradY[pixelIndex - width];
|
|
26639
|
+
}
|
|
26640
|
+
return gradY;
|
|
26641
|
+
}
|
|
26642
|
+
_getGradientUnitVector(px, py) {
|
|
26643
|
+
const { gradXNew, gradYNew, _getPointIndex: index } = this;
|
|
26644
|
+
const pointGradX = gradXNew[index(py, px)];
|
|
26645
|
+
const pointGradY = gradYNew[index(py, px)];
|
|
26646
|
+
let gradVecLen = Math.sqrt(pointGradX * pointGradX + pointGradY * pointGradY);
|
|
26647
|
+
gradVecLen = Math.max(gradVecLen, 1e-100);
|
|
26648
|
+
return [pointGradX / gradVecLen, pointGradY / gradVecLen];
|
|
26649
|
+
}
|
|
26650
|
+
_getGradientDirection(px, py, qx, qy) {
|
|
26651
|
+
const dgpUnitVec = this._getGradientUnitVector(px, py);
|
|
26652
|
+
const gdqUnitVec = this._getGradientUnitVector(qx, qy);
|
|
26653
|
+
let dp = dgpUnitVec[1] * (qx - px) - dgpUnitVec[0] * (qy - py);
|
|
26654
|
+
let dq = gdqUnitVec[1] * (qx - px) - gdqUnitVec[0] * (qy - py);
|
|
26655
|
+
if (dp < 0) {
|
|
26656
|
+
dp = -dp;
|
|
26657
|
+
dq = -dq;
|
|
26658
|
+
}
|
|
26659
|
+
if (px !== qx && py !== qy) {
|
|
26660
|
+
dp *= Math.SQRT1_2;
|
|
26661
|
+
dq *= Math.SQRT1_2;
|
|
26662
|
+
}
|
|
26663
|
+
return TWO_THIRD_PI * (Math.acos(dp) + Math.acos(dq));
|
|
26664
|
+
}
|
|
26665
|
+
_getWeightedDistance(pointA, pointB) {
|
|
26666
|
+
const { _getPointIndex: index } = this;
|
|
26667
|
+
const [aX, aY] = pointA;
|
|
26668
|
+
const [bX, bY] = pointB;
|
|
26669
|
+
const bIndex = index(bY, bX);
|
|
26670
|
+
let gradient = this.gradMagnitude[bIndex];
|
|
26671
|
+
if (aX === bX || aY === bY) {
|
|
26672
|
+
gradient *= Math.SQRT1_2;
|
|
26673
|
+
}
|
|
26674
|
+
const laplace = this.laplace[bIndex];
|
|
26675
|
+
const direction = this._getGradientDirection(aX, aY, bX, bY);
|
|
26676
|
+
return 0.43 * gradient + 0.43 * laplace + 0.11 * direction;
|
|
26677
|
+
}
|
|
26678
|
+
_getNeighborPoints(point) {
|
|
26679
|
+
const { width, height } = this;
|
|
26680
|
+
const list = [];
|
|
26681
|
+
const sx = Math.max(point[0] - 1, 0);
|
|
26682
|
+
const sy = Math.max(point[1] - 1, 0);
|
|
26683
|
+
const ex = Math.min(point[0] + 1, width - 1);
|
|
26684
|
+
const ey = Math.min(point[1] + 1, height - 1);
|
|
26685
|
+
for (let y = sy; y <= ey; y++) {
|
|
26686
|
+
for (let x = sx; x <= ex; x++) {
|
|
26687
|
+
if (x !== point[0] || y !== point[1]) {
|
|
26688
|
+
list.push([x, y]);
|
|
26689
|
+
}
|
|
26690
|
+
}
|
|
26691
|
+
}
|
|
26692
|
+
return list;
|
|
26693
|
+
}
|
|
26694
|
+
static createInstanceFromRawPixelData(pixelData, width, height, voiRange) {
|
|
26695
|
+
const numPixels = pixelData.length;
|
|
26696
|
+
const grayscalePixelData = new Float32Array(numPixels);
|
|
26697
|
+
const { lower: minPixelValue, upper: maxPixelValue } = voiRange;
|
|
26698
|
+
const pixelRange = maxPixelValue - minPixelValue;
|
|
26699
|
+
for (let i = 0, len = pixelData.length; i < len; i++) {
|
|
26700
|
+
grayscalePixelData[i] = Math.max(0, Math.min(1, (pixelData[i] - minPixelValue) / pixelRange));
|
|
26701
|
+
}
|
|
26702
|
+
return new LivewireScissors(grayscalePixelData, width, height);
|
|
26703
|
+
}
|
|
26704
|
+
static createInstanceFromRGBAPixelData(rgbaPixelData, width, height) {
|
|
26705
|
+
const numPixels = rgbaPixelData.length / 4;
|
|
26706
|
+
const grayscalePixelData = new Float32Array(numPixels);
|
|
26707
|
+
const avgMultiplier = 1 / (3 * 255);
|
|
26708
|
+
for (let i = 0, offset = 0; i < numPixels; i++, offset += 4) {
|
|
26709
|
+
const red = rgbaPixelData[offset];
|
|
26710
|
+
const green = rgbaPixelData[offset];
|
|
26711
|
+
const blue = rgbaPixelData[offset];
|
|
26712
|
+
grayscalePixelData[i] = (red + green + blue) * avgMultiplier;
|
|
26713
|
+
}
|
|
26714
|
+
return new LivewireScissors(grayscalePixelData, width, height);
|
|
26715
|
+
}
|
|
26716
|
+
}
|
|
26717
|
+
|
|
26718
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/livewire/LiveWirePath.js
|
|
26719
|
+
class LivewirePath {
|
|
26720
|
+
constructor(inputPointArray, inputControlPointIndexArray) {
|
|
26721
|
+
this.pointArray = inputPointArray ? inputPointArray.slice() : [];
|
|
26722
|
+
this._controlPointIndexes = inputControlPointIndexArray
|
|
26723
|
+
? inputControlPointIndexArray.slice()
|
|
26724
|
+
: [];
|
|
26725
|
+
}
|
|
26726
|
+
getPoint(index) {
|
|
26727
|
+
return this.pointArray[index];
|
|
26728
|
+
}
|
|
26729
|
+
getLastPoint() {
|
|
26730
|
+
return this.pointArray[this.pointArray.length - 1];
|
|
26731
|
+
}
|
|
26732
|
+
isControlPoint(point) {
|
|
26733
|
+
const index = this.pointArray.indexOf(point);
|
|
26734
|
+
if (index !== -1) {
|
|
26735
|
+
return this._controlPointIndexes.indexOf(index) !== -1;
|
|
26736
|
+
}
|
|
26737
|
+
else {
|
|
26738
|
+
throw new Error('Error: isControlPoint called with not in list point.');
|
|
26739
|
+
}
|
|
26740
|
+
}
|
|
26741
|
+
addPoint(point) {
|
|
26742
|
+
this.pointArray.push(point);
|
|
26743
|
+
}
|
|
26744
|
+
addControlPoint(point) {
|
|
26745
|
+
const index = this.pointArray.indexOf(point);
|
|
26746
|
+
if (index !== -1) {
|
|
26747
|
+
this._controlPointIndexes.push(index);
|
|
26748
|
+
}
|
|
26749
|
+
else {
|
|
26750
|
+
throw new Error('Cannot mark a non registered point as control point.');
|
|
26751
|
+
}
|
|
26752
|
+
}
|
|
26753
|
+
getControlPoints() {
|
|
26754
|
+
return this._controlPointIndexes.map((i) => this.pointArray[i]);
|
|
26755
|
+
}
|
|
26756
|
+
getNumControlPoints() {
|
|
26757
|
+
return this._controlPointIndexes.length;
|
|
26758
|
+
}
|
|
26759
|
+
removeLastControlPoint() {
|
|
26760
|
+
if (this._controlPointIndexes.length) {
|
|
26761
|
+
this._controlPointIndexes.pop();
|
|
26762
|
+
}
|
|
26763
|
+
}
|
|
26764
|
+
addPoints(newPointArray) {
|
|
26765
|
+
this.pointArray = this.pointArray.concat(newPointArray);
|
|
26766
|
+
}
|
|
26767
|
+
prependPath(other) {
|
|
26768
|
+
const otherSize = other.pointArray.length;
|
|
26769
|
+
const shiftedIndexArray = [];
|
|
26770
|
+
this.pointArray = other.pointArray.concat(this.pointArray);
|
|
26771
|
+
for (let i = 0; i < this._controlPointIndexes.length; ++i) {
|
|
26772
|
+
shiftedIndexArray[i] = this._controlPointIndexes[i] + otherSize;
|
|
26773
|
+
}
|
|
26774
|
+
this._controlPointIndexes =
|
|
26775
|
+
other._controlPointIndexes.concat(shiftedIndexArray);
|
|
26776
|
+
}
|
|
26777
|
+
}
|
|
26778
|
+
|
|
26779
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/tools/annotation/LivewireContourTool.js
|
|
26780
|
+
|
|
26781
|
+
|
|
26782
|
+
|
|
26783
|
+
|
|
26784
|
+
|
|
26785
|
+
|
|
26786
|
+
|
|
26787
|
+
|
|
26788
|
+
|
|
26789
|
+
|
|
26790
|
+
|
|
26791
|
+
|
|
26792
|
+
|
|
26793
|
+
const CLICK_CLOSE_CURVE_SQR_DIST = 10 ** 2;
|
|
26794
|
+
class LivewireContourTool extends base_AnnotationTool {
|
|
26795
|
+
constructor(toolProps = {}, defaultToolProps = {
|
|
26796
|
+
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
26797
|
+
configuration: {
|
|
26798
|
+
preventHandleOutsideImage: false,
|
|
26799
|
+
},
|
|
26800
|
+
}) {
|
|
26801
|
+
super(toolProps, defaultToolProps);
|
|
26802
|
+
this.isHandleOutsideImage = false;
|
|
26803
|
+
this.addNewAnnotation = (evt) => {
|
|
26804
|
+
const eventDetail = evt.detail;
|
|
26805
|
+
const { currentPoints, element } = eventDetail;
|
|
26806
|
+
const { world: worldPos, canvas: canvasPos } = currentPoints;
|
|
26807
|
+
const enabledElement = (0,esm.getEnabledElement)(element);
|
|
26808
|
+
const { viewport, renderingEngine } = enabledElement;
|
|
26809
|
+
this.isDrawing = true;
|
|
26810
|
+
const camera = viewport.getCamera();
|
|
26811
|
+
const { viewPlaneNormal, viewUp } = camera;
|
|
26812
|
+
const referencedImageId = this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp);
|
|
26813
|
+
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
26814
|
+
const defaultActor = viewport.getDefaultActor();
|
|
26815
|
+
if (!defaultActor || !esm.utilities.isImageActor(defaultActor)) {
|
|
26816
|
+
throw new Error('Default actor must be an image actor');
|
|
26817
|
+
}
|
|
26818
|
+
const viewportImageData = viewport.getImageData();
|
|
26819
|
+
const { imageData: vtkImageData } = viewportImageData;
|
|
26820
|
+
let worldToSlice;
|
|
26821
|
+
let sliceToWorld;
|
|
26822
|
+
let scalarData;
|
|
26823
|
+
let width;
|
|
26824
|
+
let height;
|
|
26825
|
+
if (viewport instanceof esm.StackViewport) {
|
|
26826
|
+
scalarData = viewportImageData.scalarData;
|
|
26827
|
+
width = viewportImageData.dimensions[0];
|
|
26828
|
+
height = viewportImageData.dimensions[1];
|
|
26829
|
+
worldToSlice = (point) => {
|
|
26830
|
+
const ijkPoint = esm.utilities.transformWorldToIndex(vtkImageData, point);
|
|
26831
|
+
return [ijkPoint[0], ijkPoint[1]];
|
|
26832
|
+
};
|
|
26833
|
+
sliceToWorld = (point) => esm.utilities.transformIndexToWorld(vtkImageData, [point[0], point[1], 0]);
|
|
26834
|
+
}
|
|
26835
|
+
else if (viewport instanceof esm.VolumeViewport) {
|
|
26836
|
+
const sliceImageData = esm.utilities.getCurrentVolumeViewportSlice(viewport);
|
|
26837
|
+
const { sliceToIndexMatrix, indexToSliceMatrix } = sliceImageData;
|
|
26838
|
+
worldToSlice = (point) => {
|
|
26839
|
+
const ijkPoint = esm.utilities.transformWorldToIndex(vtkImageData, point);
|
|
26840
|
+
const slicePoint = gl_matrix_esm/* vec3.transformMat4 */.R3.transformMat4([0, 0, 0], ijkPoint, indexToSliceMatrix);
|
|
26841
|
+
return [slicePoint[0], slicePoint[1]];
|
|
26842
|
+
};
|
|
26843
|
+
sliceToWorld = (point) => {
|
|
26844
|
+
const ijkPoint = gl_matrix_esm/* vec3.transformMat4 */.R3.transformMat4([0, 0, 0], [point[0], point[1], 0], sliceToIndexMatrix);
|
|
26845
|
+
return esm.utilities.transformIndexToWorld(vtkImageData, ijkPoint);
|
|
26846
|
+
};
|
|
26847
|
+
scalarData = sliceImageData.scalarData;
|
|
26848
|
+
width = sliceImageData.width;
|
|
26849
|
+
height = sliceImageData.height;
|
|
26850
|
+
}
|
|
26851
|
+
else {
|
|
26852
|
+
throw new Error('Viewport not supported');
|
|
26853
|
+
}
|
|
26854
|
+
const { voiRange } = viewport.getProperties();
|
|
26855
|
+
const startPos = worldToSlice(worldPos);
|
|
26856
|
+
this.scissors = LivewireScissors.createInstanceFromRawPixelData(scalarData, width, height, voiRange);
|
|
26857
|
+
this.scissors.startSearch(startPos);
|
|
26858
|
+
const confirmedPath = new LivewirePath();
|
|
26859
|
+
const currentPath = new LivewirePath();
|
|
26860
|
+
confirmedPath.addPoint(startPos);
|
|
26861
|
+
confirmedPath.addControlPoint(startPos);
|
|
26862
|
+
const annotation = {
|
|
26863
|
+
highlighted: true,
|
|
26864
|
+
invalidated: true,
|
|
26865
|
+
metadata: {
|
|
26866
|
+
toolName: this.getToolName(),
|
|
26867
|
+
viewPlaneNormal: [...viewPlaneNormal],
|
|
26868
|
+
viewUp: [...viewUp],
|
|
26869
|
+
FrameOfReferenceUID,
|
|
26870
|
+
referencedImageId,
|
|
26871
|
+
},
|
|
26872
|
+
data: {
|
|
26873
|
+
polyline: [],
|
|
26874
|
+
handles: {
|
|
26875
|
+
points: [[...worldPos]],
|
|
26876
|
+
activeHandleIndex: null,
|
|
26877
|
+
},
|
|
26878
|
+
},
|
|
26879
|
+
};
|
|
26880
|
+
addAnnotation(annotation, element);
|
|
26881
|
+
const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
|
|
26882
|
+
this.editData = {
|
|
26883
|
+
annotation,
|
|
26884
|
+
viewportIdsToRender,
|
|
26885
|
+
newAnnotation: true,
|
|
26886
|
+
hasMoved: false,
|
|
26887
|
+
lastCanvasPoint: canvasPos,
|
|
26888
|
+
confirmedPath: confirmedPath,
|
|
26889
|
+
currentPath: currentPath,
|
|
26890
|
+
closed: false,
|
|
26891
|
+
worldToSlice,
|
|
26892
|
+
sliceToWorld,
|
|
26893
|
+
};
|
|
26894
|
+
this._activateDraw(element);
|
|
26895
|
+
evt.preventDefault();
|
|
26896
|
+
utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
26897
|
+
return annotation;
|
|
26898
|
+
};
|
|
26899
|
+
this.isPointNearTool = (element, annotation, canvasCoords, proximity) => {
|
|
26900
|
+
const enabledElement = (0,esm.getEnabledElement)(element);
|
|
26901
|
+
const { viewport } = enabledElement;
|
|
26902
|
+
const proximitySquared = proximity * proximity;
|
|
26903
|
+
const canvasPoints = annotation.data.polyline.map((p) => viewport.worldToCanvas(p));
|
|
26904
|
+
let startPoint = canvasPoints[canvasPoints.length - 1];
|
|
26905
|
+
for (let i = 0; i < canvasPoints.length; i++) {
|
|
26906
|
+
const endPoint = canvasPoints[i];
|
|
26907
|
+
const distanceToPointSquared = line_distanceToPointSquared_distanceToPointSquared(startPoint, endPoint, canvasCoords);
|
|
26908
|
+
if (distanceToPointSquared <= proximitySquared) {
|
|
26909
|
+
return true;
|
|
26910
|
+
}
|
|
26911
|
+
startPoint = endPoint;
|
|
26912
|
+
}
|
|
26913
|
+
return false;
|
|
26914
|
+
};
|
|
26915
|
+
this.toolSelectedCallback = (evt, annotation) => {
|
|
26916
|
+
const eventDetail = evt.detail;
|
|
26917
|
+
const { element } = eventDetail;
|
|
26918
|
+
annotation.highlighted = true;
|
|
26919
|
+
const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
|
|
26920
|
+
this.editData = {
|
|
26921
|
+
annotation,
|
|
26922
|
+
viewportIdsToRender,
|
|
26923
|
+
};
|
|
26924
|
+
const enabledElement = (0,esm.getEnabledElement)(element);
|
|
26925
|
+
const { renderingEngine } = enabledElement;
|
|
26926
|
+
this._activateModify(element);
|
|
26927
|
+
utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
26928
|
+
evt.preventDefault();
|
|
26929
|
+
};
|
|
26930
|
+
this.handleSelectedCallback = (evt, annotation, handle) => {
|
|
26931
|
+
const eventDetail = evt.detail;
|
|
26932
|
+
const { element } = eventDetail;
|
|
26933
|
+
const { data } = annotation;
|
|
26934
|
+
annotation.highlighted = true;
|
|
26935
|
+
const { points } = data.handles;
|
|
26936
|
+
const handleIndex = points.findIndex((p) => p === handle);
|
|
26937
|
+
const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
|
|
26938
|
+
this.editData = {
|
|
26939
|
+
annotation,
|
|
26940
|
+
viewportIdsToRender,
|
|
26941
|
+
handleIndex,
|
|
26942
|
+
};
|
|
26943
|
+
this._activateModify(element);
|
|
26944
|
+
const enabledElement = (0,esm.getEnabledElement)(element);
|
|
26945
|
+
const { renderingEngine } = enabledElement;
|
|
26946
|
+
utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
26947
|
+
evt.preventDefault();
|
|
26948
|
+
};
|
|
26949
|
+
this._endCallback = (evt) => {
|
|
26950
|
+
const eventDetail = evt.detail;
|
|
26951
|
+
const { element } = eventDetail;
|
|
26952
|
+
const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
|
|
26953
|
+
const { data } = annotation;
|
|
26954
|
+
data.handles.activeHandleIndex = null;
|
|
26955
|
+
this._deactivateModify(element);
|
|
26956
|
+
this._deactivateDraw(element);
|
|
26957
|
+
resetElementCursor(element);
|
|
26958
|
+
const enabledElement = (0,esm.getEnabledElement)(element);
|
|
26959
|
+
const { renderingEngine } = enabledElement;
|
|
26960
|
+
if (this.isHandleOutsideImage &&
|
|
26961
|
+
this.configuration.preventHandleOutsideImage) {
|
|
26962
|
+
annotationState_removeAnnotation(annotation.annotationUID);
|
|
26963
|
+
}
|
|
26964
|
+
utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
26965
|
+
if (newAnnotation) {
|
|
26966
|
+
const eventType = enums_Events.ANNOTATION_COMPLETED;
|
|
26967
|
+
const eventDetail = {
|
|
26968
|
+
annotation,
|
|
26969
|
+
};
|
|
26970
|
+
(0,esm.triggerEvent)(esm.eventTarget, eventType, eventDetail);
|
|
26971
|
+
}
|
|
26972
|
+
this.editData = null;
|
|
26973
|
+
this.scissors = null;
|
|
26974
|
+
this.isDrawing = false;
|
|
26975
|
+
};
|
|
26976
|
+
this._mouseDownCallback = (evt) => {
|
|
26977
|
+
const doubleClick = evt.type === enums_Events.MOUSE_DOUBLE_CLICK;
|
|
26978
|
+
const { annotation, viewportIdsToRender, worldToSlice, sliceToWorld } = this.editData;
|
|
26979
|
+
if (this.editData.closed) {
|
|
26980
|
+
return;
|
|
26981
|
+
}
|
|
26982
|
+
const eventDetail = evt.detail;
|
|
26983
|
+
const { element } = eventDetail;
|
|
26984
|
+
const { currentPoints } = eventDetail;
|
|
26985
|
+
const { canvas: canvasPos, world: worldPos } = currentPoints;
|
|
26986
|
+
const enabledElement = (0,esm.getEnabledElement)(element);
|
|
26987
|
+
const { viewport, renderingEngine } = enabledElement;
|
|
26988
|
+
const controlPoints = this.editData.currentPath.getControlPoints();
|
|
26989
|
+
let closePath = controlPoints.length >= 2 && doubleClick;
|
|
26990
|
+
if (controlPoints.length >= 2) {
|
|
26991
|
+
const closestHandlePoint = {
|
|
26992
|
+
index: -1,
|
|
26993
|
+
distSquared: Infinity,
|
|
26994
|
+
};
|
|
26995
|
+
for (let i = 0, len = controlPoints.length; i < len; i++) {
|
|
26996
|
+
const controlPoint = controlPoints[i];
|
|
26997
|
+
const worldControlPoint = sliceToWorld(controlPoint);
|
|
26998
|
+
const canvasControlPoint = viewport.worldToCanvas(worldControlPoint);
|
|
26999
|
+
const distSquared = distanceToPointSquared_distanceToPointSquared(canvasPos, canvasControlPoint);
|
|
27000
|
+
if (distSquared <= CLICK_CLOSE_CURVE_SQR_DIST &&
|
|
27001
|
+
distSquared < closestHandlePoint.distSquared) {
|
|
27002
|
+
closestHandlePoint.distSquared = distSquared;
|
|
27003
|
+
closestHandlePoint.index = i;
|
|
27004
|
+
}
|
|
27005
|
+
}
|
|
27006
|
+
if (closestHandlePoint.index === 0) {
|
|
27007
|
+
closePath = true;
|
|
27008
|
+
}
|
|
27009
|
+
}
|
|
27010
|
+
this.editData.closed = this.editData.closed || closePath;
|
|
27011
|
+
this.editData.confirmedPath = this.editData.currentPath;
|
|
27012
|
+
this.editData.confirmedPath.addControlPoint(this.editData.currentPath.getLastPoint());
|
|
27013
|
+
this.scissors.startSearch(worldToSlice(worldPos));
|
|
27014
|
+
annotation.invalidated = true;
|
|
27015
|
+
utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
27016
|
+
if (this.editData.closed) {
|
|
27017
|
+
this._updateAnnotation(element, this.editData.confirmedPath);
|
|
27018
|
+
this._endCallback(evt);
|
|
27019
|
+
}
|
|
27020
|
+
evt.preventDefault();
|
|
27021
|
+
};
|
|
27022
|
+
this._mouseMoveCallback = (evt) => {
|
|
27023
|
+
const { element, currentPoints } = evt.detail;
|
|
27024
|
+
const { world: worldPos, canvas: canvasPos } = currentPoints;
|
|
27025
|
+
const { renderingEngine } = (0,esm.getEnabledElement)(element);
|
|
27026
|
+
const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
|
|
27027
|
+
this.editData.lastCanvasPoint = canvasPos;
|
|
27028
|
+
const { width: imgWidth, height: imgHeight } = this.scissors;
|
|
27029
|
+
const { worldToSlice } = this.editData;
|
|
27030
|
+
const slicePoint = worldToSlice(worldPos);
|
|
27031
|
+
if (slicePoint[0] < 0 ||
|
|
27032
|
+
slicePoint[1] < 0 ||
|
|
27033
|
+
slicePoint[0] >= imgWidth ||
|
|
27034
|
+
slicePoint[1] >= imgHeight) {
|
|
27035
|
+
return;
|
|
27036
|
+
}
|
|
27037
|
+
const pathPoints = this.scissors.findPathToPoint(slicePoint);
|
|
27038
|
+
const currentPath = new LivewirePath();
|
|
27039
|
+
for (let i = 0, len = pathPoints.length; i < len; i++) {
|
|
27040
|
+
currentPath.addPoint(pathPoints[i]);
|
|
27041
|
+
}
|
|
27042
|
+
currentPath.prependPath(this.editData.confirmedPath);
|
|
27043
|
+
this.editData.currentPath = currentPath;
|
|
27044
|
+
utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
27045
|
+
evt.preventDefault();
|
|
27046
|
+
};
|
|
27047
|
+
this._dragCallback = (evt) => {
|
|
27048
|
+
this.isDrawing = true;
|
|
27049
|
+
const eventDetail = evt.detail;
|
|
27050
|
+
const { element } = eventDetail;
|
|
27051
|
+
const { annotation, viewportIdsToRender, handleIndex } = this.editData;
|
|
27052
|
+
const { data } = annotation;
|
|
27053
|
+
if (handleIndex === undefined) {
|
|
27054
|
+
const { deltaPoints } = eventDetail;
|
|
27055
|
+
const worldPosDelta = deltaPoints.world;
|
|
27056
|
+
const points = data.polyline;
|
|
27057
|
+
points.forEach((point) => {
|
|
27058
|
+
point[0] += worldPosDelta[0];
|
|
27059
|
+
point[1] += worldPosDelta[1];
|
|
27060
|
+
point[2] += worldPosDelta[2];
|
|
27061
|
+
});
|
|
27062
|
+
annotation.invalidated = true;
|
|
27063
|
+
}
|
|
27064
|
+
else {
|
|
27065
|
+
const { currentPoints } = eventDetail;
|
|
27066
|
+
const worldPos = currentPoints.world;
|
|
27067
|
+
data.handles.points[handleIndex] = [...worldPos];
|
|
27068
|
+
annotation.invalidated = true;
|
|
27069
|
+
}
|
|
27070
|
+
this.editData.hasMoved = true;
|
|
27071
|
+
const enabledElement = (0,esm.getEnabledElement)(element);
|
|
27072
|
+
const { renderingEngine } = enabledElement;
|
|
27073
|
+
utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
27074
|
+
};
|
|
27075
|
+
this.cancel = (element) => {
|
|
27076
|
+
if (!this.isDrawing) {
|
|
27077
|
+
return;
|
|
27078
|
+
}
|
|
27079
|
+
this.isDrawing = false;
|
|
27080
|
+
this._deactivateDraw(element);
|
|
27081
|
+
this._deactivateModify(element);
|
|
27082
|
+
resetElementCursor(element);
|
|
27083
|
+
const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
|
|
27084
|
+
if (newAnnotation) {
|
|
27085
|
+
annotationState_removeAnnotation(annotation.annotationUID);
|
|
27086
|
+
}
|
|
27087
|
+
const enabledElement = (0,esm.getEnabledElement)(element);
|
|
27088
|
+
const { renderingEngine } = enabledElement;
|
|
27089
|
+
utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
27090
|
+
this.editData = null;
|
|
27091
|
+
this.scissors = null;
|
|
27092
|
+
return annotation.annotationUID;
|
|
27093
|
+
};
|
|
27094
|
+
this.triggerAnnotationModified = (annotation, enabledElement) => {
|
|
27095
|
+
const { viewportId, renderingEngineId } = enabledElement;
|
|
27096
|
+
const eventType = enums_Events.ANNOTATION_MODIFIED;
|
|
27097
|
+
const eventDetail = {
|
|
27098
|
+
annotation,
|
|
27099
|
+
viewportId,
|
|
27100
|
+
renderingEngineId,
|
|
27101
|
+
};
|
|
27102
|
+
(0,esm.triggerEvent)(esm.eventTarget, eventType, eventDetail);
|
|
27103
|
+
};
|
|
27104
|
+
this._activateModify = (element) => {
|
|
27105
|
+
state.isInteractingWithTool = true;
|
|
27106
|
+
element.addEventListener(enums_Events.MOUSE_UP, this._endCallback);
|
|
27107
|
+
element.addEventListener(enums_Events.MOUSE_DRAG, this._dragCallback);
|
|
27108
|
+
element.addEventListener(enums_Events.MOUSE_CLICK, this._endCallback);
|
|
27109
|
+
element.addEventListener(enums_Events.TOUCH_END, this._endCallback);
|
|
27110
|
+
element.addEventListener(enums_Events.TOUCH_DRAG, this._dragCallback);
|
|
27111
|
+
element.addEventListener(enums_Events.TOUCH_TAP, this._endCallback);
|
|
27112
|
+
};
|
|
27113
|
+
this._deactivateModify = (element) => {
|
|
27114
|
+
state.isInteractingWithTool = false;
|
|
27115
|
+
element.removeEventListener(enums_Events.MOUSE_UP, this._endCallback);
|
|
27116
|
+
element.removeEventListener(enums_Events.MOUSE_DRAG, this._dragCallback);
|
|
27117
|
+
element.removeEventListener(enums_Events.MOUSE_CLICK, this._endCallback);
|
|
27118
|
+
element.removeEventListener(enums_Events.TOUCH_END, this._endCallback);
|
|
27119
|
+
element.removeEventListener(enums_Events.TOUCH_DRAG, this._dragCallback);
|
|
27120
|
+
element.removeEventListener(enums_Events.TOUCH_TAP, this._endCallback);
|
|
27121
|
+
};
|
|
27122
|
+
this._activateDraw = (element) => {
|
|
27123
|
+
state.isInteractingWithTool = true;
|
|
27124
|
+
element.addEventListener(enums_Events.MOUSE_MOVE, this._mouseMoveCallback);
|
|
27125
|
+
element.addEventListener(enums_Events.MOUSE_DOWN, this._mouseDownCallback);
|
|
27126
|
+
element.addEventListener(enums_Events.MOUSE_DOUBLE_CLICK, this._mouseDownCallback);
|
|
27127
|
+
element.addEventListener(enums_Events.TOUCH_TAP, this._mouseDownCallback);
|
|
27128
|
+
};
|
|
27129
|
+
this._deactivateDraw = (element) => {
|
|
27130
|
+
state.isInteractingWithTool = false;
|
|
27131
|
+
element.removeEventListener(enums_Events.MOUSE_MOVE, this._mouseMoveCallback);
|
|
27132
|
+
element.removeEventListener(enums_Events.MOUSE_DOWN, this._mouseDownCallback);
|
|
27133
|
+
element.removeEventListener(enums_Events.MOUSE_DOUBLE_CLICK, this._mouseDownCallback);
|
|
27134
|
+
element.removeEventListener(enums_Events.TOUCH_TAP, this._mouseDownCallback);
|
|
27135
|
+
};
|
|
27136
|
+
this.renderAnnotation = (enabledElement, svgDrawingHelper) => {
|
|
27137
|
+
let renderStatus = false;
|
|
27138
|
+
const { viewport } = enabledElement;
|
|
27139
|
+
const { worldToCanvas } = viewport;
|
|
27140
|
+
const { element } = viewport;
|
|
27141
|
+
if (!viewport.getRenderingEngine()) {
|
|
27142
|
+
console.warn('Rendering Engine has been destroyed');
|
|
27143
|
+
return renderStatus;
|
|
27144
|
+
}
|
|
27145
|
+
let annotations = getAnnotations(this.getToolName(), element);
|
|
27146
|
+
if (!annotations?.length) {
|
|
27147
|
+
return renderStatus;
|
|
27148
|
+
}
|
|
27149
|
+
annotations = this.filterInteractableAnnotationsForElement(element, annotations);
|
|
27150
|
+
if (!annotations?.length) {
|
|
27151
|
+
return renderStatus;
|
|
27152
|
+
}
|
|
27153
|
+
const newAnnotation = this.editData?.newAnnotation;
|
|
27154
|
+
const styleSpecifier = {
|
|
27155
|
+
toolGroupId: this.toolGroupId,
|
|
27156
|
+
toolName: this.getToolName(),
|
|
27157
|
+
viewportId: enabledElement.viewport.id,
|
|
27158
|
+
};
|
|
27159
|
+
this._updateAnnotation(element, this.editData?.currentPath);
|
|
27160
|
+
for (let i = 0; i < annotations.length; i++) {
|
|
27161
|
+
const annotation = annotations[i];
|
|
27162
|
+
const { annotationUID, data } = annotation;
|
|
27163
|
+
const { handles } = data;
|
|
27164
|
+
const { points } = handles;
|
|
27165
|
+
styleSpecifier.annotationUID = annotationUID;
|
|
27166
|
+
const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
|
|
27167
|
+
const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
|
|
27168
|
+
const color = this.getStyle('color', styleSpecifier, annotation);
|
|
27169
|
+
const canvasCoordinates = points.map((p) => worldToCanvas(p));
|
|
27170
|
+
if (!isAnnotationVisible(annotationUID)) {
|
|
27171
|
+
continue;
|
|
27172
|
+
}
|
|
27173
|
+
if (newAnnotation &&
|
|
27174
|
+
annotation.annotationUID === this.editData?.annotation?.annotationUID) {
|
|
27175
|
+
const handleGroupUID = '0';
|
|
27176
|
+
drawingSvg_drawHandles(svgDrawingHelper, annotationUID, handleGroupUID, [canvasCoordinates[0]], {
|
|
27177
|
+
color,
|
|
27178
|
+
lineDash,
|
|
27179
|
+
lineWidth,
|
|
27180
|
+
});
|
|
27181
|
+
}
|
|
27182
|
+
const canvasPolyline = data.polyline.map((worldPoint) => viewport.worldToCanvas(worldPoint));
|
|
27183
|
+
drawPolyline(svgDrawingHelper, annotationUID, 'polyline', canvasPolyline, {
|
|
27184
|
+
color,
|
|
27185
|
+
lineDash,
|
|
27186
|
+
lineWidth,
|
|
27187
|
+
});
|
|
27188
|
+
renderStatus = true;
|
|
27189
|
+
annotation.invalidated = false;
|
|
27190
|
+
}
|
|
27191
|
+
return renderStatus;
|
|
27192
|
+
};
|
|
27193
|
+
}
|
|
27194
|
+
_updateAnnotation(element, livewirePath) {
|
|
27195
|
+
if (!this.editData || !livewirePath) {
|
|
27196
|
+
return;
|
|
27197
|
+
}
|
|
27198
|
+
const { pointArray: imagePoints } = livewirePath;
|
|
27199
|
+
const worldPolylinePoints = [];
|
|
27200
|
+
const { sliceToWorld } = this.editData;
|
|
27201
|
+
for (let i = 0, len = imagePoints.length; i < len; i++) {
|
|
27202
|
+
const imagePoint = imagePoints[i];
|
|
27203
|
+
const worldPoint = sliceToWorld(imagePoint);
|
|
27204
|
+
worldPolylinePoints.push(worldPoint);
|
|
27205
|
+
}
|
|
27206
|
+
if (worldPolylinePoints.length > 1) {
|
|
27207
|
+
worldPolylinePoints.push([...worldPolylinePoints[0]]);
|
|
27208
|
+
}
|
|
27209
|
+
this.editData.annotation.data.polyline = worldPolylinePoints;
|
|
27210
|
+
}
|
|
27211
|
+
}
|
|
27212
|
+
LivewireContourTool.toolName = 'LivewireContour';
|
|
27213
|
+
/* harmony default export */ const annotation_LivewireContourTool = (LivewireContourTool);
|
|
27214
|
+
|
|
26360
27215
|
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/tools/annotation/ArrowAnnotateTool.js
|
|
26361
27216
|
|
|
26362
27217
|
|
|
@@ -34804,6 +35659,7 @@ OrientationMarkerTool.toolName = 'OrientationMarker';
|
|
|
34804
35659
|
|
|
34805
35660
|
|
|
34806
35661
|
|
|
35662
|
+
|
|
34807
35663
|
|
|
34808
35664
|
|
|
34809
35665
|
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.js
|