From e30b77aa657b9a79c8db45132cd7c61270081df8 Mon Sep 17 00:00:00 2001 From: Gustavo Lelis Date: Thu, 7 Mar 2019 16:17:22 -0300 Subject: [PATCH 1/8] feat(BidirectionalTool): Update tool data on every modified event of Bidirectional so we can display --- .../bidirectionalTool/addNewMeasurement.js | 32 +++++++++++--- .../moveHandle/moveHandle.js | 28 ++++++++++++ .../moveHandle/touchMoveHandle.js | 31 ++++++++++--- .../bidirectionalTool/renderToolData.js | 35 +-------------- .../calculateLongestAndShortestDiameters.js | 44 +++++++++++++++++++ 5 files changed, 124 insertions(+), 46 deletions(-) create mode 100644 src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js diff --git a/src/tools/annotation/bidirectionalTool/addNewMeasurement.js b/src/tools/annotation/bidirectionalTool/addNewMeasurement.js index 215bf13e1..53c1a488c 100644 --- a/src/tools/annotation/bidirectionalTool/addNewMeasurement.js +++ b/src/tools/annotation/bidirectionalTool/addNewMeasurement.js @@ -2,6 +2,7 @@ import external from './../../../externalModules.js'; import EVENTS from './../../../events.js'; import { moveNewHandle } from './../../../manipulators/index.js'; import anyHandlesOutsideImage from './../../../manipulators/anyHandlesOutsideImage.js'; +import calculateLongestAndShortestDiameters from './utils/calculateLongestAndShortestDiameters.js'; import { addToolState, removeToolState, @@ -22,15 +23,32 @@ export default function(evt, interactionType) { measurementData.active = false; external.cornerstone.updateImage(element); - // Trigger measurement modified event - const eventType = EVENTS.MEASUREMENT_MODIFIED; - const modifiedEventData = { - toolName: this.name, - element, - measurementData, + const measurementModifiedHandler = () => { + const modifiedEventData = { + toolName: this.name, + element, + measurementData, + }; + + calculateLongestAndShortestDiameters(eventData, measurementData); + + external.cornerstone.triggerEvent( + element, + EVENTS.MEASUREMENT_MODIFIED, + modifiedEventData + ); + + element.removeEventListener( + external.cornerstone.EVENTS.IMAGE_RENDERED, + measurementModifiedHandler + ); }; - external.cornerstone.triggerEvent(element, eventType, modifiedEventData); + // Wait on image render before triggering the modified event + element.addEventListener( + external.cornerstone.EVENTS.IMAGE_RENDERED, + measurementModifiedHandler + ); }; // Associate this data with this imageId so we can render it and manipulate it diff --git a/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js b/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js index d3fb41c3a..1e83fac22 100644 --- a/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js +++ b/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js @@ -2,6 +2,7 @@ import external from './../../../../externalModules.js'; import { state } from '../../../../store/index.js'; import EVENTS from './../../../../events.js'; import setHandlesPosition from './setHandlesPosition.js'; +import calculateLongestAndShortestDiameters from '../utils/calculateLongestAndShortestDiameters.js'; export default function( mouseEventData, @@ -50,6 +51,33 @@ export default function( EVENTS.MEASUREMENT_MODIFIED, modifiedEventData ); + + const measurementModifiedHandler = () => { + const modifiedEventData = { + toolType, + element, + measurementData: data, + }; + + calculateLongestAndShortestDiameters(mouseEventData, data); + + external.cornerstone.triggerEvent( + element, + EVENTS.MEASUREMENT_MODIFIED, + modifiedEventData + ); + + element.removeEventListener( + external.cornerstone.EVENTS.IMAGE_RENDERED, + measurementModifiedHandler + ); + }; + + // Wait on image render before triggering the modified event + element.addEventListener( + external.cornerstone.EVENTS.IMAGE_RENDERED, + measurementModifiedHandler + ); }; handle.active = true; diff --git a/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js b/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js index 901378683..575184874 100644 --- a/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js +++ b/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js @@ -2,6 +2,7 @@ import external from './../../../../externalModules.js'; import { state } from '../../../../store/index.js'; import EVENTS from './../../../../events.js'; import setHandlesPosition from './setHandlesPosition.js'; +import calculateLongestAndShortestDiameters from '../utils/calculateLongestAndShortestDiameters.js'; const touchEndEvents = [ EVENTS.TOUCH_END, @@ -47,14 +48,32 @@ export default function( external.cornerstone.updateImage(element); - const eventType = EVENTS.MEASUREMENT_MODIFIED; - const modifiedEventData = { - toolType, - element, - measurementData: data, + const measurementModifiedHandler = () => { + const modifiedEventData = { + toolType, + element, + measurementData: data, + }; + + calculateLongestAndShortestDiameters(mouseEventData, data); + + external.cornerstone.triggerEvent( + element, + EVENTS.MEASUREMENT_MODIFIED, + modifiedEventData + ); + + element.removeEventListener( + external.cornerstone.EVENTS.IMAGE_RENDERED, + measurementModifiedHandler + ); }; - external.cornerstone.triggerEvent(element, eventType, modifiedEventData); + // Wait on image render before triggering the modified event + element.addEventListener( + external.cornerstone.EVENTS.IMAGE_RENDERED, + measurementModifiedHandler + ); }; handle.active = true; diff --git a/src/tools/annotation/bidirectionalTool/renderToolData.js b/src/tools/annotation/bidirectionalTool/renderToolData.js index 40e3322b2..0e82c2129 100644 --- a/src/tools/annotation/bidirectionalTool/renderToolData.js +++ b/src/tools/annotation/bidirectionalTool/renderToolData.js @@ -2,6 +2,7 @@ import external from './../../../externalModules.js'; import drawHandles from './../../../drawing/drawHandles.js'; import updatePerpendicularLineHandles from './utils/updatePerpendicularLineHandles.js'; +import calculateLongestAndShortestDiameters from './utils/calculateLongestAndShortestDiameters.js'; import toolStyle from './../../../stateManagement/toolStyle.js'; import toolColors from './../../../stateManagement/toolColors.js'; @@ -63,7 +64,7 @@ export default function(evt) { color = data.active ? activeColor : toolColors.getToolColor(); // Calculate the data measurements - getMeasurementData(data, rowPixelSpacing, colPixelSpacing); + calculateLongestAndShortestDiameters(eventData, data); draw(context, context => { // Configurable shadow @@ -127,38 +128,6 @@ export default function(evt) { } } -const getMeasurementData = (data, rowPixelSpacing, colPixelSpacing) => { - const { start, end, perpendicularStart, perpendicularEnd } = data.handles; - // Calculate the long axis length - const dx = (start.x - end.x) * (colPixelSpacing || 1); - const dy = (start.y - end.y) * (rowPixelSpacing || 1); - let length = Math.sqrt(dx * dx + dy * dy); - - // Calculate the short axis length - const wx = - (perpendicularStart.x - perpendicularEnd.x) * (colPixelSpacing || 1); - const wy = - (perpendicularStart.y - perpendicularEnd.y) * (rowPixelSpacing || 1); - let width = Math.sqrt(wx * wx + wy * wy); - - if (!width) { - width = 0; - } - - // Length is always longer than width - if (width > length) { - const tempW = width; - const tempL = length; - - length = tempW; - width = tempL; - } - - // Set measurement values to be use externaly - data.longestDiameter = length.toFixed(1); - data.shortestDiameter = width.toFixed(1); -}; - const getTextBoxText = (data, rowPixelSpacing, colPixelSpacing) => { let suffix = ' mm'; diff --git a/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js new file mode 100644 index 000000000..0937dba26 --- /dev/null +++ b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js @@ -0,0 +1,44 @@ +// Calculate the longest and shortest diameters for the given measurementData +export default function calculateLongestAndShortestDiameters( + eventData, + measurementData +) { + const { rowPixelSpacing, columnPixelSpacing } = eventData.image; + const { + start, + end, + perpendicularStart, + perpendicularEnd, + } = measurementData.handles; + + // UpdatePerpendicularLineHandles(eventData, measurementData); + + // Calculate the long axis length + const dx = (start.x - end.x) * (columnPixelSpacing || 1); + const dy = (start.y - end.y) * (rowPixelSpacing || 1); + let length = Math.sqrt(dx * dx + dy * dy); + + // Calculate the short axis length + const wx = + (perpendicularStart.x - perpendicularEnd.x) * (columnPixelSpacing || 1); + const wy = + (perpendicularStart.y - perpendicularEnd.y) * (rowPixelSpacing || 1); + let width = Math.sqrt(wx * wx + wy * wy); + + if (!width) { + width = 0; + } + + // Length is always longer than width + if (width > length) { + const tempW = width; + const tempL = length; + + length = tempW; + width = tempL; + } + + // Set measurement text to show lesion table + measurementData.longestDiameter = length.toFixed(1); + measurementData.shortestDiameter = width.toFixed(1); +} From 18acbd80b7d9d306671289287b8841304f9a0b61 Mon Sep 17 00:00:00 2001 From: Gustavo Lelis Date: Fri, 8 Mar 2019 01:35:19 -0300 Subject: [PATCH 2/8] test(bidirectional): Adding unit tests to bidirectional data calculation function --- .../calculateLongestAndShortestDiameters.js | 2 - ...lculateLongestAndShortestDiameters.test.js | 119 ++++++++++++++++++ 2 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.test.js diff --git a/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js index 0937dba26..3511c4004 100644 --- a/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js +++ b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js @@ -11,8 +11,6 @@ export default function calculateLongestAndShortestDiameters( perpendicularEnd, } = measurementData.handles; - // UpdatePerpendicularLineHandles(eventData, measurementData); - // Calculate the long axis length const dx = (start.x - end.x) * (columnPixelSpacing || 1); const dy = (start.y - end.y) * (rowPixelSpacing || 1); diff --git a/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.test.js b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.test.js new file mode 100644 index 000000000..38e14b5ff --- /dev/null +++ b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.test.js @@ -0,0 +1,119 @@ +import calculateLongestAndShortestDiameters from './calculateLongestAndShortestDiameters.js'; +import lodash from 'lodash'; + +const measurementData = { + handles: { + start: { + x: 290.6229508196721, + y: 272.7868852459016, + }, + end: { + x: 361.96721311475403, + y: 191.99999999999997, + }, + perpendicularStart: { + x: 346.49180327868845, + y: 250.22950819672127, + }, + perpendicularEnd: { + x: 306.0983606557376, + y: 214.55737704918027, + }, + }, +}; + +describe('CalculateLongestAndShortestDiameters.js', () => { + beforeEach(() => { + console.error = jest.fn(); + console.error.mockClear(); + console.warn = jest.fn(); + console.warn.mockClear(); + }); + + describe('calculate diameters', () => { + it('once we pass all data needed', () => { + const newMeasurementData = lodash.cloneDeep(measurementData); + const eventData = { + image: { + rowPixelSpacing: 0.876953125, + columnPixelSpacing: 0.876953125, + }, + }; + + calculateLongestAndShortestDiameters(eventData, newMeasurementData); + + expect(newMeasurementData.longestDiameter).toEqual('94.5'); + expect(newMeasurementData.shortestDiameter).toEqual('47.3'); + }); + + it('once pixelSpacing is undefined', () => { + const newMeasurementData = lodash.cloneDeep(measurementData); + const eventData = { + image: {}, + }; + + calculateLongestAndShortestDiameters(eventData, newMeasurementData); + + expect(newMeasurementData.longestDiameter).toEqual('107.8'); + expect(newMeasurementData.shortestDiameter).toEqual('53.9'); + }); + + it('once shortestDiameter gets zero because perpendicular axis are undefined', () => { + const newMeasurementData = lodash.cloneDeep(measurementData); + + newMeasurementData.handles = { + start: { + x: 0, + y: 0, + }, + end: { + x: 4, + y: 4, + }, + perpendicularStart: {}, + perpendicularEnd: {}, + }; + + const eventData = { + image: {}, + }; + + calculateLongestAndShortestDiameters(eventData, newMeasurementData); + + expect(newMeasurementData.shortestDiameter).toEqual('0.0'); + expect(newMeasurementData.longestDiameter).toEqual('5.7'); + }); + + it('once shortestDiameter gets swaped with longestDiamater', () => { + const newMeasurementData = lodash.cloneDeep(measurementData); + + newMeasurementData.handles = { + start: { + x: 10, + y: 10, + }, + end: { + x: 5, + y: 5, + }, + perpendicularStart: { + x: 12, + y: 12, + }, + perpendicularEnd: { + x: 5, + y: 5, + }, + }; + + const eventData = { + image: {}, + }; + + calculateLongestAndShortestDiameters(eventData, newMeasurementData); + + expect(newMeasurementData.shortestDiameter).toEqual('7.1'); + expect(newMeasurementData.longestDiameter).toEqual('9.9'); + }); + }); +}); From 87ca6a06464174d08654bdadca9fbc0d96a5c5f0 Mon Sep 17 00:00:00 2001 From: Gustavo Lelis Date: Mon, 11 Mar 2019 15:07:54 -0300 Subject: [PATCH 3/8] fix(bidirectional): Fix unit tests after callouts --- ...lculateLongestAndShortestDiameters.test.js | 184 +++++++++--------- 1 file changed, 88 insertions(+), 96 deletions(-) diff --git a/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.test.js b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.test.js index 38e14b5ff..874a10c59 100644 --- a/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.test.js +++ b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.test.js @@ -1,26 +1,7 @@ import calculateLongestAndShortestDiameters from './calculateLongestAndShortestDiameters.js'; -import lodash from 'lodash'; - -const measurementData = { - handles: { - start: { - x: 290.6229508196721, - y: 272.7868852459016, - }, - end: { - x: 361.96721311475403, - y: 191.99999999999997, - }, - perpendicularStart: { - x: 346.49180327868845, - y: 250.22950819672127, - }, - perpendicularEnd: { - x: 306.0983606557376, - y: 214.55737704918027, - }, - }, -}; + +let measurementData = {}; +let eventData = {}; describe('CalculateLongestAndShortestDiameters.js', () => { beforeEach(() => { @@ -28,92 +9,103 @@ describe('CalculateLongestAndShortestDiameters.js', () => { console.error.mockClear(); console.warn = jest.fn(); console.warn.mockClear(); - }); - - describe('calculate diameters', () => { - it('once we pass all data needed', () => { - const newMeasurementData = lodash.cloneDeep(measurementData); - const eventData = { - image: { - rowPixelSpacing: 0.876953125, - columnPixelSpacing: 0.876953125, - }, - }; - - calculateLongestAndShortestDiameters(eventData, newMeasurementData); - - expect(newMeasurementData.longestDiameter).toEqual('94.5'); - expect(newMeasurementData.shortestDiameter).toEqual('47.3'); - }); - - it('once pixelSpacing is undefined', () => { - const newMeasurementData = lodash.cloneDeep(measurementData); - const eventData = { - image: {}, - }; - calculateLongestAndShortestDiameters(eventData, newMeasurementData); - - expect(newMeasurementData.longestDiameter).toEqual('107.8'); - expect(newMeasurementData.shortestDiameter).toEqual('53.9'); - }); - - it('once shortestDiameter gets zero because perpendicular axis are undefined', () => { - const newMeasurementData = lodash.cloneDeep(measurementData); - - newMeasurementData.handles = { + measurementData = { + handles: { start: { - x: 0, - y: 0, + x: 290.6229508196721, + y: 272.7868852459016, }, end: { - x: 4, - y: 4, + x: 361.96721311475403, + y: 191.99999999999997, + }, + perpendicularStart: { + x: 346.49180327868845, + y: 250.22950819672127, + }, + perpendicularEnd: { + x: 306.0983606557376, + y: 214.55737704918027, }, - perpendicularStart: {}, - perpendicularEnd: {}, - }; + }, + }; + eventData = { + image: {}, + }; + }); - const eventData = { - image: {}, - }; + it('should calculates long/short diameters', () => { + eventData = { + image: { + rowPixelSpacing: 0.876953125, + columnPixelSpacing: 0.876953125, + }, + }; - calculateLongestAndShortestDiameters(eventData, newMeasurementData); + calculateLongestAndShortestDiameters(eventData, measurementData); - expect(newMeasurementData.shortestDiameter).toEqual('0.0'); - expect(newMeasurementData.longestDiameter).toEqual('5.7'); - }); + expect(measurementData.longestDiameter).toEqual('94.5'); + expect(measurementData.shortestDiameter).toEqual('47.3'); + }); - it('once shortestDiameter gets swaped with longestDiamater', () => { - const newMeasurementData = lodash.cloneDeep(measurementData); + it('should return values with scale of 1', () => { + calculateLongestAndShortestDiameters(eventData, measurementData); - newMeasurementData.handles = { - start: { - x: 10, - y: 10, - }, - end: { - x: 5, - y: 5, - }, - perpendicularStart: { - x: 12, - y: 12, - }, - perpendicularEnd: { - x: 5, - y: 5, - }, - }; + expect(measurementData.shortestDiameter).toMatch(/\d*\.\d$/); + expect(measurementData.longestDiameter).toMatch(/\d*\.\d$/); + }); - const eventData = { - image: {}, - }; + it('should use a default pixelSpacing of 1 when pixelSpacing is undefined', () => { + calculateLongestAndShortestDiameters(eventData, measurementData); - calculateLongestAndShortestDiameters(eventData, newMeasurementData); + expect(measurementData.longestDiameter).toEqual('107.8'); + expect(measurementData.shortestDiameter).toEqual('53.9'); + }); + + it('should get longest and shortest diameters defined even with undefined handles', () => { + measurementData.handles = { + start: { + x: 0, + y: 0, + }, + end: { + x: 4, + y: 4, + }, + perpendicularStart: {}, + perpendicularEnd: {}, + }; + + calculateLongestAndShortestDiameters(eventData, measurementData); + + expect(measurementData.shortestDiameter).toEqual('0.0'); + expect(measurementData.longestDiameter).toEqual('5.7'); + }); - expect(newMeasurementData.shortestDiameter).toEqual('7.1'); - expect(newMeasurementData.longestDiameter).toEqual('9.9'); - }); + it('should make shortestDiameter always small than longestDiameter', () => { + measurementData.handles = { + start: { + x: 10, + y: 10, + }, + end: { + x: 5, + y: 5, + }, + perpendicularStart: { + x: 12, + y: 12, + }, + perpendicularEnd: { + x: 5, + y: 5, + }, + }; + + calculateLongestAndShortestDiameters(eventData, measurementData); + + expect(measurementData.shortestDiameter).toEqual('7.1'); + expect(measurementData.longestDiameter).toEqual('9.9'); }); }); From 2bc8692b400784087ba737998b267192dad0f20f Mon Sep 17 00:00:00 2001 From: Gustavo Lelis Date: Tue, 12 Mar 2019 03:05:11 -0300 Subject: [PATCH 4/8] fix(bidirectional): Refactor to remove some eventListeners and to fix the data once we addNewMeasurement --- .../bidirectionalTool/addNewMeasurement.js | 41 +++++++------------ .../moveHandle/moveHandle.js | 29 +------------ .../moveHandle/touchMoveHandle.js | 33 +++++---------- 3 files changed, 26 insertions(+), 77 deletions(-) diff --git a/src/tools/annotation/bidirectionalTool/addNewMeasurement.js b/src/tools/annotation/bidirectionalTool/addNewMeasurement.js index 53c1a488c..b233b3cd3 100644 --- a/src/tools/annotation/bidirectionalTool/addNewMeasurement.js +++ b/src/tools/annotation/bidirectionalTool/addNewMeasurement.js @@ -22,33 +22,6 @@ export default function(evt, interactionType) { const doneCallback = () => { measurementData.active = false; external.cornerstone.updateImage(element); - - const measurementModifiedHandler = () => { - const modifiedEventData = { - toolName: this.name, - element, - measurementData, - }; - - calculateLongestAndShortestDiameters(eventData, measurementData); - - external.cornerstone.triggerEvent( - element, - EVENTS.MEASUREMENT_MODIFIED, - modifiedEventData - ); - - element.removeEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); - }; - - // Wait on image render before triggering the modified event - element.addEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); }; // Associate this data with this imageId so we can render it and manipulate it @@ -89,6 +62,20 @@ export default function(evt, interactionType) { perpendicularStart.locked = false; external.cornerstone.updateImage(element); + + const modifiedEventData = { + toolType: this.name, + element, + measurementData, + }; + + calculateLongestAndShortestDiameters(eventData, measurementData); + + external.cornerstone.triggerEvent( + element, + EVENTS.MEASUREMENT_MODIFIED, + modifiedEventData + ); }, }, interactionType diff --git a/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js b/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js index 1e83fac22..2bed80861 100644 --- a/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js +++ b/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js @@ -46,38 +46,13 @@ export default function( measurementData: data, }; + calculateLongestAndShortestDiameters(mouseEventData, data); + external.cornerstone.triggerEvent( element, EVENTS.MEASUREMENT_MODIFIED, modifiedEventData ); - - const measurementModifiedHandler = () => { - const modifiedEventData = { - toolType, - element, - measurementData: data, - }; - - calculateLongestAndShortestDiameters(mouseEventData, data); - - external.cornerstone.triggerEvent( - element, - EVENTS.MEASUREMENT_MODIFIED, - modifiedEventData - ); - - element.removeEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); - }; - - // Wait on image render before triggering the modified event - element.addEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); }; handle.active = true; diff --git a/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js b/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js index 575184874..3738a5922 100644 --- a/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js +++ b/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js @@ -48,31 +48,18 @@ export default function( external.cornerstone.updateImage(element); - const measurementModifiedHandler = () => { - const modifiedEventData = { - toolType, - element, - measurementData: data, - }; - - calculateLongestAndShortestDiameters(mouseEventData, data); - - external.cornerstone.triggerEvent( - element, - EVENTS.MEASUREMENT_MODIFIED, - modifiedEventData - ); - - element.removeEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); + const modifiedEventData = { + toolType, + element, + measurementData: data, }; - // Wait on image render before triggering the modified event - element.addEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler + calculateLongestAndShortestDiameters(mouseEventData, data); + + external.cornerstone.triggerEvent( + element, + EVENTS.MEASUREMENT_MODIFIED, + modifiedEventData ); }; From e90a7ad405960525dc46de3e4a2048655091a2d8 Mon Sep 17 00:00:00 2001 From: Gustavo Lelis Date: Tue, 12 Mar 2019 03:14:18 -0300 Subject: [PATCH 5/8] fix(bidirectional): Adding JSDocs in the new file --- .../utils/calculateLongestAndShortestDiameters.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js index 3511c4004..ce335bb0b 100644 --- a/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js +++ b/src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js @@ -1,4 +1,9 @@ -// Calculate the longest and shortest diameters for the given measurementData +/** + * Calculates longest and shortest diameters using measurement handles and pixelSpacing + * @param {Object} eventData + * @param {Object} measurementData + * @returns {void} + */ export default function calculateLongestAndShortestDiameters( eventData, measurementData From d6b75d319bf528d07ea58eb6a33f24ca98a62651 Mon Sep 17 00:00:00 2001 From: Gustavo Lelis Date: Thu, 14 Mar 2019 12:29:21 -0300 Subject: [PATCH 6/8] fix(circleci): Fix node version as 11.11.0 is causing issues on Jest's test. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cd85f1a51..a486ee5ef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2 defaults: &defaults working_directory: ~/repo docker: - - image: circleci/node:latest + - image: circleci/node:10.0.0 jobs: ################## From 6ef5162eb3f90381be176239648d133cc6830393 Mon Sep 17 00:00:00 2001 From: Gustavo Lelis Date: Thu, 14 Mar 2019 12:56:16 -0300 Subject: [PATCH 7/8] fix(circleci): Disable cache on circleci for testing --- .circleci/config.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a486ee5ef..3abe920b9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,15 +15,15 @@ jobs: - checkout - attach_workspace: at: ~/repo - - restore_cache: - keys: - - v1-dependencies-{{ checksum "package.json" }} - - v1-dependencies- - - run: npm install - - save_cache: - paths: - - node_modules - key: v1-dependencies-{{ checksum "package.json" }} + # - restore_cache: + # keys: + # - v1-dependencies-{{ checksum "package.json" }} + # - v1-dependencies- + # - run: npm install + # - save_cache: + # paths: + # - node_modules + # key: v1-dependencies-{{ checksum "package.json" }} - persist_to_workspace: root: ~/repo paths: . From f620ed07e1130aa208ddc19cf0b9aa8587235d68 Mon Sep 17 00:00:00 2001 From: Gustavo Lelis Date: Thu, 14 Mar 2019 13:18:48 -0300 Subject: [PATCH 8/8] fix(netlify-example): Renaming netlify example folder and update index.html --- index.html | 8 ++++---- {examples-old => netlify-example}/app.css | 0 {examples-old => netlify-example}/brush/index.html | 0 {examples-old => netlify-example}/crosshairs/index.html | 0 {examples-old => netlify-example}/freehand/index.html | 0 {examples-old => netlify-example}/icon-classes.css | 0 {examples-old => netlify-example}/icons/mouse-left.svg | 0 {examples-old => netlify-example}/icons/mouse-middle.svg | 0 {examples-old => netlify-example}/icons/mouse-right.svg | 0 {examples-old => netlify-example}/imageLoader.js | 0 {examples-old => netlify-example}/metaDataProvider.js | 0 .../numberMetaDataProvider.js | 0 {examples-old => netlify-example}/petctImageIdLoader.js | 0 .../petctMetaDataProvider.js | 0 {examples-old => netlify-example}/reset.css | 0 {examples-old => netlify-example}/stack/index.html | 0 {examples-old => netlify-example}/textImageLoader.js | 0 {examples-old => netlify-example}/thirdParty/index.html | 0 {examples-old => netlify-example}/tool-help.css | 0 19 files changed, 4 insertions(+), 4 deletions(-) rename {examples-old => netlify-example}/app.css (100%) rename {examples-old => netlify-example}/brush/index.html (100%) rename {examples-old => netlify-example}/crosshairs/index.html (100%) rename {examples-old => netlify-example}/freehand/index.html (100%) rename {examples-old => netlify-example}/icon-classes.css (100%) rename {examples-old => netlify-example}/icons/mouse-left.svg (100%) rename {examples-old => netlify-example}/icons/mouse-middle.svg (100%) rename {examples-old => netlify-example}/icons/mouse-right.svg (100%) rename {examples-old => netlify-example}/imageLoader.js (100%) rename {examples-old => netlify-example}/metaDataProvider.js (100%) rename {examples-old => netlify-example}/numberMetaDataProvider.js (100%) rename {examples-old => netlify-example}/petctImageIdLoader.js (100%) rename {examples-old => netlify-example}/petctMetaDataProvider.js (100%) rename {examples-old => netlify-example}/reset.css (100%) rename {examples-old => netlify-example}/stack/index.html (100%) rename {examples-old => netlify-example}/textImageLoader.js (100%) rename {examples-old => netlify-example}/thirdParty/index.html (100%) rename {examples-old => netlify-example}/tool-help.css (100%) diff --git a/index.html b/index.html index edf307f3a..0407ee457 100644 --- a/index.html +++ b/index.html @@ -6,9 +6,9 @@ name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1" /> - - - + + +