Files
ohif-viewer/extensions/cornerstone/src/index.js
T

75 lines
2.0 KiB
JavaScript
Raw Normal View History

import React from 'react';
import init from './init.js';
import commandsModule from './commandsModule.js';
import toolbarModule from './toolbarModule.js';
2019-12-02 14:02:35 -05:00
import CornerstoneViewportDownloadForm from './CornerstoneViewportDownloadForm';
2020-09-03 12:58:04 +02:00
import { version } from '../package.json';
2019-04-16 12:00:06 -04:00
const Component = React.lazy(() => {
return import('./OHIFCornerstoneViewport');
});
const OHIFCornerstoneViewport = props => {
return (
<React.Suspense fallback={<div>Loading...</div>}>
<Component {...props} />
</React.Suspense>
);
};
/**
*
*/
export default {
/**
* Only required property. Should be a unique value across all extensions.
*/
id: 'cornerstone',
2020-09-03 12:58:04 +02:00
version,
/**
*
*
* @param {object} [configuration={}]
* @param {object|array} [configuration.csToolsConfig] - Passed directly to `initCornerstoneTools`
*/
preRegistration({ servicesManager, configuration = {} }) {
init({ servicesManager, configuration });
},
2021-09-09 04:58:24 -03:00
getViewportModule({ commandsManager, appConfig }) {
const ExtendedOHIFCornerstoneViewport = props => {
2021-03-26 13:27:51 -03:00
/**
* TODO: This appears to be used to set the redux parameters for
* the viewport when new images are loaded. It's very ugly
* and we should remove it.
*/
const onNewImageHandler = jumpData => {
2021-03-26 13:27:51 -03:00
/** Do not trigger all viewports to render unnecessarily */
jumpData.refreshViewports = false;
commandsManager.runCommand('jumpToImage', jumpData);
};
2021-09-09 04:58:24 -03:00
const { studyPrefetcher } = appConfig;
const isStackPrefetchEnabled =
studyPrefetcher && !studyPrefetcher.enabled;
2020-06-04 06:52:30 -03:00
return (
2021-09-09 04:58:24 -03:00
<OHIFCornerstoneViewport
{...props}
onNewImage={onNewImageHandler}
isStackPrefetchEnabled={isStackPrefetchEnabled}
/>
2020-06-04 06:52:30 -03:00
);
};
return ExtendedOHIFCornerstoneViewport;
},
getToolbarModule() {
return toolbarModule;
},
2019-12-02 14:02:35 -05:00
getCommandsModule({ servicesManager }) {
return commandsModule({ servicesManager });
2019-06-20 22:57:14 -04:00
},
};
2019-12-02 14:02:35 -05:00
export { CornerstoneViewportDownloadForm };