From f07f21117d2766fec8bdf817d7dca3b41117092c Mon Sep 17 00:00:00 2001 From: igoroctaviano Date: Wed, 20 Jan 2021 18:05:20 -0300 Subject: [PATCH 1/3] Notify user of buffer errors from vtk / add possibility to add actions to notifications --- extensions/vtk/src/OHIFVTKViewport.js | 123 +++++++++++------- extensions/vtk/src/index.js | 10 +- .../services/UINotificationService/index.js | 5 +- .../ui/src/components/snackbar/Snackbar.css | 39 +++++- .../src/components/snackbar/SnackbarItem.js | 7 +- .../src/contextProviders/SnackbarProvider.js | 1 + 6 files changed, 132 insertions(+), 53 deletions(-) diff --git a/extensions/vtk/src/OHIFVTKViewport.js b/extensions/vtk/src/OHIFVTKViewport.js index 19e557143..8dccda2f3 100644 --- a/extensions/vtk/src/OHIFVTKViewport.js +++ b/extensions/vtk/src/OHIFVTKViewport.js @@ -72,7 +72,7 @@ class OHIFVTKViewport extends Component { }; static defaultProps = { - onScroll: () => { }, + onScroll: () => {}, }; static id = 'OHIFVTKViewport'; @@ -138,6 +138,8 @@ class OHIFVTKViewport extends Component { SOPInstanceUID, frameIndex ) => { + const { UINotificationService } = this.props.servicesManager.services; + const stack = OHIFVTKViewport.getCornerstoneStack( studies, StudyInstanceUID, @@ -159,11 +161,14 @@ class OHIFVTKViewport extends Component { const { activeLabelmapIndex } = brushStackState; const labelmap3D = brushStackState.labelmaps3D[activeLabelmapIndex]; - if (brushStackState.labelmaps3D.length > 1 && this.props.viewportIndex === 0) { - const { UINotificationService } = this.props.servicesManager.services; + if ( + brushStackState.labelmaps3D.length > 1 && + this.props.viewportIndex === 0 + ) { UINotificationService.show({ title: 'Overlapping Segmentation Found', - message: 'Overlapping segmentations cannot be displayed when in MPR mode', + message: + 'Overlapping segmentations cannot be displayed when in MPR mode', type: 'info', }); } @@ -305,52 +310,80 @@ class OHIFVTKViewport extends Component { seriesDescription: displaySet.seriesDescription, }; - const { - imageDataObject, - labelmapDataObject, - labelmapColorLUT, - } = this.getViewportData( - studies, - StudyInstanceUID, - displaySetInstanceUID, - SOPInstanceUID, - frameIndex - ); + try { + const { + imageDataObject, + labelmapDataObject, + labelmapColorLUT, + } = this.getViewportData( + studies, + StudyInstanceUID, + displaySetInstanceUID, + SOPInstanceUID, + frameIndex + ); - this.imageDataObject = imageDataObject; + this.imageDataObject = imageDataObject; - /* TODO: Not currently used until we have drawing tools in vtkjs. - if (!labelmap) { - labelmap = createLabelMapImageData(data); - } */ + /* TODO: Not currently used until we have drawing tools in vtkjs. + if (!labelmap) { + labelmap = createLabelMapImageData(data); + } */ - const volumeActor = this.getOrCreateVolume( - imageDataObject, - displaySetInstanceUID - ); + const volumeActor = this.getOrCreateVolume( + imageDataObject, + displaySetInstanceUID + ); - this.setState( - { - percentComplete: 0, - dataDetails, - }, - () => { - this.loadProgressively(imageDataObject); + this.setState( + { + percentComplete: 0, + dataDetails, + }, + () => { + this.loadProgressively(imageDataObject); - // TODO: There must be a better way to do this. - // We do this so that if all the data is available the react-vtkjs-viewport - // Will render _something_ before the volumes are set and the volume - // Construction that happens in react-vtkjs-viewport locks up the CPU. - setTimeout(() => { - this.setState({ - volumes: [volumeActor], - paintFilterLabelMapImageData: labelmapDataObject, - paintFilterBackgroundImageData: imageDataObject.vtkImageData, - labelmapColorLUT, - }); - }, 200); + // TODO: There must be a better way to do this. + // We do this so that if all the data is available the react-vtkjs-viewport + // Will render _something_ before the volumes are set and the volume + // Construction that happens in react-vtkjs-viewport locks up the CPU. + setTimeout(() => { + this.setState({ + volumes: [volumeActor], + paintFilterLabelMapImageData: labelmapDataObject, + paintFilterBackgroundImageData: imageDataObject.vtkImageData, + labelmapColorLUT, + }); + }, 200); + } + ); + } catch (error) { + const errorTitle = 'Failed to load 2D MPR'; + console.error(errorTitle, error); + const { UINotificationService } = this.props.servicesManager.services; + if (this.props.viewportIndex === 0) { + const message = error.message.includes('buffer') + ? 'Buffer allocation limit exceeded' + : error.message; + console.error(errorTitle, error); + UINotificationService.show({ + title: errorTitle, + message, + type: 'error', + autoClose: false, + /* action: { + label: 'Download', + onClick: () => { + const listOfUIDs = [window.location.href.split('/').pop()]; + this.props.commandsManager.runCommand('downloadAndZip', { + listOfUIDs, + }); + }, + }, */ + }); } - ); + this.setState({ isLoaded: true }); + } } componentDidMount() { @@ -363,7 +396,7 @@ class OHIFVTKViewport extends Component { if ( displaySet.displaySetInstanceUID !== - prevDisplaySet.displaySetInstanceUID || + prevDisplaySet.displaySetInstanceUID || displaySet.SOPInstanceUID !== prevDisplaySet.SOPInstanceUID || displaySet.frameIndex !== prevDisplaySet.frameIndex ) { diff --git a/extensions/vtk/src/index.js b/extensions/vtk/src/index.js index dde0d6ce0..18e69c22c 100644 --- a/extensions/vtk/src/index.js +++ b/extensions/vtk/src/index.js @@ -9,7 +9,9 @@ import { version } from '../package.json'; // import loadLocales from './loadLocales'; const OHIFVTKViewport = asyncComponent(() => - retryImport(() => import(/* webpackChunkName: "OHIFVTKViewport" */ './OHIFVTKViewport.js')) + retryImport(() => + import(/* webpackChunkName: "OHIFVTKViewport" */ './OHIFVTKViewport.js') + ) ); const vtkExtension = { @@ -21,7 +23,11 @@ const vtkExtension = { getViewportModule({ commandsManager, servicesManager }) { const ExtendedVTKViewport = props => ( - + ); return withCommandsManager(ExtendedVTKViewport, commandsManager); }, diff --git a/platform/core/src/services/UINotificationService/index.js b/platform/core/src/services/UINotificationService/index.js index 0cdb8ea95..42e4b0512 100644 --- a/platform/core/src/services/UINotificationService/index.js +++ b/platform/core/src/services/UINotificationService/index.js @@ -8,6 +8,7 @@ * @property {string} [position="bottomRight"] -"topLeft" | "topCenter | "topRight" | "bottomLeft" | "bottomCenter" | "bottomRight" * @property {string} [type="info"] - "info" | "error" | "warning" | "success" * @property {boolean} [autoClose=true] + * @property {object} [action=null] */ const name = 'UINotificationService'; @@ -34,7 +35,7 @@ const serviceImplementation = { * Create and show a new UI notification; returns the * ID of the created notification. * - * @param {Notification} notification { title, message, duration, position, type, autoClose} + * @param {Notification} notification { title, message, duration, position, type, autoClose, action} * @returns {number} id */ function _show({ @@ -44,6 +45,7 @@ function _show({ position = 'bottomRight', type = 'info', autoClose = true, + action = null, }) { return serviceImplementation._show({ title, @@ -52,6 +54,7 @@ function _show({ position, type, autoClose, + action, }); } diff --git a/platform/ui/src/components/snackbar/Snackbar.css b/platform/ui/src/components/snackbar/Snackbar.css index bb99cefe6..8d7399165 100644 --- a/platform/ui/src/components/snackbar/Snackbar.css +++ b/platform/ui/src/components/snackbar/Snackbar.css @@ -156,19 +156,50 @@ transition: all 300ms ease; } -.sb-success { +.sb-item .sb-action, +.sb-error .sb-action, +.sb-warning .sb-action, +.sb-info .sb-action, +.sb-success .sb-action { + margin-top: 10px; + display: inline-block; + padding: 6px 12px; + margin-bottom: 0; + font-size: 14px; + font-weight: 400; + line-height: 1.42857143; + text-align: center; + white-space: nowrap; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + background-image: none; + border: none; + color: white; +} + +.sb-success, +.sb-success .sb-action { background-color: var(--snackbar-success); } -.sb-error { +.sb-error, +.sb-error .sb-action { background-color: var(--snackbar-error); } -.sb-warning { +.sb-warning, +.sb-warning .sb-action { background-color: var(--snackbar-warning); } -.sb-info { +.sb-info, +.sb-info .sb-action { background-color: var(--snackbar-info); } diff --git a/platform/ui/src/components/snackbar/SnackbarItem.js b/platform/ui/src/components/snackbar/SnackbarItem.js index 40c43697e..f3d7243eb 100644 --- a/platform/ui/src/components/snackbar/SnackbarItem.js +++ b/platform/ui/src/components/snackbar/SnackbarItem.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useEffect } from 'react'; const SnackbarItem = ({ options, onClose }) => { const handleClose = () => { @@ -24,6 +24,11 @@ const SnackbarItem = ({ options, onClose }) => { {options.title &&
{options.title}
} {options.message &&
{options.message}
} + {options.action && ( + + )} ); }; diff --git a/platform/ui/src/contextProviders/SnackbarProvider.js b/platform/ui/src/contextProviders/SnackbarProvider.js index 4b4c6bcbd..86709fedc 100644 --- a/platform/ui/src/contextProviders/SnackbarProvider.js +++ b/platform/ui/src/contextProviders/SnackbarProvider.js @@ -22,6 +22,7 @@ const SnackbarProvider = ({ children, service }) => { autoClose: true, position: 'bottomRight', type: SnackbarTypes.INFO, + action: null, }; const [count, setCount] = useState(1); From 8038009afd6d9596f7055152da0f487b01bfbfe9 Mon Sep 17 00:00:00 2001 From: igoroctaviano Date: Wed, 20 Jan 2021 20:59:03 -0300 Subject: [PATCH 2/3] Add exit mpr action --- extensions/vtk/src/OHIFVTKViewport.js | 17 ++++++++--------- .../ui/src/components/snackbar/SnackbarItem.js | 6 +++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/extensions/vtk/src/OHIFVTKViewport.js b/extensions/vtk/src/OHIFVTKViewport.js index 8dccda2f3..bac284a4e 100644 --- a/extensions/vtk/src/OHIFVTKViewport.js +++ b/extensions/vtk/src/OHIFVTKViewport.js @@ -363,7 +363,7 @@ class OHIFVTKViewport extends Component { const { UINotificationService } = this.props.servicesManager.services; if (this.props.viewportIndex === 0) { const message = error.message.includes('buffer') - ? 'Buffer allocation limit exceeded' + ? 'Dataset is too big to display in MPR' : error.message; console.error(errorTitle, error); UINotificationService.show({ @@ -371,15 +371,14 @@ class OHIFVTKViewport extends Component { message, type: 'error', autoClose: false, - /* action: { - label: 'Download', - onClick: () => { - const listOfUIDs = [window.location.href.split('/').pop()]; - this.props.commandsManager.runCommand('downloadAndZip', { - listOfUIDs, - }); + action: { + label: 'Exit 2D MPR', + onClick: ({ close }) => { + // context: 'ACTIVE_VIEWPORT::VTK', + close(); + this.props.commandsManager.runCommand('setCornerstoneLayout'); }, - }, */ + }, }); } this.setState({ isLoaded: true }); diff --git a/platform/ui/src/components/snackbar/SnackbarItem.js b/platform/ui/src/components/snackbar/SnackbarItem.js index f3d7243eb..2e1d62ccf 100644 --- a/platform/ui/src/components/snackbar/SnackbarItem.js +++ b/platform/ui/src/components/snackbar/SnackbarItem.js @@ -5,6 +5,10 @@ const SnackbarItem = ({ options, onClose }) => { onClose(options.id); }; + const handleClick = () => { + options.action.onClick({ ...options, close: handleClose }); + }; + useEffect(() => { if (options.autoClose) { setTimeout(() => { @@ -25,7 +29,7 @@ const SnackbarItem = ({ options, onClose }) => { {options.title &&
{options.title}
} {options.message &&
{options.message}
} {options.action && ( - )} From 587de94cea9d8d375c7475bdbaa77ca8ddd016e4 Mon Sep 17 00:00:00 2001 From: ohif-bot Date: Thu, 21 Jan 2021 12:35:41 +0000 Subject: [PATCH 3/3] chore(release): publish [skip ci] - @ohif/extension-vtk@1.10.2 - @ohif/core@2.12.1 - @ohif/ui@1.8.1 - @ohif/viewer@4.8.2 --- extensions/vtk/CHANGELOG.md | 8 ++++++++ extensions/vtk/package.json | 6 +++--- platform/core/CHANGELOG.md | 8 ++++++++ platform/core/package.json | 2 +- platform/ui/CHANGELOG.md | 8 ++++++++ platform/ui/package.json | 2 +- platform/viewer/CHANGELOG.md | 8 ++++++++ platform/viewer/package.json | 8 ++++---- 8 files changed, 41 insertions(+), 9 deletions(-) diff --git a/extensions/vtk/CHANGELOG.md b/extensions/vtk/CHANGELOG.md index a6ee3b762..f905f7e3f 100644 --- a/extensions/vtk/CHANGELOG.md +++ b/extensions/vtk/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.10.2](https://github.com/OHIF/Viewers/compare/@ohif/extension-vtk@1.10.1...@ohif/extension-vtk@1.10.2) (2021-01-21) + +**Note:** Version bump only for package @ohif/extension-vtk + + + + + ## [1.10.1](https://github.com/OHIF/Viewers/compare/@ohif/extension-vtk@1.10.0...@ohif/extension-vtk@1.10.1) (2020-12-10) diff --git a/extensions/vtk/package.json b/extensions/vtk/package.json index 1b1836659..1b3c8b35a 100644 --- a/extensions/vtk/package.json +++ b/extensions/vtk/package.json @@ -1,6 +1,6 @@ { "name": "@ohif/extension-vtk", - "version": "1.10.1", + "version": "1.10.2", "description": "OHIF extension for VTK.js", "author": "OHIF", "license": "MIT", @@ -53,8 +53,8 @@ "react-vtkjs-viewport": "^0.14.2" }, "devDependencies": { - "@ohif/core": "^2.12.0", - "@ohif/ui": "^1.8.0", + "@ohif/core": "^2.12.1", + "@ohif/ui": "^1.8.1", "cornerstone-tools": "^4.20.1", "cornerstone-wado-image-loader": "^3.1.0", "dicom-parser": "^1.8.3", diff --git a/platform/core/CHANGELOG.md b/platform/core/CHANGELOG.md index afd6f5d5e..bf41447f6 100644 --- a/platform/core/CHANGELOG.md +++ b/platform/core/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.12.1](https://github.com/OHIF/Viewers/compare/@ohif/core@2.12.0...@ohif/core@2.12.1) (2021-01-21) + +**Note:** Version bump only for package @ohif/core + + + + + # [2.12.0](https://github.com/OHIF/Viewers/compare/@ohif/core@2.11.1...@ohif/core@2.12.0) (2020-12-10) diff --git a/platform/core/package.json b/platform/core/package.json index 71ad0313a..ba48fd021 100644 --- a/platform/core/package.json +++ b/platform/core/package.json @@ -1,6 +1,6 @@ { "name": "@ohif/core", - "version": "2.12.0", + "version": "2.12.1", "description": "Generic business logic for web-based medical imaging applications", "author": "OHIF Core Team", "license": "MIT", diff --git a/platform/ui/CHANGELOG.md b/platform/ui/CHANGELOG.md index 964bae730..5dc90a2dd 100644 --- a/platform/ui/CHANGELOG.md +++ b/platform/ui/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.8.1](https://github.com/OHIF/Viewers/compare/@ohif/ui@1.8.0...@ohif/ui@1.8.1) (2021-01-21) + +**Note:** Version bump only for package @ohif/ui + + + + + # [1.8.0](https://github.com/OHIF/Viewers/compare/@ohif/ui@1.7.1...@ohif/ui@1.8.0) (2020-12-10) diff --git a/platform/ui/package.json b/platform/ui/package.json index cb97e11d3..3fe076c90 100644 --- a/platform/ui/package.json +++ b/platform/ui/package.json @@ -1,6 +1,6 @@ { "name": "@ohif/ui", - "version": "1.8.0", + "version": "1.8.1", "description": "A set of React components for Medical Imaging Viewers", "author": "OHIF Contributors", "license": "MIT", diff --git a/platform/viewer/CHANGELOG.md b/platform/viewer/CHANGELOG.md index d99d6d4c8..9af74c046 100644 --- a/platform/viewer/CHANGELOG.md +++ b/platform/viewer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.8.2](https://github.com/OHIF/Viewers/compare/@ohif/viewer@4.8.1...@ohif/viewer@4.8.2) (2021-01-21) + +**Note:** Version bump only for package @ohif/viewer + + + + + ## [4.8.1](https://github.com/OHIF/Viewers/compare/@ohif/viewer@4.8.0...@ohif/viewer@4.8.1) (2020-12-10) **Note:** Version bump only for package @ohif/viewer diff --git a/platform/viewer/package.json b/platform/viewer/package.json index 7defee060..9c106cbb3 100644 --- a/platform/viewer/package.json +++ b/platform/viewer/package.json @@ -1,6 +1,6 @@ { "name": "@ohif/viewer", - "version": "4.8.1", + "version": "4.8.2", "description": "OHIF Viewer", "author": "OHIF Contributors", "license": "MIT", @@ -49,7 +49,7 @@ }, "dependencies": { "@babel/runtime": "^7.5.5", - "@ohif/core": "^2.12.0", + "@ohif/core": "^2.12.1", "@ohif/extension-cornerstone": "^2.10.0", "@ohif/extension-debugging": "^0.1.6", "@ohif/extension-dicom-html": "^1.3.0", @@ -58,9 +58,9 @@ "@ohif/extension-dicom-rt": "^0.6.1", "@ohif/extension-dicom-segmentation": "^0.5.0", "@ohif/extension-lesion-tracker": "^0.2.1", - "@ohif/extension-vtk": "^1.10.1", + "@ohif/extension-vtk": "^1.10.2", "@ohif/i18n": "^0.53.0", - "@ohif/ui": "^1.8.0", + "@ohif/ui": "^1.8.1", "@tanem/react-nprogress": "^1.1.25", "classnames": "^2.2.6", "core-js": "^3.2.1",