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 => (
-