2024-03-27 21:01:32 +01:00
|
|
|
import type { Button } from '@ohif/core/types';
|
2024-03-28 15:40:32 +01:00
|
|
|
import { defaults, ToolbarService, ViewportGridService } from '@ohif/core';
|
2024-03-27 21:01:32 +01:00
|
|
|
import { WindowLevelMenuItem } from '@ohif/ui';
|
2023-09-22 16:23:44 +02:00
|
|
|
|
|
|
|
|
const { windowLevelPresets } = defaults;
|
2024-03-28 15:40:32 +01:00
|
|
|
const { createButton } = ToolbarService;
|
|
|
|
|
|
|
|
|
|
const ReferenceLinesListeners: RunCommand = [
|
|
|
|
|
{
|
|
|
|
|
commandName: 'setSourceViewportForReferenceLinesTool',
|
|
|
|
|
context: 'CORNERSTONE',
|
|
|
|
|
},
|
|
|
|
|
];
|
2023-09-22 16:23:44 +02:00
|
|
|
|
|
|
|
|
function _createWwwcPreset(preset, title, subtitle) {
|
|
|
|
|
return {
|
|
|
|
|
id: preset.toString(),
|
|
|
|
|
title,
|
|
|
|
|
subtitle,
|
|
|
|
|
commands: [
|
|
|
|
|
{
|
|
|
|
|
commandName: 'setWindowLevel',
|
|
|
|
|
commandOptions: {
|
|
|
|
|
...windowLevelPresets[preset],
|
|
|
|
|
},
|
|
|
|
|
context: 'CORNERSTONE',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-28 15:40:32 +01:00
|
|
|
export const setToolActiveToolbar = {
|
|
|
|
|
commandName: 'setToolActiveToolbar',
|
|
|
|
|
commandOptions: {
|
|
|
|
|
toolGroupIds: ['default', 'mpr', 'SRToolGroup'],
|
|
|
|
|
},
|
|
|
|
|
};
|
2023-09-22 16:23:44 +02:00
|
|
|
|
2024-03-27 21:01:32 +01:00
|
|
|
const toolbarButtons: Button[] = [
|
2023-09-22 16:23:44 +02:00
|
|
|
{
|
|
|
|
|
id: 'Zoom',
|
2024-03-27 21:01:32 +01:00
|
|
|
uiType: 'ohif.radioGroup',
|
2023-09-22 16:23:44 +02:00
|
|
|
props: {
|
|
|
|
|
icon: 'tool-zoom',
|
|
|
|
|
label: 'Zoom',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: setToolActiveToolbar,
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
2023-09-22 16:23:44 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'WindowLevel',
|
2024-03-27 21:01:32 +01:00
|
|
|
uiType: 'ohif.splitButton',
|
2023-09-22 16:23:44 +02:00
|
|
|
props: {
|
|
|
|
|
groupId: 'WindowLevel',
|
2024-03-28 15:40:32 +01:00
|
|
|
primary: createButton({
|
2024-03-27 21:01:32 +01:00
|
|
|
id: 'WindowLevel',
|
|
|
|
|
icon: 'tool-window-level',
|
|
|
|
|
label: 'Window Level',
|
|
|
|
|
tooltip: 'Window Level',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: setToolActiveToolbar,
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
|
|
|
|
}),
|
2023-09-22 16:23:44 +02:00
|
|
|
secondary: {
|
|
|
|
|
icon: 'chevron-down',
|
|
|
|
|
tooltip: 'W/L Presets',
|
|
|
|
|
},
|
|
|
|
|
renderer: WindowLevelMenuItem,
|
|
|
|
|
items: [
|
|
|
|
|
_createWwwcPreset(1, 'Soft tissue', '400 / 40'),
|
|
|
|
|
_createWwwcPreset(2, 'Lung', '1500 / -600'),
|
|
|
|
|
_createWwwcPreset(3, 'Liver', '150 / 90'),
|
|
|
|
|
_createWwwcPreset(4, 'Bone', '2500 / 480'),
|
|
|
|
|
_createWwwcPreset(5, 'Brain', '80 / 40'),
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'Pan',
|
2024-03-27 21:01:32 +01:00
|
|
|
uiType: 'ohif.radioGroup',
|
2023-09-22 16:23:44 +02:00
|
|
|
props: {
|
|
|
|
|
icon: 'tool-move',
|
|
|
|
|
label: 'Pan',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: setToolActiveToolbar,
|
|
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'TrackballRotate',
|
|
|
|
|
uiType: 'ohif.radioGroup',
|
|
|
|
|
props: {
|
|
|
|
|
type: 'tool',
|
|
|
|
|
icon: 'tool-3d-rotate',
|
|
|
|
|
label: '3D Rotate',
|
|
|
|
|
commands: setToolActiveToolbar,
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
2023-09-22 16:23:44 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'Capture',
|
2024-03-27 21:01:32 +01:00
|
|
|
uiType: 'ohif.radioGroup',
|
2023-09-22 16:23:44 +02:00
|
|
|
props: {
|
|
|
|
|
icon: 'tool-capture',
|
|
|
|
|
label: 'Capture',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: 'showDownloadViewportModal',
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.action',
|
2023-09-22 16:23:44 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'Layout',
|
2024-03-27 21:01:32 +01:00
|
|
|
uiType: 'ohif.layoutSelector',
|
2023-09-22 16:23:44 +02:00
|
|
|
props: {
|
|
|
|
|
rows: 3,
|
2024-03-28 15:40:32 +01:00
|
|
|
columns: 4,
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.action',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: 'setViewportGridLayout',
|
2023-09-22 16:23:44 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'Crosshairs',
|
2024-03-27 21:01:32 +01:00
|
|
|
uiType: 'ohif.radioGroup',
|
2023-09-22 16:23:44 +02:00
|
|
|
props: {
|
|
|
|
|
icon: 'tool-crosshair',
|
|
|
|
|
label: 'Crosshairs',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: {
|
|
|
|
|
commandName: 'setToolActiveToolbar',
|
|
|
|
|
commandOptions: {
|
|
|
|
|
toolGroupIds: ['mpr'],
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
2023-09-22 16:23:44 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'MoreTools',
|
2024-03-27 21:01:32 +01:00
|
|
|
uiType: 'ohif.splitButton',
|
2023-09-22 16:23:44 +02:00
|
|
|
props: {
|
|
|
|
|
groupId: 'MoreTools',
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.group.promoteToPrimaryIfCornerstoneToolNotActiveInTheList',
|
2024-03-28 15:40:32 +01:00
|
|
|
primary: createButton({
|
2024-03-27 21:01:32 +01:00
|
|
|
id: 'Reset',
|
|
|
|
|
icon: 'tool-reset',
|
2024-03-28 15:40:32 +01:00
|
|
|
tooltip: 'Reset View',
|
|
|
|
|
label: 'Reset',
|
|
|
|
|
commands: 'resetViewport',
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.action',
|
|
|
|
|
}),
|
2023-09-22 16:23:44 +02:00
|
|
|
secondary: {
|
|
|
|
|
icon: 'chevron-down',
|
2024-03-28 15:40:32 +01:00
|
|
|
label: '',
|
2023-09-22 16:23:44 +02:00
|
|
|
tooltip: 'More Tools',
|
|
|
|
|
},
|
|
|
|
|
items: [
|
2024-03-28 15:40:32 +01:00
|
|
|
createButton({
|
|
|
|
|
id: 'Reset',
|
|
|
|
|
icon: 'tool-reset',
|
|
|
|
|
label: 'Reset View',
|
|
|
|
|
tooltip: 'Reset View',
|
|
|
|
|
commands: 'resetViewport',
|
|
|
|
|
evaluate: 'evaluate.action',
|
|
|
|
|
}),
|
|
|
|
|
createButton({
|
|
|
|
|
id: 'rotate-right',
|
2024-03-27 21:01:32 +01:00
|
|
|
icon: 'tool-rotate-right',
|
|
|
|
|
label: 'Rotate Right',
|
|
|
|
|
tooltip: 'Rotate +90',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: 'rotateViewportCW',
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.action',
|
|
|
|
|
}),
|
2024-03-28 15:40:32 +01:00
|
|
|
createButton({
|
|
|
|
|
id: 'flipHorizontal',
|
2024-03-27 21:01:32 +01:00
|
|
|
icon: 'tool-flip-horizontal',
|
2024-03-28 15:40:32 +01:00
|
|
|
label: 'Flip Horizontal',
|
|
|
|
|
tooltip: 'Flip Horizontally',
|
|
|
|
|
commands: 'flipViewportHorizontal',
|
|
|
|
|
evaluate: ['evaluate.viewportProperties.toggle', 'evaluate.not3D'],
|
|
|
|
|
}),
|
|
|
|
|
createButton({
|
|
|
|
|
id: 'ReferenceLines',
|
|
|
|
|
icon: 'tool-referenceLines',
|
|
|
|
|
label: 'Reference Lines',
|
|
|
|
|
tooltip: 'Show Reference Lines',
|
|
|
|
|
commands: {
|
|
|
|
|
commandName: 'setToolEnabled',
|
|
|
|
|
commandOptions: {
|
|
|
|
|
toolName: 'ReferenceLines',
|
|
|
|
|
toggle: true, // Toggle the tool on/off upon click
|
2023-09-22 16:23:44 +02:00
|
|
|
},
|
2024-03-28 15:40:32 +01:00
|
|
|
},
|
|
|
|
|
listeners: {
|
|
|
|
|
[ViewportGridService.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED]: ReferenceLinesListeners,
|
|
|
|
|
[ViewportGridService.EVENTS.VIEWPORTS_READY]: ReferenceLinesListeners,
|
|
|
|
|
},
|
|
|
|
|
evaluate: 'evaluate.cornerstoneTool.toggle',
|
2024-03-27 21:01:32 +01:00
|
|
|
}),
|
2024-03-28 15:40:32 +01:00
|
|
|
createButton({
|
|
|
|
|
id: 'ImageOverlay',
|
|
|
|
|
icon: 'toggle-dicom-overlay',
|
|
|
|
|
label: 'Image Overlay',
|
|
|
|
|
tooltip: 'Toggle Image Overlay',
|
|
|
|
|
commands: {
|
|
|
|
|
commandName: 'setToolEnabled',
|
|
|
|
|
commandOptions: {
|
|
|
|
|
toolName: 'ImageOverlayViewer',
|
|
|
|
|
toggle: true, // Toggle the tool on/off upon click
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
evaluate: 'evaluate.cornerstoneTool.toggle',
|
|
|
|
|
}),
|
|
|
|
|
createButton({
|
2024-03-27 21:01:32 +01:00
|
|
|
id: 'StackScroll',
|
|
|
|
|
icon: 'tool-stack-scroll',
|
|
|
|
|
label: 'Stack Scroll',
|
|
|
|
|
tooltip: 'Stack Scroll',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: setToolActiveToolbar,
|
2024-03-27 21:01:32 +01:00
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
|
|
|
|
}),
|
2024-03-28 15:40:32 +01:00
|
|
|
createButton({
|
|
|
|
|
id: 'invert',
|
2024-03-27 21:01:32 +01:00
|
|
|
icon: 'tool-invert',
|
|
|
|
|
label: 'Invert',
|
|
|
|
|
tooltip: 'Invert Colors',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: 'invertViewport',
|
|
|
|
|
evaluate: 'evaluate.viewportProperties.toggle',
|
|
|
|
|
}),
|
|
|
|
|
createButton({
|
|
|
|
|
id: 'Probe',
|
|
|
|
|
icon: 'tool-probe',
|
|
|
|
|
label: 'Probe',
|
|
|
|
|
tooltip: 'Probe',
|
|
|
|
|
commands: setToolActiveToolbar,
|
|
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
2024-03-27 21:01:32 +01:00
|
|
|
}),
|
2024-03-28 15:40:32 +01:00
|
|
|
createButton({
|
2024-03-27 21:01:32 +01:00
|
|
|
id: 'Cine',
|
|
|
|
|
icon: 'tool-cine',
|
|
|
|
|
label: 'Cine',
|
|
|
|
|
tooltip: 'Cine',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: 'toggleCine',
|
|
|
|
|
evaluate: ['evaluate.cine', 'evaluate.not3D'],
|
|
|
|
|
}),
|
|
|
|
|
createButton({
|
|
|
|
|
id: 'Angle',
|
|
|
|
|
icon: 'tool-angle',
|
|
|
|
|
label: 'Angle',
|
|
|
|
|
tooltip: 'Angle',
|
|
|
|
|
commands: setToolActiveToolbar,
|
|
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
|
|
|
|
}),
|
|
|
|
|
createButton({
|
|
|
|
|
id: 'Magnify',
|
|
|
|
|
icon: 'tool-magnify',
|
|
|
|
|
label: 'Magnify',
|
|
|
|
|
tooltip: 'Magnify',
|
|
|
|
|
commands: setToolActiveToolbar,
|
|
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
|
|
|
|
}),
|
|
|
|
|
createButton({
|
|
|
|
|
id: 'RectangleROI',
|
|
|
|
|
icon: 'tool-rectangle',
|
|
|
|
|
label: 'Rectangle',
|
|
|
|
|
tooltip: 'Rectangle',
|
|
|
|
|
commands: setToolActiveToolbar,
|
|
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
2024-03-27 21:01:32 +01:00
|
|
|
}),
|
2024-03-28 15:40:32 +01:00
|
|
|
createButton({
|
|
|
|
|
id: 'CalibrationLine',
|
|
|
|
|
icon: 'tool-calibration',
|
|
|
|
|
label: 'Calibration',
|
|
|
|
|
tooltip: 'Calibration Line',
|
|
|
|
|
commands: setToolActiveToolbar,
|
|
|
|
|
evaluate: 'evaluate.cornerstoneTool',
|
|
|
|
|
}),
|
|
|
|
|
createButton({
|
|
|
|
|
id: 'TagBrowser',
|
2024-03-27 21:01:32 +01:00
|
|
|
icon: 'list-bullets',
|
|
|
|
|
label: 'Dicom Tag Browser',
|
|
|
|
|
tooltip: 'Dicom Tag Browser',
|
2024-03-28 15:40:32 +01:00
|
|
|
commands: 'openDICOMTagViewer',
|
2024-03-27 21:01:32 +01:00
|
|
|
}),
|
2023-09-22 16:23:44 +02:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export default toolbarButtons;
|