Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 🔔🔔🔔🔔 Attention: Cornerstone.js has evolved! We're excited to introduce [Cornerstone3D](https://github.com/cornerstonejs/cornerstone3D) 🚀. Expect advanced rendering, stellar performance, and a modern toolset. 🌐 Navigate to the new repository for the latest updates and improvements.


<div align="center">
<h1>cornerstone-tools</h1>

Expand Down
32,653 changes: 31,541 additions & 1,112 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"all-contributors-cli": "5.11.0",
"babel-jest": "^25.1.0",
"babel-loader": "^8.0.4",
"canvas": "2.6.1",
"canvas": "^2.9.1",
"commitizen": "^4.0.3",
"coveralls": "3.0.2",
"cz-conventional-changelog": "2.1.0",
Expand Down Expand Up @@ -93,7 +93,7 @@
},
"dependencies": {
"@babel/runtime": "7.1.2",
"cornerstone-math": "0.1.9"
"cornerstone-math": "0.1.10"
},
"files": [
"dist/cornerstoneTools.js",
Expand Down
15 changes: 14 additions & 1 deletion src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default function(evt, tool) {
? moveHandle
: moveNewHandle;

const timestamp = new Date().getTime();

handleMover(
eventData,
tool.name,
Expand All @@ -44,7 +46,18 @@ export default function(evt, tool) {
return;
}

if (success) {
const hasThreshold =
tool.configuration &&
Object(tool.configuration).hasOwnProperty(
'measurementCreationThreshold'
);

const isTooFast = hasThreshold
? new Date().getTime() - timestamp <
tool.configuration.measurementCreationThreshold
: false;

if (success && isTooFast === false) {
const eventType = EVENTS.MEASUREMENT_COMPLETED;
const eventData = {
toolName: tool.name,
Expand Down
33 changes: 14 additions & 19 deletions src/eventListeners/internals/renderSegmentationFill.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { getModule } from '../../store/index.js';
import {
getNewContext,
resetCanvasContextTransform,
transformCanvasContext,
} from '../../drawing/index.js';
import { getNewContext, transformCanvasContext } from '../../drawing/index.js';
import external from '../../externalModules';

const segmentationModule = getModule('segmentation');
Expand Down Expand Up @@ -80,25 +76,25 @@ export function getLabelmapCanvas(evt, labelmap3D, labelmap2D) {
export function renderFill(evt, labelmapCanvas, isActiveLabelMap) {
const { configuration } = segmentationModule;
const eventData = evt.detail;
const context = getNewContext(eventData.canvasContext.canvas);
const { canvasContext, element, image, viewport } = eventData;

const canvasTopLeft = external.cornerstone.pixelToCanvas(eventData.element, {
const previousTransform = canvasContext.getTransform();
const context = getNewContext(canvasContext.canvas);

const canvasTopLeft = external.cornerstone.pixelToCanvas(element, {
x: 0,
y: 0,
});

const canvasTopRight = external.cornerstone.pixelToCanvas(eventData.element, {
x: eventData.image.width,
const canvasTopRight = external.cornerstone.pixelToCanvas(element, {
x: image.width,
y: 0,
});

const canvasBottomRight = external.cornerstone.pixelToCanvas(
eventData.element,
{
x: eventData.image.width,
y: eventData.image.height,
}
);
const canvasBottomRight = external.cornerstone.pixelToCanvas(element, {
x: image.width,
y: image.height,
});

const cornerstoneCanvasWidth = external.cornerstoneMath.point.distance(
canvasTopLeft,
Expand All @@ -109,8 +105,7 @@ export function renderFill(evt, labelmapCanvas, isActiveLabelMap) {
canvasBottomRight
);

const canvas = eventData.canvasContext.canvas;
const viewport = eventData.viewport;
const canvas = canvasContext.canvas;

const previousImageSmoothingEnabled = context.imageSmoothingEnabled;
const previousGlobalAlpha = context.globalAlpha;
Expand All @@ -137,7 +132,7 @@ export function renderFill(evt, labelmapCanvas, isActiveLabelMap) {
context.globalAlpha = previousGlobalAlpha;
context.imageSmoothingEnabled = previousImageSmoothingEnabled;

resetCanvasContextTransform(context);
context.setTransform(previousTransform);
}

/**
Expand Down
Loading