There had been a change made to make the hanging protocols auto initialize, but that caused problems on mode init because the couldn't specify the hanging protocols any longer. THis change restores that, and also improves the API a little bit by allowing the display set selectors to be specified by id instead of positionally. fix(hp):PR Review Comments fix(hp):Unit test and docs
207 lines
5.9 KiB
JavaScript
207 lines
5.9 KiB
JavaScript
import toolbarButtons from './toolbarButtons.js';
|
|
import { hotkeys } from '@ohif/core';
|
|
import { id } from './id';
|
|
|
|
const configs = {
|
|
Length: {},
|
|
//
|
|
};
|
|
|
|
const ohif = {
|
|
layout: '@ohif/extension-default.layoutTemplateModule.viewerLayout',
|
|
sopClassHandler: '@ohif/extension-default.sopClassHandlerModule.stack',
|
|
hangingProtocol: '@ohif/extension-default.hangingProtocolModule.default',
|
|
measurements: '@ohif/extension-default.panelModule.measure',
|
|
thumbnailList: '@ohif/extension-default.panelModule.seriesList',
|
|
};
|
|
|
|
const cs3d = {
|
|
viewport: '@ohif/extension-cornerstone.viewportModule.cornerstone',
|
|
};
|
|
|
|
const dicomsr = {
|
|
sopClassHandler:
|
|
'@ohif/extension-cornerstone-dicom-sr.sopClassHandlerModule.dicom-sr',
|
|
viewport: '@ohif/extension-cornerstone-dicom-sr.viewportModule.dicom-sr',
|
|
};
|
|
|
|
const dicomvideo = {
|
|
sopClassHandler:
|
|
'@ohif/extension-dicom-video.sopClassHandlerModule.dicom-video',
|
|
viewport: '@ohif/extension-dicom-video.viewportModule.dicom-video',
|
|
};
|
|
|
|
const dicompdf = {
|
|
sopClassHandler: '@ohif/extension-dicom-pdf.sopClassHandlerModule.dicom-pdf',
|
|
viewport: '@ohif/extension-dicom-pdf.viewportModule.dicom-pdf',
|
|
};
|
|
|
|
const extensionDependencies = {
|
|
'@ohif/extension-default': '^3.0.0',
|
|
'@ohif/extension-cornerstone': '^3.0.0',
|
|
'@ohif/extension-cornerstone-dicom-sr': '^3.0.0',
|
|
'@ohif/extension-dicom-pdf': '^3.0.1',
|
|
'@ohif/extension-dicom-video': '^3.0.1',
|
|
};
|
|
|
|
function modeFactory({ modeConfiguration }) {
|
|
return {
|
|
id,
|
|
routeName: 'viewer',
|
|
displayName: 'Basic Viewer CS3D',
|
|
/**
|
|
* Lifecycle hooks
|
|
*/
|
|
onModeEnter: ({ servicesManager, extensionManager }) => {
|
|
const { ToolBarService, ToolGroupService } = servicesManager.services;
|
|
const utilityModule = extensionManager.getModuleEntry(
|
|
'@ohif/extension-cornerstone.utilityModule.tools'
|
|
);
|
|
|
|
const { toolNames, Enums } = utilityModule.exports;
|
|
|
|
const tools = {
|
|
active: [
|
|
{
|
|
toolName: toolNames.WindowLevel,
|
|
bindings: [{ mouseButton: Enums.MouseBindings.Primary }],
|
|
},
|
|
{
|
|
toolName: toolNames.Pan,
|
|
bindings: [{ mouseButton: Enums.MouseBindings.Auxiliary }],
|
|
},
|
|
{
|
|
toolName: toolNames.Zoom,
|
|
bindings: [{ mouseButton: Enums.MouseBindings.Secondary }],
|
|
},
|
|
{ toolName: toolNames.StackScrollMouseWheel, bindings: [] },
|
|
],
|
|
passive: [
|
|
{ toolName: toolNames.Length },
|
|
{ toolName: toolNames.Bidirectional },
|
|
{ toolName: toolNames.Probe },
|
|
{ toolName: toolNames.EllipticalROI },
|
|
{ toolName: toolNames.RectangleROI },
|
|
{ toolName: toolNames.StackScroll },
|
|
],
|
|
// enabled
|
|
// disabled
|
|
};
|
|
|
|
const toolGroupId = 'default';
|
|
ToolGroupService.createToolGroupAndAddTools(toolGroupId, tools, configs);
|
|
|
|
let unsubscribe;
|
|
|
|
const activateTool = () => {
|
|
ToolBarService.recordInteraction({
|
|
groupId: 'WindowLevel',
|
|
itemId: 'WindowLevel',
|
|
interactionType: 'tool',
|
|
commands: [
|
|
{
|
|
commandName: 'setToolActive',
|
|
commandOptions: {
|
|
toolName: 'WindowLevel',
|
|
},
|
|
context: 'CORNERSTONE',
|
|
},
|
|
],
|
|
});
|
|
|
|
// We don't need to reset the active tool whenever a viewport is getting
|
|
// added to the toolGroup.
|
|
unsubscribe();
|
|
};
|
|
|
|
// Since we only have one viewport for the basic cs3d mode and it has
|
|
// only one hanging protocol, we can just use the first viewport
|
|
({ unsubscribe } = ToolGroupService.subscribe(
|
|
ToolGroupService.EVENTS.VIEWPORT_ADDED,
|
|
activateTool
|
|
));
|
|
|
|
ToolBarService.init(extensionManager);
|
|
ToolBarService.addButtons(toolbarButtons);
|
|
ToolBarService.createButtonSection('primary', [
|
|
'MeasurementTools',
|
|
'Zoom',
|
|
'WindowLevel',
|
|
'Pan',
|
|
'Layout',
|
|
'MoreTools',
|
|
]);
|
|
},
|
|
onModeExit: ({ servicesManager }) => {
|
|
const {
|
|
ToolGroupService,
|
|
MeasurementService,
|
|
ToolBarService,
|
|
} = servicesManager.services;
|
|
|
|
ToolBarService.reset();
|
|
MeasurementService.clearMeasurements();
|
|
ToolGroupService.destroy();
|
|
},
|
|
validationTags: {
|
|
study: [],
|
|
series: [],
|
|
},
|
|
isValidMode: ({ modalities }) => {
|
|
const modalities_list = modalities.split('\\');
|
|
|
|
// Slide Microscopy modality not supported by basic mode yet
|
|
return !modalities_list.includes('SM');
|
|
},
|
|
routes: [
|
|
{
|
|
path: 'viewer-cs3d',
|
|
/*init: ({ servicesManager, extensionManager }) => {
|
|
//defaultViewerRouteInit
|
|
},*/
|
|
layoutTemplate: ({ location, servicesManager }) => {
|
|
return {
|
|
id: ohif.layout,
|
|
props: {
|
|
// TODO: Should be optional, or required to pass empty array for slots?
|
|
leftPanels: [ohif.thumbnailList],
|
|
rightPanels: [ohif.measurements],
|
|
viewports: [
|
|
{
|
|
namespace: cs3d.viewport,
|
|
displaySetsToDisplay: [ohif.sopClassHandler],
|
|
},
|
|
{
|
|
namespace: dicomvideo.viewport,
|
|
displaySetsToDisplay: [dicomvideo.sopClassHandler],
|
|
},
|
|
{
|
|
namespace: dicompdf.viewport,
|
|
displaySetsToDisplay: [dicompdf.sopClassHandler],
|
|
},
|
|
],
|
|
},
|
|
};
|
|
},
|
|
},
|
|
],
|
|
extensions: extensionDependencies,
|
|
hangingProtocol: [ohif.hangingProtocol],
|
|
sopClassHandlers: [
|
|
dicomvideo.sopClassHandler,
|
|
ohif.sopClassHandler,
|
|
dicompdf.sopClassHandler,
|
|
dicomsr.sopClassHandler,
|
|
],
|
|
hotkeys: [...hotkeys.defaults.hotkeyBindings],
|
|
};
|
|
}
|
|
|
|
const mode = {
|
|
id,
|
|
modeFactory,
|
|
extensionDependencies,
|
|
};
|
|
|
|
export default mode;
|