From 38d452e17db2e8ebeab1a587e44a05c35a3ec5a6 Mon Sep 17 00:00:00 2001 From: Alireza Date: Thu, 2 Mar 2023 17:11:51 -0500 Subject: [PATCH] feat(measurementService): use the new api for annotation manager in cs3d (#3206) * fix OHIF to use the new api for annotation manager in cs3d * bump package versions * fix tests * remove unnecessary code --- extensions/cornerstone-dicom-sr/package.json | 4 +- .../src/tools/DICOMSRDisplayTool.ts | 4 +- .../src/utils/addMeasurement.ts | 2 +- .../utils/getFilteredCornerstoneToolState.ts | 2 +- extensions/cornerstone/package.json | 6 +-- .../cornerstone/src/initMeasurementService.js | 2 +- .../utils/selection.ts | 5 +- extensions/measurement-tracking/package.json | 4 +- extensions/tmtv/src/commandsModule.js | 2 +- .../cypress/integration/volume/MPR.spec.js | 4 +- testdata | 2 +- yarn.lock | 46 +++++++++---------- 12 files changed, 40 insertions(+), 43 deletions(-) diff --git a/extensions/cornerstone-dicom-sr/package.json b/extensions/cornerstone-dicom-sr/package.json index 46e9eb36e2b..93573b40bc0 100644 --- a/extensions/cornerstone-dicom-sr/package.json +++ b/extensions/cornerstone-dicom-sr/package.json @@ -46,7 +46,7 @@ "@babel/runtime": "^7.20.13", "classnames": "^2.3.2", "@cornerstonejs/adapters": "^0.3.1", - "@cornerstonejs/core": "^0.31.2", - "@cornerstonejs/tools": "^0.46.2" + "@cornerstonejs/core": "^0.32.0", + "@cornerstonejs/tools": "^0.48.0" } } diff --git a/extensions/cornerstone-dicom-sr/src/tools/DICOMSRDisplayTool.ts b/extensions/cornerstone-dicom-sr/src/tools/DICOMSRDisplayTool.ts index 6aa7a1347e8..9c4f3c2eaa6 100644 --- a/extensions/cornerstone-dicom-sr/src/tools/DICOMSRDisplayTool.ts +++ b/extensions/cornerstone-dicom-sr/src/tools/DICOMSRDisplayTool.ts @@ -48,8 +48,8 @@ export default class DICOMSRDisplayTool extends AnnotationTool { const { element } = viewport; let annotations = annotation.state.getAnnotations( - element, - this.getToolName() + this.getToolName(), + element ); // Todo: We don't need this anymore, filtering happens in triggerAnnotationRender diff --git a/extensions/cornerstone-dicom-sr/src/utils/addMeasurement.ts b/extensions/cornerstone-dicom-sr/src/utils/addMeasurement.ts index 546dc644ddb..ac8e43003fa 100644 --- a/extensions/cornerstone-dicom-sr/src/utils/addMeasurement.ts +++ b/extensions/cornerstone-dicom-sr/src/utils/addMeasurement.ts @@ -43,7 +43,7 @@ export default function addMeasurement( // Use the metadata provider to grab its imagePlaneModule metadata const imagePlaneModule = metaData.get('imagePlaneModule', imageId); - const annotationManager = annotation.state.getDefaultAnnotationManager(); + const annotationManager = annotation.state.getAnnotationManager(); // Create Cornerstone3D Annotation from measurement const frameNumber = diff --git a/extensions/cornerstone-dicom-sr/src/utils/getFilteredCornerstoneToolState.ts b/extensions/cornerstone-dicom-sr/src/utils/getFilteredCornerstoneToolState.ts index 1ef1842a583..9cef8634538 100644 --- a/extensions/cornerstone-dicom-sr/src/utils/getFilteredCornerstoneToolState.ts +++ b/extensions/cornerstone-dicom-sr/src/utils/getFilteredCornerstoneToolState.ts @@ -67,7 +67,7 @@ function getFilteredCornerstoneToolState( const uidFilter = measurementData.map(md => md.uid); const uids = uidFilter.slice(); - const annotationManager = annotation.state.getDefaultAnnotationManager(); + const annotationManager = annotation.state.getAnnotationManager(); const framesOfReference = annotationManager.getFramesOfReference(); for (let i = 0; i < framesOfReference.length; i++) { diff --git a/extensions/cornerstone/package.json b/extensions/cornerstone/package.json index e46bd0fd30e..8a62a6905e2 100644 --- a/extensions/cornerstone/package.json +++ b/extensions/cornerstone/package.json @@ -44,9 +44,9 @@ "dependencies": { "@babel/runtime": "^7.20.13", "@cornerstonejs/adapters": "^0.3.1", - "@cornerstonejs/core": "^0.31.2", - "@cornerstonejs/streaming-image-volume-loader": "^0.12.2", - "@cornerstonejs/tools": "^0.46.2", + "@cornerstonejs/core": "^0.32.0", + "@cornerstonejs/streaming-image-volume-loader": "^0.13.0", + "@cornerstonejs/tools": "^0.48.0", "@kitware/vtk.js": "26.5.6", "html2canvas": "^1.4.1", "lodash.debounce": "4.0.8", diff --git a/extensions/cornerstone/src/initMeasurementService.js b/extensions/cornerstone/src/initMeasurementService.js index e081435ceb7..93a618eaf32 100644 --- a/extensions/cornerstone/src/initMeasurementService.js +++ b/extensions/cornerstone/src/initMeasurementService.js @@ -366,7 +366,7 @@ const connectMeasurementServiceToTools = ( imageId = dataSource.getImageIdsForInstance({ instance }); } - const annotationManager = annotation.state.getDefaultAnnotationManager(); + const annotationManager = annotation.state.getAnnotationManager(); annotationManager.addAnnotation({ annotationUID: measurement.uid, highlighted: false, diff --git a/extensions/cornerstone/src/utils/measurementServiceMappings/utils/selection.ts b/extensions/cornerstone/src/utils/measurementServiceMappings/utils/selection.ts index c70bf832e48..156133306de 100644 --- a/extensions/cornerstone/src/utils/measurementServiceMappings/utils/selection.ts +++ b/extensions/cornerstone/src/utils/measurementServiceMappings/utils/selection.ts @@ -30,10 +30,7 @@ function getFirstAnnotationSelected(element) { cs3dToolAnnotationUtils.selection.getAnnotationsSelected() || []; if (selectedAnnotationUID) { - return cs3dToolAnnotationUtils.state.getAnnotation( - selectedAnnotationUID, - element - ); + return cs3dToolAnnotationUtils.state.getAnnotation(selectedAnnotationUID); } } diff --git a/extensions/measurement-tracking/package.json b/extensions/measurement-tracking/package.json index 6916ccbdeeb..1f2f5c69463 100644 --- a/extensions/measurement-tracking/package.json +++ b/extensions/measurement-tracking/package.json @@ -32,8 +32,8 @@ "peerDependencies": { "@ohif/core": "^3.0.0", "classnames": "^2.3.2", - "@cornerstonejs/core": "^0.31.2", - "@cornerstonejs/tools": "^0.46.2", + "@cornerstonejs/core": "^0.32.0", + "@cornerstonejs/tools": "^0.48.0", "@ohif/extension-cornerstone-dicom-sr": "^3.0.0", "dcmjs": "^0.29.4", "prop-types": "^15.6.2", diff --git a/extensions/tmtv/src/commandsModule.js b/extensions/tmtv/src/commandsModule.js index bc4de2c986b..37de4dea8ba 100644 --- a/extensions/tmtv/src/commandsModule.js +++ b/extensions/tmtv/src/commandsModule.js @@ -432,7 +432,7 @@ const commandsModule = ({ }, createTMTVRTReport: () => { // get all Rectangle ROI annotation - const stateManager = csTools.annotation.state.getDefaultAnnotationManager(); + const stateManager = csTools.annotation.state.getAnnotationManager(); const annotations = []; diff --git a/platform/viewer/cypress/integration/volume/MPR.spec.js b/platform/viewer/cypress/integration/volume/MPR.spec.js index 3efed2fadb3..d377a3fa3ae 100644 --- a/platform/viewer/cypress/integration/volume/MPR.spec.js +++ b/platform/viewer/cypress/integration/volume/MPR.spec.js @@ -99,7 +99,7 @@ describe('OHIF MPR', () => { cy.window() .its('cornerstoneTools') .then(cornerstoneTools => { - const state = cornerstoneTools.annotation.state.getDefaultAnnotationManager(); + const state = cornerstoneTools.annotation.state.getAnnotationManager(); const fORMap = state.annotations; // it should not have crosshairs yet @@ -117,7 +117,7 @@ describe('OHIF MPR', () => { cy.window() .its('cornerstoneTools') .then(cornerstoneTools => { - const state = cornerstoneTools.annotation.state.getDefaultAnnotationManager(); + const state = cornerstoneTools.annotation.state.getAnnotationManager(); const fORMap = state.annotations; const fOR = Object.keys(fORMap)[0]; diff --git a/testdata b/testdata index 1bca96aa2ae..4d59660c288 160000 --- a/testdata +++ b/testdata @@ -1 +1 @@ -Subproject commit 1bca96aa2aeae7d90b3c8db73845c85dd27b34d5 +Subproject commit 4d59660c2883ed749a680e5fb6d4624ab54c9422 diff --git a/yarn.lock b/yarn.lock index 8566e80789f..c9d5ac58cbc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1443,28 +1443,28 @@ resolved "https://registry.npmjs.org/@cornerstonejs/codec-openjph/-/codec-openjph-2.4.2.tgz#e96721d56f6ec96f7f95c16321d88cc8467d8d81" integrity sha512-lgdvBvvNezleY+4pIe2ceUsJzlZe/0PipdeubQ3vZZOz3xxtHHMR1XFCl4fgd8gosR8COHuD7h6q+MwgrwBsng== -"@cornerstonejs/core@^0.31.2": - version "0.31.2" - resolved "https://registry.npmjs.org/@cornerstonejs/core/-/core-0.31.2.tgz#0087cb4445962c82125ae2dddff49aadcfab634d" - integrity sha512-RIxKF/3gGvx8Rca91YlAkUF0DVICedHr6Xis9x8EvOIm+DraP1h3FSQs6bO77FdalAEPGyDjG5U8ZfsAkAXN4g== +"@cornerstonejs/core@^0.32.0": + version "0.32.0" + resolved "https://registry.npmjs.org/@cornerstonejs/core/-/core-0.32.0.tgz#75fb782cc30c82642d6085d7900ec91df51aee36" + integrity sha512-Ep7b+jUO5OtRuEYRlb2Q386ZZfndAdgkDApPoTOYR+BzrwVfMF8/BEmP7UagT/bpAFk5lp5PHt/akN0qM2KR/Q== dependencies: detect-gpu "^4.0.45" lodash.clonedeep "4.5.0" -"@cornerstonejs/streaming-image-volume-loader@^0.12.2": - version "0.12.2" - resolved "https://registry.npmjs.org/@cornerstonejs/streaming-image-volume-loader/-/streaming-image-volume-loader-0.12.2.tgz#5df26356e846743264b624847fe4a1c7f0a304b9" - integrity sha512-0L7+oLAuhv/NIK/zmffHi499QGLcj+KS5Mgcml+7aqecO+ABiOzeC2hdCF9fGRPMN7IWadhDVOE1E78sUoCLRg== +"@cornerstonejs/streaming-image-volume-loader@^0.13.0": + version "0.13.0" + resolved "https://registry.npmjs.org/@cornerstonejs/streaming-image-volume-loader/-/streaming-image-volume-loader-0.13.0.tgz#0b27bde776585274b6f5ab98eb2366711f8fc878" + integrity sha512-js+qaw+I5en0FR/SzJVwGY5WKfldPiVfoJvMuZb7/mNoeoi+N/U47W9WzKlCPqM81xb1mlnjXPyhVdxQ78F36Q== dependencies: - "@cornerstonejs/core" "^0.31.2" - cornerstone-wado-image-loader "^4.8.0" + "@cornerstonejs/core" "^0.32.0" + cornerstone-wado-image-loader "^4.10.0" -"@cornerstonejs/tools@^0.46.2": - version "0.46.2" - resolved "https://registry.npmjs.org/@cornerstonejs/tools/-/tools-0.46.2.tgz#d2adee12652c3c4ce7782102c82c21af6c4d3198" - integrity sha512-sqyEKU0f3nmBBQHju251C/oLbruBtgn+b5JT7Zvr79VH0qSxQAFVUyzYXWIF6Jmbd6i+A/qI1fiv2Gzv2CZfbg== +"@cornerstonejs/tools@^0.48.0": + version "0.48.0" + resolved "https://registry.npmjs.org/@cornerstonejs/tools/-/tools-0.48.0.tgz#c881866a58dd7fe5338256166630e3de633b14e7" + integrity sha512-uMrfY84m1bzVQ8I6HAkmKjZDuB3cHy9T7SWiOhXqfQGdcftkEJXYzXA6WbXDbsG8LpslnSv79Ovbx1uvH2GrWQ== dependencies: - "@cornerstonejs/core" "^0.31.2" + "@cornerstonejs/core" "^0.32.0" lodash.clonedeep "4.5.0" lodash.get "^4.4.2" @@ -8536,10 +8536,10 @@ cornerstone-math@^0.1.9: resolved "https://registry.npmjs.org/cornerstone-math/-/cornerstone-math-0.1.10.tgz#a3f99db64d73c5adee61ae0d570128eca1682d07" integrity sha512-23XSAyP7t70ANvhFyqwvva+zFd1bQ2d5GL7tg9qKE932WmImjA2Y9tiy5n0iTtnf51W/78Png8Lia2o4dCdJaQ== -cornerstone-wado-image-loader@^4.2.1: - version "4.9.1" - resolved "https://registry.npmjs.org/cornerstone-wado-image-loader/-/cornerstone-wado-image-loader-4.9.1.tgz#442eeca78ff0bcf9f9cbde04e8c429f35b31c55a" - integrity sha512-l0HRxGAupfufnHjT9uFpwAtafvuGMKKB9SCL8dHUwCK+7jwNeVigy8s6+Oki2nycaJUzy2TRQaauO78mIf3grg== +cornerstone-wado-image-loader@^4.10.0: + version "4.10.0" + resolved "https://registry.npmjs.org/cornerstone-wado-image-loader/-/cornerstone-wado-image-loader-4.10.0.tgz#25c367cfc54a2c92ebbb5c64dba4fe38439112a1" + integrity sha512-XZcgB8DpUxnsTA3vU/zbPtB2uFLL4ght70BPrQHykkX/Jlg/r6Ob7ztX2dEEAAb4ELE/d4icfGuSy10Acg/kyw== dependencies: "@babel/eslint-parser" "^7.19.1" "@cornerstonejs/codec-charls" "^1.2.3" @@ -8552,10 +8552,10 @@ cornerstone-wado-image-loader@^4.2.1: pako "^2.0.4" uuid "^9.0.0" -cornerstone-wado-image-loader@^4.8.0: - version "4.10.0" - resolved "https://registry.npmjs.org/cornerstone-wado-image-loader/-/cornerstone-wado-image-loader-4.10.0.tgz#25c367cfc54a2c92ebbb5c64dba4fe38439112a1" - integrity sha512-XZcgB8DpUxnsTA3vU/zbPtB2uFLL4ght70BPrQHykkX/Jlg/r6Ob7ztX2dEEAAb4ELE/d4icfGuSy10Acg/kyw== +cornerstone-wado-image-loader@^4.2.1: + version "4.9.1" + resolved "https://registry.npmjs.org/cornerstone-wado-image-loader/-/cornerstone-wado-image-loader-4.9.1.tgz#442eeca78ff0bcf9f9cbde04e8c429f35b31c55a" + integrity sha512-l0HRxGAupfufnHjT9uFpwAtafvuGMKKB9SCL8dHUwCK+7jwNeVigy8s6+Oki2nycaJUzy2TRQaauO78mIf3grg== dependencies: "@babel/eslint-parser" "^7.19.1" "@cornerstonejs/codec-charls" "^1.2.3"