Fix/update branch cherry pick (#2039)
* Update all the icons * Turn off global tool sync; watch as the world burns * Shift a bunch of things around so we can start tracking/setting per element * ToolBarService to initiate one of three different calls; callback passed to all button types * SplitButton and Toolbar Button to use new `onInteraction` prop and new toolbar state * Changes to toolbar button interface and config * Fix broken layout selector * Update SR viewport to activate tools in viewport component * Duplicate activation logic in measurement tracking extension * Add alternative/dashed variants for SR Viewport * pass through "setToolActive" commands for other viewport types * fix small overlay bugs (no wwwc or scale info) * Show SpacingBetweenSlices instead of PixelSpacing in patient information dialog * Fix prop-types * Update tracked viewport to have alternative tracked styling * alt styling for SR viewports * Update to support isLocked + isRehydratable * fix broken logic * fix broken logic * switch icon style * fix icon styles * hover and click to start flow * expedited workflow when data is not dirty (just after SR hydration) * fix: setting elliptical roi tool * fix arrow annotate dialog * fix: do not show learn more button for now * remove dead code * simpler cache invalidation * simpler cache invalidation part 2 * Fix for unable to spand study cards on separate pages
This commit is contained in:
1 parent
365ba2fa72
commit
cae54b0779
78 files changed
+1678
-1263
No files matched your search
@@ -13,7 +13,9 @@ const DEFAULT_SIZE = 512;
|
||||
const MAX_TEXTURE_SIZE = 10000;
|
||||
|
||||
const CornerstoneViewportDownloadForm = ({ onClose, activeViewportIndex }) => {
|
||||
const activeEnabledElement = getEnabledElement(activeViewportIndex);
|
||||
const { enabledElement: activeEnabledElement } = getEnabledElement(
|
||||
activeViewportIndex
|
||||
);
|
||||
|
||||
const enableViewport = viewportElement => {
|
||||
if (viewportElement) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import React, { Component } from 'react';
|
||||
import CornerstoneViewport from 'react-cornerstone-viewport';
|
||||
import OHIF from '@ohif/core';
|
||||
import csTools from 'cornerstone-tools';
|
||||
import PropTypes from 'prop-types';
|
||||
import debounce from 'lodash.debounce';
|
||||
import getTools from './utils/getTools.js';
|
||||
import setActiveAndPassiveToolsForElement from './utils/setActiveAndPassiveToolsForElement';
|
||||
|
||||
import { setEnabledElement } from './state';
|
||||
|
||||
@@ -23,6 +26,7 @@ class OHIFCornerstoneViewport extends Component {
|
||||
dataSource: PropTypes.object,
|
||||
children: PropTypes.node,
|
||||
customProps: PropTypes.object,
|
||||
ToolBarService: PropTypes.object,
|
||||
};
|
||||
|
||||
static name = 'OHIFCornerstoneViewport';
|
||||
@@ -131,7 +135,7 @@ class OHIFCornerstoneViewport extends Component {
|
||||
|
||||
if (
|
||||
displaySet.displaySetInstanceUID !==
|
||||
prevDisplaySet.displaySetInstanceUID ||
|
||||
prevDisplaySet.displaySetInstanceUID ||
|
||||
displaySet.SOPInstanceUID !== prevDisplaySet.SOPInstanceUID ||
|
||||
displaySet.imageIndex !== prevDisplaySet.imageIndex
|
||||
) {
|
||||
@@ -203,7 +207,14 @@ class OHIFCornerstoneViewport extends Component {
|
||||
// Need to expose viewportGrid as a "UI Service"
|
||||
onElementEnabled={evt => {
|
||||
const enabledElement = evt.detail.element;
|
||||
const tools = getTools();
|
||||
const toolAlias = ToolBarService.state.primaryToolId;
|
||||
|
||||
setEnabledElement(viewportIndex, enabledElement);
|
||||
setActiveAndPassiveToolsForElement(enabledElement, tools);
|
||||
csTools.setToolActiveForElement(enabledElement, toolAlias, {
|
||||
mouseButtonMask: 1,
|
||||
});
|
||||
}}
|
||||
// Sync resize throttle w/ sidepanel animation duration to prevent
|
||||
// seizure inducing strobe blinking effect
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import React from 'react';
|
||||
import { Input, Dialog } from '@ohif/ui';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} data
|
||||
* @param {*} data.text
|
||||
* @param {*} data.label
|
||||
* @param {*} event
|
||||
* @param {*} callback
|
||||
* @param {*} isArrowAnnotateInputDialog
|
||||
*/
|
||||
function callInputDialog(
|
||||
UIDialogService,
|
||||
data,
|
||||
callback,
|
||||
isArrowAnnotateInputDialog = true
|
||||
) {
|
||||
const dialogId = 'enter-annotation';
|
||||
const label = data
|
||||
? isArrowAnnotateInputDialog
|
||||
? data.text
|
||||
: data.label
|
||||
: '';
|
||||
|
||||
const onSubmitHandler = ({ action, value }) => {
|
||||
switch (action.id) {
|
||||
case 'save':
|
||||
callback(value.label, action.id);
|
||||
break;
|
||||
case 'cancel':
|
||||
callback('', action.id);
|
||||
break;
|
||||
}
|
||||
UIDialogService.dismiss({ id: dialogId });
|
||||
};
|
||||
|
||||
if (UIDialogService) {
|
||||
UIDialogService.create({
|
||||
id: dialogId,
|
||||
centralize: true,
|
||||
isDraggable: false,
|
||||
showOverlay: true,
|
||||
content: Dialog,
|
||||
contentProps: {
|
||||
title: 'Enter your annotation',
|
||||
value: { label },
|
||||
noCloseButton: true,
|
||||
onClose: () => UIDialogService.dismiss({ id: dialogId }),
|
||||
actions: [
|
||||
{ id: 'cancel', text: 'Cancel', type: 'secondary' },
|
||||
{ id: 'save', text: 'Save', type: 'primary' },
|
||||
],
|
||||
onSubmit: onSubmitHandler,
|
||||
body: ({ value, setValue }) => {
|
||||
return (
|
||||
<div className="p-4 bg-primary-dark">
|
||||
<Input
|
||||
autoFocus
|
||||
className="mt-2 bg-black border-primary-main"
|
||||
type="text"
|
||||
containerClassName="mr-2"
|
||||
value={value.label}
|
||||
onChange={event => {
|
||||
event.persist();
|
||||
setValue(value => ({ ...value, label: event.target.value }));
|
||||
}}
|
||||
onKeyPress={event => {
|
||||
if (event.key === 'Enter') {
|
||||
onSubmitHandler({ value, action: { id: 'save' } });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default callInputDialog;
|
||||
@@ -10,12 +10,13 @@ const scroll = cornerstoneTools.import('util/scroll');
|
||||
const { studyMetadataManager } = OHIF.utils;
|
||||
const { setViewportSpecificData } = OHIF.redux.actions;
|
||||
|
||||
const commandsModule = ({ servicesManager }) => {
|
||||
const commandsModule = ({ servicesManager, commandsManager }) => {
|
||||
const { ViewportGridService } = servicesManager.services;
|
||||
|
||||
function _getActiveViewportsEnabledElement() {
|
||||
const { activeViewportIndex } = ViewportGridService.getState();
|
||||
return getEnabledElement(activeViewportIndex);
|
||||
const { element } = getEnabledElement(activeViewportIndex) || {};
|
||||
return element;
|
||||
}
|
||||
|
||||
const actions = {
|
||||
@@ -98,7 +99,38 @@ const commandsModule = ({ servicesManager }) => {
|
||||
if (!toolName) {
|
||||
console.warn('No toolname provided to setToolActive command');
|
||||
}
|
||||
cornerstoneTools.setToolActive(toolName, { mouseButtonMask: 1 });
|
||||
|
||||
// Find total number of tool indexes
|
||||
const { viewports } = ViewportGridService.getState();
|
||||
for (let i = 0; i < viewports.length; i++) {
|
||||
const viewport = viewports[i];
|
||||
const hasDisplaySet = viewport.displaySetInstanceUID !== undefined;
|
||||
|
||||
if (!hasDisplaySet) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const viewportInfo = getEnabledElement(i);
|
||||
const hasCornerstoneContext =
|
||||
viewportInfo.context == 'ACTIVE_VIEWPORT::CORNERSTONE';
|
||||
|
||||
if (hasCornerstoneContext) {
|
||||
cornerstoneTools.setToolActiveForElement(
|
||||
viewportInfo.enabledElement,
|
||||
toolName,
|
||||
{ mouseButtonMask: 1 }
|
||||
);
|
||||
} else {
|
||||
commandsManager.runCommand(
|
||||
'setToolActive',
|
||||
{
|
||||
element: viewportInfo.element,
|
||||
toolName,
|
||||
},
|
||||
viewportInfo.context
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
clearAnnotations: () => {
|
||||
const element = _getActiveViewportsEnabledElement();
|
||||
@@ -106,7 +138,7 @@ const commandsModule = ({ servicesManager }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const enabledElement = cornerstone.getEnabledElement(element);
|
||||
const { enabledElement } = cornerstone.getEnabledElement(element) || {};
|
||||
if (!enabledElement || !enabledElement.image) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,13 +33,19 @@ export default {
|
||||
preRegistration({ servicesManager, commandsManager, configuration = {} }) {
|
||||
init({ servicesManager, commandsManager, configuration });
|
||||
},
|
||||
getViewportModule({ commandsManager }) {
|
||||
getViewportModule({ servicesManager, commandsManager }) {
|
||||
const ExtendedOHIFCornerstoneViewport = props => {
|
||||
const onNewImageHandler = jumpData => {
|
||||
commandsManager.runCommand('jumpToImage', jumpData);
|
||||
};
|
||||
const { ToolBarService } = servicesManager;
|
||||
|
||||
return (
|
||||
<OHIFCornerstoneViewport {...props} onNewImage={onNewImageHandler} />
|
||||
<OHIFCornerstoneViewport
|
||||
{...props}
|
||||
ToolBarService={ToolBarService}
|
||||
onNewImage={onNewImageHandler}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -47,8 +53,8 @@ export default {
|
||||
{ name: 'cornerstone', component: ExtendedOHIFCornerstoneViewport },
|
||||
];
|
||||
},
|
||||
getCommandsModule({ servicesManager }) {
|
||||
return commandsModule({ servicesManager });
|
||||
getCommandsModule({ servicesManager, commandsManager }) {
|
||||
return commandsModule({ servicesManager, commandsManager });
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
+104
-200
@@ -1,19 +1,19 @@
|
||||
import React from 'react';
|
||||
import OHIF from '@ohif/core';
|
||||
import { Input, Dialog, ContextMenuMeasurements } from '@ohif/ui';
|
||||
import { ContextMenuMeasurements } from '@ohif/ui';
|
||||
import cs from 'cornerstone-core';
|
||||
import csTools from 'cornerstone-tools';
|
||||
import merge from 'lodash.merge';
|
||||
import getTools, { toolsGroupedByType } from './utils/getTools.js';
|
||||
import initCornerstoneTools from './initCornerstoneTools.js';
|
||||
import './initWADOImageLoader.js';
|
||||
import getCornerstoneMeasurementById from './utils/getCornerstoneMeasurementById';
|
||||
import measurementServiceMappingsFactory from './utils/measurementServiceMappings/measurementServiceMappingsFactory';
|
||||
import { setEnabledElement } from './state';
|
||||
import callInputDialog from './callInputDialog.js';
|
||||
|
||||
// TODO -> Global "context menu open state", or lots of expensive searches on drag?
|
||||
|
||||
let CONTEXT_MENU_OPEN = false;
|
||||
|
||||
const { globalImageIdSpecificToolStateManager } = csTools;
|
||||
|
||||
const TOOL_TYPES_WITH_CONTEXT_MENU = [
|
||||
@@ -30,6 +30,24 @@ const TOOL_TYPES_WITH_CONTEXT_MENU = [
|
||||
const _refreshViewports = () =>
|
||||
cs.getEnabledElements().forEach(({ element }) => cs.updateImage(element));
|
||||
|
||||
/* Add extension tools configuration here. */
|
||||
const _createInternalToolsConfig = UIDialogService => {
|
||||
return {
|
||||
ArrowAnnotate: {
|
||||
configuration: {
|
||||
getTextCallback: (callback, eventDetails) =>
|
||||
callInputDialog(UIDialogService, null, callback),
|
||||
changeTextCallback: (data, eventDetails, callback) =>
|
||||
callInputDialog(UIDialogService, data, callback),
|
||||
allowEmptyLabel: true,
|
||||
},
|
||||
},
|
||||
DragProbe: {
|
||||
defaultStrategy: 'minimal',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Object} servicesManager
|
||||
@@ -45,7 +63,11 @@ export default function init({
|
||||
UIDialogService,
|
||||
MeasurementService,
|
||||
DisplaySetService,
|
||||
ToolBarService,
|
||||
} = servicesManager.services;
|
||||
const tools = getTools();
|
||||
|
||||
console.log(servicesManager.services);
|
||||
|
||||
/* Measurement Service */
|
||||
const measurementServiceSource = _connectToolsToMeasurementService(
|
||||
@@ -112,6 +134,7 @@ export default function init({
|
||||
);
|
||||
|
||||
callInputDialog(
|
||||
UIDialogService,
|
||||
measurement,
|
||||
(label, actionId) => {
|
||||
if (actionId === 'cancel') {
|
||||
@@ -180,8 +203,18 @@ export default function init({
|
||||
}
|
||||
};
|
||||
|
||||
function elementEnabledHandler(evt) {
|
||||
// TODO: This is the handler for ALL ENABLED ELEMENT EVENTS
|
||||
// ... Activation logic should take place per element, not for all (diff behavior per ext)
|
||||
function elementEnabledHandler(tools, evt) {
|
||||
const element = evt.detail.element;
|
||||
|
||||
_addConfiguredToolsForElement(
|
||||
UIDialogService,
|
||||
element,
|
||||
tools,
|
||||
configuration
|
||||
);
|
||||
|
||||
element.addEventListener(csTools.EVENTS.TOUCH_PRESS, onTouchPress);
|
||||
element.addEventListener(
|
||||
csTools.EVENTS.MOUSE_CLICK,
|
||||
@@ -200,85 +233,6 @@ export default function init({
|
||||
element.removeEventListener(cs.EVENTS.NEW_IMAGE, cancelContextMenuIfOpen);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} data
|
||||
* @param {*} event
|
||||
* @param {*} callback
|
||||
* @param {*} isArrowAnnotateInputDialog
|
||||
*/
|
||||
const callInputDialog = (
|
||||
data,
|
||||
callback,
|
||||
isArrowAnnotateInputDialog = true
|
||||
) => {
|
||||
const dialogId = 'enter-annotation';
|
||||
const label = data
|
||||
? isArrowAnnotateInputDialog
|
||||
? data.text
|
||||
: data.label
|
||||
: '';
|
||||
|
||||
const onSubmitHandler = ({ action, value }) => {
|
||||
switch (action.id) {
|
||||
case 'save':
|
||||
callback(value.label, action.id);
|
||||
break;
|
||||
case 'cancel':
|
||||
callback('', action.id);
|
||||
break;
|
||||
}
|
||||
UIDialogService.dismiss({ id: dialogId });
|
||||
};
|
||||
|
||||
if (UIDialogService) {
|
||||
UIDialogService.create({
|
||||
id: dialogId,
|
||||
centralize: true,
|
||||
isDraggable: false,
|
||||
showOverlay: true,
|
||||
content: Dialog,
|
||||
contentProps: {
|
||||
title: 'Enter your annotation',
|
||||
value: { label },
|
||||
noCloseButton: true,
|
||||
onClose: () => UIDialogService.dismiss({ id: dialogId }),
|
||||
actions: [
|
||||
{ id: 'cancel', text: 'Cancel', type: 'secondary' },
|
||||
{ id: 'save', text: 'Save', type: 'primary' },
|
||||
],
|
||||
onSubmit: onSubmitHandler,
|
||||
body: ({ value, setValue }) => {
|
||||
const onChangeHandler = event => {
|
||||
event.persist();
|
||||
setValue(value => ({ ...value, label: event.target.value }));
|
||||
};
|
||||
|
||||
const onKeyPressHandler = event => {
|
||||
if (event.key === 'Enter') {
|
||||
onSubmitHandler({ value, action: { id: 'save' } });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-4 bg-primary-dark">
|
||||
<Input
|
||||
autoFocus
|
||||
className="mt-2 bg-black border-primary-main"
|
||||
type="text"
|
||||
containerClassName="mr-2"
|
||||
value={value.label}
|
||||
onChange={onChangeHandler}
|
||||
onKeyPress={onKeyPressHandler}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const { csToolsConfig } = configuration;
|
||||
const metadataProvider = OHIF.cornerstone.metadataProvider;
|
||||
|
||||
@@ -286,7 +240,7 @@ export default function init({
|
||||
|
||||
// ~~
|
||||
const defaultCsToolsConfig = csToolsConfig || {
|
||||
globalToolSyncEnabled: true,
|
||||
globalToolSyncEnabled: false, // hold on to your pants!
|
||||
showSVGCursors: false,
|
||||
autoResizeViewports: false,
|
||||
};
|
||||
@@ -298,10 +252,10 @@ export default function init({
|
||||
// THIS
|
||||
// is a way for extensions that "depend" on this extension to notify it of
|
||||
// new cornerstone enabled elements so it's commands continue to work.
|
||||
const handleOhifCornerstoneEnabledElementEvent = function (evt) {
|
||||
const { viewportIndex, enabledElement } = evt.detail;
|
||||
const handleOhifCornerstoneEnabledElementEvent = function(evt) {
|
||||
const { context, viewportIndex, enabledElement } = evt.detail;
|
||||
|
||||
setEnabledElement(viewportIndex, enabledElement);
|
||||
setEnabledElement(viewportIndex, enabledElement, context);
|
||||
};
|
||||
|
||||
document.addEventListener(
|
||||
@@ -309,120 +263,10 @@ export default function init({
|
||||
handleOhifCornerstoneEnabledElementEvent
|
||||
);
|
||||
|
||||
const toolsGroupedByType = {
|
||||
touch: [csTools.PanMultiTouchTool, csTools.ZoomTouchPinchTool],
|
||||
annotations: [
|
||||
csTools.ArrowAnnotateTool,
|
||||
csTools.BidirectionalTool,
|
||||
csTools.LengthTool,
|
||||
csTools.AngleTool,
|
||||
csTools.FreehandRoiTool,
|
||||
csTools.EllipticalRoiTool,
|
||||
csTools.DragProbeTool,
|
||||
csTools.RectangleRoiTool,
|
||||
],
|
||||
other: [
|
||||
csTools.PanTool,
|
||||
csTools.ZoomTool,
|
||||
csTools.WwwcTool,
|
||||
csTools.WwwcRegionTool,
|
||||
csTools.MagnifyTool,
|
||||
csTools.StackScrollTool,
|
||||
csTools.StackScrollMouseWheelTool,
|
||||
csTools.OverlayTool,
|
||||
],
|
||||
};
|
||||
|
||||
let tools = [];
|
||||
Object.keys(toolsGroupedByType).forEach(toolsGroup =>
|
||||
tools.push(...toolsGroupedByType[toolsGroup])
|
||||
cs.events.addEventListener(
|
||||
cs.EVENTS.ELEMENT_ENABLED,
|
||||
elementEnabledHandler.bind(null, tools)
|
||||
);
|
||||
|
||||
/* Add extension tools configuration here. */
|
||||
const internalToolsConfig = {
|
||||
ArrowAnnotate: {
|
||||
configuration: {
|
||||
getTextCallback: (callback, eventDetails) =>
|
||||
callInputDialog(null, callback),
|
||||
changeTextCallback: (data, eventDetails, callback) =>
|
||||
callInputDialog(data, callback),
|
||||
allowEmptyLabel: true,
|
||||
},
|
||||
},
|
||||
DragProbe: {
|
||||
defaultStrategy: 'minimal',
|
||||
},
|
||||
};
|
||||
|
||||
/* Abstract tools configuration using extension configuration. */
|
||||
const parseToolProps = (props, tool) => {
|
||||
const { annotations } = toolsGroupedByType;
|
||||
// An alternative approach would be to remove the `drawHandlesOnHover` config
|
||||
// from the supported configuration properties in `cornerstone-tools`
|
||||
const toolsWithHideableHandles = annotations.filter(
|
||||
tool => !['RectangleRoiTool', 'EllipticalRoiTool'].includes(tool.name)
|
||||
);
|
||||
|
||||
let parsedProps = { ...props };
|
||||
|
||||
/**
|
||||
* drawHandles - Never/Always show handles
|
||||
* drawHandlesOnHover - Only show handles on handle hover (pointNearHandle)
|
||||
* hideHandlesIfMoving - Hides the handles whilst you are moving them, for better visibility.
|
||||
*
|
||||
* Does not apply to tools where handles aren't placed in predictable
|
||||
* locations.
|
||||
*/
|
||||
if (
|
||||
configuration.hideHandles !== false &&
|
||||
toolsWithHideableHandles.includes(tool)
|
||||
) {
|
||||
if (props.configuration) {
|
||||
parsedProps.configuration.drawHandlesOnHover = true;
|
||||
parsedProps.configuration.hideHandlesIfMoving = true;
|
||||
} else {
|
||||
parsedProps.configuration = {
|
||||
drawHandlesOnHover: true,
|
||||
hideHandlesIfMoving: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return parsedProps;
|
||||
};
|
||||
|
||||
/* Add tools with its custom props through extension configuration. */
|
||||
tools.forEach(tool => {
|
||||
const toolName = new tool().name;
|
||||
const externalToolsConfig = configuration.tools || {};
|
||||
const externalToolProps = externalToolsConfig[toolName] || {};
|
||||
const internalToolProps = internalToolsConfig[toolName] || {};
|
||||
const props = merge(
|
||||
internalToolProps,
|
||||
parseToolProps(externalToolProps, tool)
|
||||
);
|
||||
csTools.addTool(tool, props);
|
||||
});
|
||||
|
||||
// TODO -> We need a better way to do this with maybe global tool state setting all tools passive.
|
||||
const BaseAnnotationTool = csTools.importInternal('base/BaseAnnotationTool');
|
||||
tools.forEach(tool => {
|
||||
if (tool.prototype instanceof BaseAnnotationTool) {
|
||||
// BaseAnnotationTool would likely come from csTools lib exports
|
||||
const toolName = new tool().name;
|
||||
csTools.setToolPassive(toolName); // there may be a better place to determine name; may not be on uninstantiated class
|
||||
}
|
||||
});
|
||||
|
||||
csTools.setToolActive('Pan', { mouseButtonMask: 4 });
|
||||
csTools.setToolActive('Zoom', { mouseButtonMask: 2 });
|
||||
csTools.setToolActive('Wwwc', { mouseButtonMask: 1 });
|
||||
csTools.setToolActive('StackScrollMouseWheel', {}); // TODO: Empty options should not be required
|
||||
csTools.setToolActive('PanMultiTouch', { pointers: 2 }); // TODO: Better error if no options
|
||||
csTools.setToolActive('ZoomTouchPinch', {});
|
||||
csTools.setToolEnabled('Overlay', {});
|
||||
|
||||
cs.events.addEventListener(cs.EVENTS.ELEMENT_ENABLED, elementEnabledHandler);
|
||||
cs.events.addEventListener(
|
||||
cs.EVENTS.ELEMENT_DISABLED,
|
||||
elementDisabledHandler
|
||||
@@ -646,3 +490,63 @@ const _getDefaultPosition = event => ({
|
||||
x: (event && event.currentPoints.client.x) || 0,
|
||||
y: (event && event.currentPoints.client.y) || 0,
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function _addConfiguredToolsForElement(
|
||||
UIDialogService,
|
||||
element,
|
||||
tools,
|
||||
configuration
|
||||
) {
|
||||
const internalToolsConfig = _createInternalToolsConfig(UIDialogService);
|
||||
/* Add tools with its custom props through extension configuration. */
|
||||
tools.forEach(tool => {
|
||||
const toolName = new tool().name;
|
||||
const externalToolsConfig = configuration.tools || {};
|
||||
const externalToolProps = externalToolsConfig[toolName] || {};
|
||||
const internalToolProps = internalToolsConfig[toolName] || {};
|
||||
const props = merge(
|
||||
internalToolProps,
|
||||
_parseToolProps(configuration, externalToolProps, tool)
|
||||
);
|
||||
csTools.addToolForElement(element, tool, props);
|
||||
});
|
||||
}
|
||||
/* Abstract tools configuration using extension configuration. */
|
||||
function _parseToolProps(configuration, props, tool) {
|
||||
const { annotations } = toolsGroupedByType;
|
||||
// An alternative approach would be to remove the `drawHandlesOnHover` config
|
||||
// from the supported configuration properties in `cornerstone-tools`
|
||||
const toolsWithHideableHandles = annotations.filter(
|
||||
tool => !['RectangleRoiTool', 'EllipticalRoiTool'].includes(tool.name)
|
||||
);
|
||||
|
||||
let parsedProps = { ...props };
|
||||
|
||||
/**
|
||||
* drawHandles - Never/Always show handles
|
||||
* drawHandlesOnHover - Only show handles on handle hover (pointNearHandle)
|
||||
* hideHandlesIfMoving - Hides the handles whilst you are moving them, for better visibility.
|
||||
*
|
||||
* Does not apply to tools where handles aren't placed in predictable
|
||||
* locations.
|
||||
*/
|
||||
if (
|
||||
configuration.hideHandles !== false &&
|
||||
toolsWithHideableHandles.includes(tool)
|
||||
) {
|
||||
if (props.configuration) {
|
||||
parsedProps.configuration.drawHandlesOnHover = true;
|
||||
parsedProps.configuration.hideHandlesIfMoving = true;
|
||||
} else {
|
||||
parsedProps.configuration = {
|
||||
drawHandlesOnHover: true,
|
||||
hideHandlesIfMoving: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return parsedProps;
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
const state = {
|
||||
// The `defaultContext` of an extension's commandsModule
|
||||
DEFAULT_CONTEXT: 'ACTIVE_VIEWPORT::CORNERSTONE',
|
||||
enabledElements: {},
|
||||
};
|
||||
|
||||
@@ -7,14 +9,22 @@ const state = {
|
||||
* @param {HTMLElement} dom Active viewport element.
|
||||
* @return void
|
||||
*/
|
||||
const setEnabledElement = (viewportIndex, element) =>
|
||||
(state.enabledElements[viewportIndex] = element);
|
||||
const setEnabledElement = (viewportIndex, element, context) => {
|
||||
const targetContext = context || DEFAULT_CONTEXT;
|
||||
|
||||
state.enabledElements[viewportIndex] = {
|
||||
element,
|
||||
context: targetContext,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Grabs the enabled element `dom` reference of an active viewport.
|
||||
* Grabs the enabled element `dom` reference of an adective viewport.
|
||||
*
|
||||
* @return {HTMLElement} Active viewport element.
|
||||
*/
|
||||
const getEnabledElement = viewportIndex => state.enabledElements[viewportIndex];
|
||||
const getEnabledElement = viewportIndex => {
|
||||
return state.enabledElements[viewportIndex];
|
||||
};
|
||||
|
||||
export { setEnabledElement, getEnabledElement };
|
||||
@@ -0,0 +1,36 @@
|
||||
import csTools from 'cornerstone-tools';
|
||||
|
||||
const toolsGroupedByType = {
|
||||
touch: [csTools.PanMultiTouchTool, csTools.ZoomTouchPinchTool],
|
||||
annotations: [
|
||||
csTools.ArrowAnnotateTool,
|
||||
csTools.BidirectionalTool,
|
||||
csTools.LengthTool,
|
||||
csTools.AngleTool,
|
||||
csTools.FreehandRoiTool,
|
||||
csTools.EllipticalRoiTool,
|
||||
csTools.DragProbeTool,
|
||||
csTools.RectangleRoiTool,
|
||||
],
|
||||
other: [
|
||||
csTools.PanTool,
|
||||
csTools.ZoomTool,
|
||||
csTools.WwwcTool,
|
||||
csTools.WwwcRegionTool,
|
||||
csTools.MagnifyTool,
|
||||
csTools.StackScrollTool,
|
||||
csTools.StackScrollMouseWheelTool,
|
||||
csTools.OverlayTool,
|
||||
],
|
||||
};
|
||||
|
||||
export default function getTools() {
|
||||
const tools = [];
|
||||
Object.keys(toolsGroupedByType).forEach(toolsGroup =>
|
||||
tools.push(...toolsGroupedByType[toolsGroup])
|
||||
);
|
||||
|
||||
return tools;
|
||||
}
|
||||
|
||||
export { toolsGroupedByType };
|
||||
@@ -0,0 +1,21 @@
|
||||
import csTools from 'cornerstone-tools';
|
||||
|
||||
export default function _setActiveAndPassiveToolsForElement(element, tools) {
|
||||
const BaseAnnotationTool = csTools.importInternal('base/BaseAnnotationTool');
|
||||
|
||||
tools.forEach(tool => {
|
||||
if (tool.prototype instanceof BaseAnnotationTool) {
|
||||
// BaseAnnotationTool would likely come from csTools lib exports
|
||||
const toolName = new tool().name;
|
||||
csTools.setToolPassiveForElement(element, toolName); // there may be a better place to determine name; may not be on uninstantiated class
|
||||
}
|
||||
});
|
||||
|
||||
csTools.setToolActiveForElement(element, 'Pan', { mouseButtonMask: 4 });
|
||||
csTools.setToolActiveForElement(element, 'Zoom', { mouseButtonMask: 2 });
|
||||
csTools.setToolActiveForElement(element, 'Wwwc', { mouseButtonMask: 1 });
|
||||
csTools.setToolActiveForElement(element, 'StackScrollMouseWheel', {}); // TODO: Empty options should not be required
|
||||
csTools.setToolActiveForElement(element, 'PanMultiTouch', { pointers: 2 }); // TODO: Better error if no options
|
||||
csTools.setToolActiveForElement(element, 'ZoomTouchPinch', {});
|
||||
csTools.setToolEnabledForElement(element, 'Overlay', {});
|
||||
}
|
||||
@@ -29,8 +29,7 @@ function LayoutSelector() {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const onClickHandler = () => setIsOpen(!isOpen);
|
||||
|
||||
const onInteractionHandler = () => setIsOpen(!isOpen);
|
||||
const DropdownContent = isOpen ? OHIFLayoutSelector : null;
|
||||
|
||||
return (
|
||||
@@ -38,7 +37,7 @@ function LayoutSelector() {
|
||||
id="Layout"
|
||||
label="Grid Layout"
|
||||
icon="tool-layout"
|
||||
onClick={onClickHandler}
|
||||
onInteraction={onInteractionHandler}
|
||||
dropdownContent={
|
||||
DropdownContent !== null && (
|
||||
<DropdownContent
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { SplitButton } from '@ohif/ui';
|
||||
|
||||
export default SplitButton;
|
||||
@@ -1,141 +1,69 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SidePanel, ErrorBoundary, UserPreferences, AboutModal, Header, useModal } from '@ohif/ui';
|
||||
import {
|
||||
SidePanel,
|
||||
ErrorBoundary,
|
||||
UserPreferences,
|
||||
AboutModal,
|
||||
Header,
|
||||
useModal,
|
||||
} from '@ohif/ui';
|
||||
|
||||
import NestedMenu from './ToolbarButtonNestedMenu.jsx';
|
||||
|
||||
// TODO: Having ToolbarPrimary and ToolbarSecondary is ugly, but
|
||||
// these are going to be unified shortly so this is good enough for now.
|
||||
function ToolbarPrimary({ servicesManager }) {
|
||||
function Toolbar({ servicesManager }) {
|
||||
const { ToolBarService } = servicesManager.services;
|
||||
const defaultTool = {
|
||||
icon: 'tool-more-menu',
|
||||
label: 'More',
|
||||
isActive: false,
|
||||
};
|
||||
const [toolbars, setToolbars] = useState({ primary: [], secondary: [] });
|
||||
const [activeTool, setActiveTool] = useState(defaultTool);
|
||||
|
||||
const setActiveToolHandler = (tool, isNested) => {
|
||||
setActiveTool(isNested ? tool : defaultTool);
|
||||
};
|
||||
|
||||
const onPrimaryClickHandler = (evt, btn) => {
|
||||
if (
|
||||
btn.props &&
|
||||
btn.props.commands &&
|
||||
evt.value &&
|
||||
btn.props.commands[evt.value]
|
||||
) {
|
||||
const { commandName, commandOptions } = btn.props.commands[evt.value];
|
||||
commandsManager.runCommand(commandName, commandOptions);
|
||||
}
|
||||
};
|
||||
const [toolbarButtons, setToolbarButtons] = useState([]);
|
||||
const [buttonState, setButtonState] = useState({
|
||||
primaryToolId: '',
|
||||
toggles: {},
|
||||
groups: {},
|
||||
});
|
||||
|
||||
// Could track buttons and state separately...?
|
||||
useEffect(() => {
|
||||
const { unsubscribe } = ToolBarService.subscribe(
|
||||
const { unsubscribe: unsub1 } = ToolBarService.subscribe(
|
||||
ToolBarService.EVENTS.TOOL_BAR_MODIFIED,
|
||||
() => {
|
||||
console.warn('~~~ TOOL BAR MODIFIED EVENT CAUGHT');
|
||||
const updatedToolbars = {
|
||||
primary: ToolBarService.getButtonSection('primary', {
|
||||
onClick: onPrimaryClickHandler,
|
||||
setActiveTool: setActiveToolHandler,
|
||||
}),
|
||||
secondary: ToolBarService.getButtonSection('secondary', {
|
||||
setActiveTool: setActiveToolHandler,
|
||||
}),
|
||||
};
|
||||
setToolbars(updatedToolbars);
|
||||
}
|
||||
() => setToolbarButtons(ToolBarService.getButtonSection('primary'))
|
||||
);
|
||||
const { unsubscribe: unsub2 } = ToolBarService.subscribe(
|
||||
ToolBarService.EVENTS.TOOL_BAR_STATE_MODIFIED,
|
||||
() => setButtonState({ ...ToolBarService.state })
|
||||
);
|
||||
|
||||
return unsubscribe;
|
||||
return () => {
|
||||
unsub1();
|
||||
unsub2();
|
||||
};
|
||||
}, [ToolBarService]);
|
||||
|
||||
return <>
|
||||
{toolbars.primary.map((toolDef, index) => {
|
||||
const isNested = Array.isArray(toolDef);
|
||||
if (!isNested) {
|
||||
return (
|
||||
<>
|
||||
{toolbarButtons.map((toolDef, index) => {
|
||||
const { id, Component, componentProps } = toolDef;
|
||||
return <Component key={id} id={id} {...componentProps} />;
|
||||
} else {
|
||||
// TODO: ...
|
||||
|
||||
// isActive if:
|
||||
// - id is primary?
|
||||
// - id is in list of "toggled on"?
|
||||
|
||||
// Also need... to filter list for splitButton, and set primary based on most recently clicked
|
||||
// Also need to kill the radioGroup button's magic logic
|
||||
// Everything should be reactive off these props, so commands can inform ToolbarService
|
||||
|
||||
// These can... Trigger toolbar events based on updates?
|
||||
// Then sync using useEffect, or simply modify the state here?
|
||||
return (
|
||||
<NestedMenu
|
||||
key={index}
|
||||
isActive={activeTool.isActive}
|
||||
icon={activeTool.icon}
|
||||
label={activeTool.label}
|
||||
>
|
||||
<div className="flex">
|
||||
{toolDef.map(x => {
|
||||
const { id, Component, componentProps } = x;
|
||||
return (
|
||||
<Component key={id} id={id} {...componentProps} />
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</NestedMenu>
|
||||
<Component
|
||||
key={id}
|
||||
id={id}
|
||||
{...componentProps}
|
||||
bState={buttonState}
|
||||
onInteraction={args => ToolBarService.recordInteraction(args)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</>
|
||||
}
|
||||
|
||||
function ToolbarSecondary({ servicesManager }) {
|
||||
const { ToolBarService } = servicesManager.services;
|
||||
const defaultTool = {
|
||||
icon: 'tool-more-menu',
|
||||
label: 'More',
|
||||
isActive: false,
|
||||
};
|
||||
const [toolbars, setToolbars] = useState({ primary: [], secondary: [] });
|
||||
const [nestedActiveTool, setNestedActiveTool] = useState(defaultTool);
|
||||
|
||||
const setActiveToolHandler = (tool, isNested) => {
|
||||
setNestedActiveTool(isNested ? tool : defaultTool);
|
||||
};
|
||||
|
||||
const onPrimaryClickHandler = (evt, btn) => {
|
||||
if (
|
||||
btn.props &&
|
||||
btn.props.commands &&
|
||||
evt.item && evt.item.value &&
|
||||
btn.props.commands[evt.item.value]
|
||||
) {
|
||||
const { commandName, commandOptions } = btn.props.commands[evt.item.value];
|
||||
commandsManager.runCommand(commandName, commandOptions);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const { unsubscribe } = ToolBarService.subscribe(
|
||||
ToolBarService.EVENTS.TOOL_BAR_MODIFIED,
|
||||
() => {
|
||||
console.warn('~~~ TOOL BAR MODIFIED EVENT CAUGHT');
|
||||
const updatedToolbars = {
|
||||
primary: ToolBarService.getButtonSection('primary', {
|
||||
onClick: onPrimaryClickHandler,
|
||||
setActiveTool: setActiveToolHandler,
|
||||
}),
|
||||
secondary: ToolBarService.getButtonSection('secondary', {
|
||||
setActiveTool: setActiveToolHandler,
|
||||
}),
|
||||
};
|
||||
setToolbars(updatedToolbars);
|
||||
}
|
||||
);
|
||||
|
||||
return unsubscribe;
|
||||
}, [ToolBarService]);
|
||||
|
||||
return <>
|
||||
{toolbars.secondary.map(toolDef => {
|
||||
const { id, Component, componentProps } = toolDef;
|
||||
return <Component key={id} id={id} {...componentProps} />;
|
||||
})}
|
||||
</>
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ViewerLayout({
|
||||
@@ -158,25 +86,28 @@ function ViewerLayout({
|
||||
{
|
||||
title: t('Header:About'),
|
||||
icon: 'info',
|
||||
onClick: () => show({ content: AboutModal, title: 'About OHIF Viewer' })
|
||||
onClick: () => show({ content: AboutModal, title: 'About OHIF Viewer' }),
|
||||
},
|
||||
{
|
||||
title: t('Header:Preferences'),
|
||||
icon: 'settings',
|
||||
onClick: () => show({
|
||||
title: t('UserPreferencesModal:User Preferences'),
|
||||
content: UserPreferences,
|
||||
contentProps: {
|
||||
hotkeyDefaults: hotkeysManager.getValidHotkeyDefinitions(hotkeyDefaults),
|
||||
hotkeyDefinitions,
|
||||
onCancel: hide,
|
||||
onSubmit: ({ hotkeyDefinitions }) => {
|
||||
hotkeysManager.setHotkeys(hotkeyDefinitions);
|
||||
hide();
|
||||
onClick: () =>
|
||||
show({
|
||||
title: t('UserPreferencesModal:User Preferences'),
|
||||
content: UserPreferences,
|
||||
contentProps: {
|
||||
hotkeyDefaults: hotkeysManager.getValidHotkeyDefinitions(
|
||||
hotkeyDefaults
|
||||
),
|
||||
hotkeyDefinitions,
|
||||
onCancel: hide,
|
||||
onSubmit: ({ hotkeyDefinitions }) => {
|
||||
hotkeysManager.setHotkeys(hotkeyDefinitions);
|
||||
hide();
|
||||
},
|
||||
onReset: () => hotkeysManager.restoreDefaultBindings(),
|
||||
},
|
||||
onReset: () => hotkeysManager.restoreDefaultBindings()
|
||||
}
|
||||
})
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -226,7 +157,7 @@ function ViewerLayout({
|
||||
<Header menuOptions={menuOptions}>
|
||||
<ErrorBoundary context="Primary Toolbar">
|
||||
<div className="relative flex justify-center">
|
||||
<ToolbarPrimary servicesManager={servicesManager} />
|
||||
<Toolbar servicesManager={servicesManager} />
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
</Header>
|
||||
@@ -246,13 +177,6 @@ function ViewerLayout({
|
||||
)}
|
||||
{/* TOOLBAR + GRID */}
|
||||
<div className="flex flex-col flex-1 h-full">
|
||||
<div className="flex h-12 border-b border-transparent flex-2 w-100">
|
||||
<ErrorBoundary context="Secondary Toolbar">
|
||||
<div className="flex items-center w-full px-3 bg-primary-dark">
|
||||
<ToolbarSecondary servicesManager={servicesManager} />
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
<div className="flex items-center justify-center flex-1 h-full pt-1 pb-2 overflow-hidden bg-black">
|
||||
<ErrorBoundary context="Grid">
|
||||
<ViewportGridComp
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ToolbarButton } from '@ohif/ui';
|
||||
import ToolbarDivider from './Toolbar/ToolbarDivider.jsx';
|
||||
import ToolbarLayoutSelector from './Toolbar/ToolbarLayoutSelector.jsx';
|
||||
import ToolbarSplitButton from './Toolbar/ToolbarSplitButton.jsx';
|
||||
|
||||
export default function getToolbarModule({ commandsManager, servicesManager }) {
|
||||
const toolbarService = servicesManager.services.ToolBarService;
|
||||
@@ -9,65 +10,27 @@ export default function getToolbarModule({ commandsManager, servicesManager }) {
|
||||
{
|
||||
name: 'ohif.divider',
|
||||
defaultComponent: ToolbarDivider,
|
||||
clickHandler: () => { },
|
||||
clickHandler: () => {},
|
||||
},
|
||||
{
|
||||
name: 'ohif.action',
|
||||
defaultComponent: ToolbarButton,
|
||||
requiredConfig: [],
|
||||
optionalConfig: [],
|
||||
requiredProps: [],
|
||||
optionalProps: [],
|
||||
clickHandler: (evt, btn, btnSectionName) => {
|
||||
const { props } = btn;
|
||||
commandsManager.runCommand(props.commandName, props.commandOptions);
|
||||
},
|
||||
clickHandler: () => {},
|
||||
},
|
||||
{
|
||||
name: 'ohif.radioGroup',
|
||||
defaultComponent: ToolbarButton,
|
||||
requiredConfig: ['groupName'],
|
||||
optionalConfig: [],
|
||||
requiredProps: [],
|
||||
optionalProps: [],
|
||||
clickHandler: (evt, clickedBtn, btnSectionName, metadata, viewerProps) => {
|
||||
const { props } = clickedBtn;
|
||||
const allButtons = toolbarService.getButtons();
|
||||
|
||||
// Set all buttons in same group to inactive
|
||||
Object.keys(allButtons).forEach(btnName => {
|
||||
const btn = allButtons[btnName];
|
||||
const isRadioGroupBtn =
|
||||
btn.config &&
|
||||
btn.config.groupName &&
|
||||
btn.type === 'ohif.radioGroup';
|
||||
|
||||
if (
|
||||
isRadioGroupBtn &&
|
||||
clickedBtn.config.groupName === btn.config.groupName
|
||||
) {
|
||||
btn.props.isActive = false;
|
||||
|
||||
if (viewerProps.setActiveTool) {
|
||||
viewerProps.setActiveTool(props, metadata.isNested);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Set our clicked button to active
|
||||
allButtons[clickedBtn.id].props.isActive = true;
|
||||
|
||||
// Run button logic/command
|
||||
commandsManager.runCommand(props.commandName, props.commandOptions);
|
||||
|
||||
// Set buttons & trigger notification
|
||||
toolbarService.setButtons(allButtons);
|
||||
},
|
||||
clickHandler: () => {},
|
||||
},
|
||||
{
|
||||
name: 'ohif.splitButton',
|
||||
defaultComponent: ToolbarSplitButton,
|
||||
clickHandler: () => {},
|
||||
},
|
||||
{
|
||||
name: 'ohif.layoutSelector',
|
||||
defaultComponent: ToolbarLayoutSelector,
|
||||
clickHandler: (evt, clickedBtn, btnSectionName) => { },
|
||||
clickHandler: (evt, clickedBtn, btnSectionName) => {},
|
||||
},
|
||||
{
|
||||
name: 'ohif.toggle',
|
||||
|
||||
@@ -4,6 +4,7 @@ import cornerstoneTools from 'cornerstone-tools';
|
||||
import cornerstone from 'cornerstone-core';
|
||||
import CornerstoneViewport from 'react-cornerstone-viewport';
|
||||
import OHIF, { DicomMetadataStore, utils } from '@ohif/core';
|
||||
import DICOMSRDisplayTool from './tools/DICOMSRDisplayTool';
|
||||
import {
|
||||
Notification,
|
||||
ViewportActionBar,
|
||||
@@ -32,7 +33,11 @@ function OHIFCornerstoneSRViewport({
|
||||
servicesManager,
|
||||
extensionManager,
|
||||
}) {
|
||||
const { DisplaySetService, MeasurementService } = servicesManager.services;
|
||||
const {
|
||||
DisplaySetService,
|
||||
MeasurementService,
|
||||
ToolBarService,
|
||||
} = servicesManager.services;
|
||||
const [viewportGrid, viewportGridService] = useViewportGrid();
|
||||
const [viewportDialogState, viewportDialogApi] = useViewportDialog();
|
||||
const [measurementSelected, setMeasurementSelected] = useState(0);
|
||||
@@ -45,15 +50,19 @@ function OHIFCornerstoneSRViewport({
|
||||
|
||||
useEffect(() => {
|
||||
const onDisplaySetsRemovedSubscription = DisplaySetService.subscribe(
|
||||
DisplaySetService.EVENTS.DISPLAY_SETS_REMOVED, ({ displaySetInstanceUIDs }) => {
|
||||
DisplaySetService.EVENTS.DISPLAY_SETS_REMOVED,
|
||||
({ displaySetInstanceUIDs }) => {
|
||||
const activeViewport = viewports[activeViewportIndex];
|
||||
if (displaySetInstanceUIDs.includes(activeViewport.displaySetInstanceUID)) {
|
||||
if (
|
||||
displaySetInstanceUIDs.includes(activeViewport.displaySetInstanceUID)
|
||||
) {
|
||||
viewportGridService.setDisplaysetForViewport({
|
||||
viewportIndex: activeViewportIndex,
|
||||
displaySetInstanceUID: undefined,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return () => {
|
||||
onDisplaySetsRemovedSubscription.unsubscribe();
|
||||
@@ -64,6 +73,8 @@ function OHIFCornerstoneSRViewport({
|
||||
let trackedMeasurements;
|
||||
let sendTrackedMeasurementsEvent;
|
||||
|
||||
// TODO: this is a hook that fails if we register/de-register
|
||||
//
|
||||
if (
|
||||
extensionManager.registeredExtensionIds.includes(
|
||||
MEASUREMENT_TRACKING_EXTENSION_ID
|
||||
@@ -81,25 +92,89 @@ function OHIFCornerstoneSRViewport({
|
||||
] = useTrackedMeasurements();
|
||||
}
|
||||
|
||||
// Locked if tracking any series
|
||||
let isLocked = trackedMeasurements?.context?.trackedSeries?.length > 0;
|
||||
useEffect(() => {
|
||||
isLocked = trackedMeasurements?.context?.trackedSeries?.length > 0;
|
||||
}, [trackedMeasurements]);
|
||||
|
||||
function _getToolAlias() {
|
||||
const primaryToolId = ToolBarService.state.primaryToolId;
|
||||
let toolAlias = primaryToolId;
|
||||
|
||||
switch (primaryToolId) {
|
||||
case 'Length':
|
||||
toolAlias = 'SRLength';
|
||||
break;
|
||||
case 'Bidirectional':
|
||||
toolAlias = 'SRBidirectional';
|
||||
break;
|
||||
case 'ArrowAnnotate':
|
||||
toolAlias = 'SRArrowAnnotate';
|
||||
break;
|
||||
case 'EllipticalRoi':
|
||||
toolAlias = 'SREllipticalRoi';
|
||||
break;
|
||||
}
|
||||
|
||||
return toolAlias;
|
||||
}
|
||||
|
||||
const onElementEnabled = evt => {
|
||||
const eventData = evt.detail;
|
||||
const targetElement = eventData.element;
|
||||
const toolAlias = _getToolAlias(); // These are 1:1 for built-in only
|
||||
|
||||
// TODO -> This will only be temporary until we set a tool on, and isn't very customizable.
|
||||
// Need to discuss how to deal with tools in general in the redesign, since we
|
||||
// Previously just had Tool mode state global across the entire viewer.
|
||||
const globalTools = cornerstoneTools.store.state.globalTools;
|
||||
const globalToolNames = Object.keys(globalTools);
|
||||
|
||||
globalToolNames.forEach(globalToolName => {
|
||||
cornerstoneTools.setToolDisabledForElement(targetElement, globalToolName);
|
||||
});
|
||||
|
||||
// ~~ MAGIC
|
||||
cornerstoneTools.addToolForElement(targetElement, DICOMSRDisplayTool);
|
||||
cornerstoneTools.setToolEnabledForElement(
|
||||
targetElement,
|
||||
TOOL_NAMES.DICOM_SR_DISPLAY_TOOL
|
||||
);
|
||||
|
||||
// ~~ Variants
|
||||
cornerstoneTools.addToolForElement(
|
||||
targetElement,
|
||||
cornerstoneTools.LengthTool,
|
||||
{
|
||||
name: 'SRLength',
|
||||
configuration: {
|
||||
renderDashed: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
cornerstoneTools.addToolForElement(
|
||||
targetElement,
|
||||
cornerstoneTools.ArrowAnnotateTool,
|
||||
{
|
||||
name: 'SRArrowAnnotate',
|
||||
configuration: {
|
||||
renderDashed: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
cornerstoneTools.addToolForElement(
|
||||
targetElement,
|
||||
cornerstoneTools.BidirectionalTool,
|
||||
{
|
||||
name: 'SRBidirectional',
|
||||
configuration: {
|
||||
renderDashed: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
cornerstoneTools.addToolForElement(
|
||||
targetElement,
|
||||
cornerstoneTools.EllipticalRoiTool,
|
||||
{
|
||||
name: 'SREllipticalRoi',
|
||||
configuration: {
|
||||
renderDashed: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
// ~~ Business as usual
|
||||
cornerstoneTools.setToolActiveForElement(targetElement, 'PanMultiTouch', {
|
||||
pointers: 2,
|
||||
});
|
||||
@@ -109,7 +184,9 @@ function OHIFCornerstoneSRViewport({
|
||||
{}
|
||||
);
|
||||
|
||||
cornerstoneTools.setToolActiveForElement(targetElement, 'Wwwc', {
|
||||
// TODO: Add always dashed tool alternative aliases
|
||||
// TODO: or same name... alternative config?
|
||||
cornerstoneTools.setToolActiveForElement(targetElement, toolAlias, {
|
||||
mouseButtonMask: 1,
|
||||
});
|
||||
cornerstoneTools.setToolActiveForElement(targetElement, 'Pan', {
|
||||
@@ -131,6 +208,7 @@ function OHIFCornerstoneSRViewport({
|
||||
'ohif-cornerstone-enabled-element-event',
|
||||
{
|
||||
detail: {
|
||||
context: 'ACTIVE_VIEWPORT::STRUCTURED_REPORT',
|
||||
enabledElement: targetElement,
|
||||
viewportIndex,
|
||||
},
|
||||
@@ -262,7 +340,7 @@ function OHIFCornerstoneSRViewport({
|
||||
StudyDate,
|
||||
SeriesDescription,
|
||||
SeriesInstanceUID,
|
||||
PixelSpacing,
|
||||
SpacingBetweenSlices,
|
||||
SeriesNumber,
|
||||
displaySetInstanceUID,
|
||||
} = activeDisplaySetData;
|
||||
@@ -298,11 +376,19 @@ function OHIFCornerstoneSRViewport({
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
}}
|
||||
onPillClick={() => {
|
||||
sendTrackedMeasurementsEvent('PROMPT_HYDRATE_SR', {
|
||||
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
||||
viewportIndex,
|
||||
});
|
||||
}}
|
||||
onSeriesChange={onMeasurementChange}
|
||||
studyData={{
|
||||
label,
|
||||
useAltStyling: true,
|
||||
isTracked: false,
|
||||
isLocked: displaySet.isLocked,
|
||||
isLocked,
|
||||
isRehydratable: displaySet.isRehydratable,
|
||||
isHydrated,
|
||||
studyDate: formatDate(StudyDate),
|
||||
currentSeries: SeriesNumber,
|
||||
@@ -317,10 +403,8 @@ function OHIFCornerstoneSRViewport({
|
||||
MRN: PatientID || '',
|
||||
thickness: SliceThickness ? `${SliceThickness.toFixed(2)}mm` : '',
|
||||
spacing:
|
||||
PixelSpacing && PixelSpacing.length
|
||||
? `${PixelSpacing[0].toFixed(2)}mm x ${PixelSpacing[1].toFixed(
|
||||
2
|
||||
)}mm`
|
||||
SpacingBetweenSlices !== undefined
|
||||
? `${SpacingBetweenSlices.toFixed(2)}mm`
|
||||
: '',
|
||||
scanner: ManufacturerModelName || '',
|
||||
},
|
||||
@@ -458,7 +542,7 @@ async function _getViewportAndActiveDisplaySetData(
|
||||
SeriesInstanceUID: image0.SeriesInstanceUID,
|
||||
SeriesNumber: image0.SeriesNumber,
|
||||
ManufacturerModelName: image0.ManufacturerModelName,
|
||||
PixelSpacing: image0.PixelSpacing,
|
||||
SpacingBetweenSlices: image0.SpacingBetweenSlices,
|
||||
displaySetInstanceUID,
|
||||
};
|
||||
|
||||
|
||||
@@ -122,7 +122,9 @@ function _load(displaySet, servicesManager, extensionManager) {
|
||||
);
|
||||
|
||||
displaySet.isHydrated = false;
|
||||
displaySet.isLocked = isRehydratable(displaySet, mappings) ? false : true;
|
||||
displaySet.isRehydratable = isRehydratable(displaySet, mappings)
|
||||
? true
|
||||
: false;
|
||||
displaySet.isLoaded = true;
|
||||
|
||||
// Check currently added displaySets and add measurements if the sources exist.
|
||||
|
||||
@@ -60,6 +60,52 @@ export default {
|
||||
|
||||
return [{ name: 'dicom-sr', component: ExtendedOHIFCornerstoneSRViewport }];
|
||||
},
|
||||
getCommandsModule({ servicesManager }) {
|
||||
return {
|
||||
definitions: {
|
||||
setToolActive: {
|
||||
commandFn: ({ toolName, element }) => {
|
||||
if (!toolName) {
|
||||
console.warn('No toolname provided to setToolActive command');
|
||||
}
|
||||
|
||||
console.warn('DICOM SR VIEWPORT SETTOOLACTIVE');
|
||||
|
||||
// Set same tool or alt tool
|
||||
const toolAlias = _getToolAlias(toolName);
|
||||
|
||||
cornerstoneTools.setToolActiveForElement(element, toolAlias, {
|
||||
mouseButtonMask: 1,
|
||||
});
|
||||
},
|
||||
storeContexts: [],
|
||||
options: {},
|
||||
},
|
||||
},
|
||||
defaultContext: 'ACTIVE_VIEWPORT::STRUCTURED_REPORT',
|
||||
};
|
||||
},
|
||||
getSopClassHandlerModule,
|
||||
onModeEnter,
|
||||
};
|
||||
|
||||
function _getToolAlias(toolName) {
|
||||
let toolAlias = toolName;
|
||||
|
||||
switch (toolName) {
|
||||
case 'Length':
|
||||
toolAlias = 'SRLength';
|
||||
break;
|
||||
case 'Bidirectional':
|
||||
toolAlias = 'SRBidirectional';
|
||||
break;
|
||||
case 'ArrowAnnotate':
|
||||
toolAlias = 'SRArrowAnnotate';
|
||||
break;
|
||||
case 'EllipticalRoi':
|
||||
toolAlias = 'SREllipticalRoi';
|
||||
break;
|
||||
}
|
||||
|
||||
return toolAlias;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import cornerstoneTools from 'cornerstone-tools';
|
||||
import DICOMSRDisplayTool from './tools/DICOMSRDisplayTool';
|
||||
import dicomSRModule from './tools/modules/dicomSRModule';
|
||||
import id from './id';
|
||||
|
||||
@@ -20,6 +19,4 @@ export default function init({ configuration = {} }) {
|
||||
TOOL_NAMES.DICOM_SR_DISPLAY_TOOL = conifg.TOOL_NAMES.DICOM_SR_DISPLAY_TOOL;
|
||||
|
||||
cornerstoneTools.register('module', id, dicomSRModule);
|
||||
cornerstoneTools.addTool(DICOMSRDisplayTool);
|
||||
cornerstoneTools.setToolEnabled(TOOL_NAMES.DICOM_SR_DISPLAY_TOOL);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import csTools from 'cornerstone-tools';
|
||||
|
||||
const toolsGroupedByType = {
|
||||
touch: [csTools.PanMultiTouchTool, csTools.ZoomTouchPinchTool],
|
||||
annotations: [
|
||||
csTools.ArrowAnnotateTool,
|
||||
csTools.BidirectionalTool,
|
||||
csTools.LengthTool,
|
||||
csTools.AngleTool,
|
||||
csTools.FreehandRoiTool,
|
||||
csTools.EllipticalRoiTool,
|
||||
csTools.DragProbeTool,
|
||||
csTools.RectangleRoiTool,
|
||||
],
|
||||
other: [
|
||||
csTools.PanTool,
|
||||
csTools.ZoomTool,
|
||||
csTools.WwwcTool,
|
||||
csTools.WwwcRegionTool,
|
||||
csTools.MagnifyTool,
|
||||
csTools.StackScrollTool,
|
||||
csTools.StackScrollMouseWheelTool,
|
||||
csTools.OverlayTool,
|
||||
],
|
||||
};
|
||||
|
||||
export default function getTools() {
|
||||
const tools = [];
|
||||
Object.keys(toolsGroupedByType).forEach(toolsGroup =>
|
||||
tools.push(...toolsGroupedByType[toolsGroup])
|
||||
);
|
||||
|
||||
return tools;
|
||||
}
|
||||
|
||||
export { toolsGroupedByType };
|
||||
@@ -0,0 +1,21 @@
|
||||
import csTools from 'cornerstone-tools';
|
||||
|
||||
export default function _setActiveAndPassiveToolsForElement(element, tools) {
|
||||
const BaseAnnotationTool = csTools.importInternal('base/BaseAnnotationTool');
|
||||
|
||||
tools.forEach(tool => {
|
||||
if (tool.prototype instanceof BaseAnnotationTool) {
|
||||
// BaseAnnotationTool would likely come from csTools lib exports
|
||||
const toolName = new tool().name;
|
||||
csTools.setToolPassiveForElement(element, toolName); // there may be a better place to determine name; may not be on uninstantiated class
|
||||
}
|
||||
});
|
||||
|
||||
csTools.setToolActiveForElement(element, 'Pan', { mouseButtonMask: 4 });
|
||||
csTools.setToolActiveForElement(element, 'Zoom', { mouseButtonMask: 2 });
|
||||
csTools.setToolActiveForElement(element, 'Wwwc', { mouseButtonMask: 1 });
|
||||
csTools.setToolActiveForElement(element, 'StackScrollMouseWheel', {}); // TODO: Empty options should not be required
|
||||
csTools.setToolActiveForElement(element, 'PanMultiTouch', { pointers: 2 }); // TODO: Better error if no options
|
||||
csTools.setToolActiveForElement(element, 'ZoomTouchPinch', {});
|
||||
csTools.setToolEnabledForElement(element, 'Overlay', {});
|
||||
}
|
||||
+1
-1
@@ -141,7 +141,7 @@ function TrackedMeasurementsContextProvider(
|
||||
if (
|
||||
displaySet.SOPClassHandlerId ===
|
||||
'org.ohif.dicom-sr.sopClassHandlerModule.dicom-sr' &&
|
||||
!displaySet.isLocked
|
||||
displaySet.isRehydratable === true
|
||||
) {
|
||||
console.log('sending event...', trackedMeasurements);
|
||||
sendTrackedMeasurementsEvent('PROMPT_HYDRATE_SR', {
|
||||
|
||||
+33
-2
@@ -21,6 +21,8 @@ const machineConfiguration = {
|
||||
prevTrackedStudy: '',
|
||||
prevTrackedSeries: [],
|
||||
prevIgnoredSeries: [],
|
||||
//
|
||||
isDirty: false,
|
||||
},
|
||||
states: {
|
||||
off: {
|
||||
@@ -33,7 +35,7 @@ const machineConfiguration = {
|
||||
SET_TRACKED_SERIES: [
|
||||
{
|
||||
target: 'tracking',
|
||||
actions: ['setTrackedStudyAndMultipleSeries'],
|
||||
actions: ['setTrackedStudyAndMultipleSeries', 'setIsDirtyToClean'],
|
||||
},
|
||||
],
|
||||
PROMPT_HYDRATE_SR: 'promptHydrateStructuredReport',
|
||||
@@ -90,6 +92,16 @@ const machineConfiguration = {
|
||||
},
|
||||
],
|
||||
SAVE_REPORT: 'promptSaveReport',
|
||||
SET_DIRTY: [
|
||||
{
|
||||
target: 'tracking',
|
||||
actions: ['setIsDirty'],
|
||||
cond: 'shouldSetDirty',
|
||||
},
|
||||
{
|
||||
target: 'tracking',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
promptTrackNewSeries: {
|
||||
@@ -98,7 +110,7 @@ const machineConfiguration = {
|
||||
onDone: [
|
||||
{
|
||||
target: 'tracking',
|
||||
actions: ['addTrackedSeries'],
|
||||
actions: ['addTrackedSeries', 'setIsDirty'],
|
||||
cond: 'shouldAddSeries',
|
||||
},
|
||||
{
|
||||
@@ -106,6 +118,7 @@ const machineConfiguration = {
|
||||
actions: [
|
||||
'discardPreviouslyTrackedMeasurements',
|
||||
'setTrackedStudyAndSeries',
|
||||
'setIsDirty',
|
||||
],
|
||||
cond: 'shouldSetStudyAndSeries',
|
||||
},
|
||||
@@ -131,6 +144,7 @@ const machineConfiguration = {
|
||||
actions: [
|
||||
'discardPreviouslyTrackedMeasurements',
|
||||
'setTrackedStudyAndSeries',
|
||||
'setIsDirty',
|
||||
],
|
||||
cond: 'shouldSetStudyAndSeries',
|
||||
},
|
||||
@@ -197,6 +211,7 @@ const machineConfiguration = {
|
||||
actions: [
|
||||
'setTrackedStudyAndMultipleSeries',
|
||||
'showSeriesInActiveViewport',
|
||||
'setIsDirtyToClean',
|
||||
],
|
||||
cond: 'shouldHydrateStructuredReport',
|
||||
},
|
||||
@@ -274,6 +289,15 @@ const defaultOptions = {
|
||||
ignoredSeries: [],
|
||||
};
|
||||
}),
|
||||
setIsDirtyToClean: assign((ctx, evt) => ({
|
||||
isDirty: false,
|
||||
})),
|
||||
setIsDirty: assign((ctx, evt) => {
|
||||
debugger;
|
||||
return {
|
||||
isDirty: true,
|
||||
};
|
||||
}),
|
||||
ignoreSeries: assign((ctx, evt) => ({
|
||||
prevIgnoredSeries: [...ctx.ignoredSeries],
|
||||
ignoredSeries: [...ctx.ignoredSeries, evt.data.SeriesInstanceUID],
|
||||
@@ -292,6 +316,13 @@ const defaultOptions = {
|
||||
})),
|
||||
},
|
||||
guards: {
|
||||
shouldSetDirty: (ctx, evt) => {
|
||||
debugger;
|
||||
return (
|
||||
evt.SeriesInstanceUID === undefined ||
|
||||
ctx.trackedSeries.includes(evt.SeriesInstanceUID)
|
||||
);
|
||||
},
|
||||
shouldKillMachine: (ctx, evt) =>
|
||||
evt.data && evt.data.userResponse === RESPONSE.NO_NEVER,
|
||||
shouldAddSeries: (ctx, evt) =>
|
||||
|
||||
+3
-1
@@ -17,11 +17,13 @@ function promptUser({ servicesManager, extensionManager }, ctx, evt) {
|
||||
viewportIndex
|
||||
);
|
||||
|
||||
if (promptResult === RESPONSE.CREATE_REPORT) {
|
||||
if (ctx.isDirty && promptResult === RESPONSE.CREATE_REPORT) {
|
||||
promptResult = await _askSaveDiscardOrCancel(
|
||||
UIViewportDialogService,
|
||||
viewportIndex
|
||||
);
|
||||
} else {
|
||||
promptResult = RESPONSE.SET_STUDY_AND_SERIES;
|
||||
}
|
||||
|
||||
resolve({
|
||||
|
||||
+3
-1
@@ -17,11 +17,13 @@ function promptUser({ servicesManager, extensionManager }, ctx, evt) {
|
||||
viewportIndex
|
||||
);
|
||||
|
||||
if (promptResult === RESPONSE.SET_STUDY_AND_SERIES) {
|
||||
if (ctx.isDirty && promptResult === RESPONSE.SET_STUDY_AND_SERIES) {
|
||||
promptResult = await _askSaveDiscardOrCancel(
|
||||
UIViewportDialogService,
|
||||
viewportIndex
|
||||
);
|
||||
} else {
|
||||
promptResult = RESPONSE.SET_STUDY_AND_SERIES;
|
||||
}
|
||||
|
||||
resolve({
|
||||
|
||||
@@ -10,4 +10,25 @@ export default {
|
||||
getContextModule,
|
||||
getPanelModule,
|
||||
getViewportModule,
|
||||
getCommandsModule({ servicesManager }) {
|
||||
return {
|
||||
definitions: {
|
||||
setToolActive: {
|
||||
commandFn: ({ toolName, element }) => {
|
||||
if (!toolName) {
|
||||
console.warn('No toolname provided to setToolActive command');
|
||||
}
|
||||
|
||||
// Set same tool or alt tool
|
||||
cornerstoneTools.setToolActiveForElement(element, toolName, {
|
||||
mouseButtonMask: 1,
|
||||
});
|
||||
},
|
||||
storeContexts: [],
|
||||
options: {},
|
||||
},
|
||||
},
|
||||
defaultContext: 'ACTIVE_VIEWPORT::TRACKED',
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -361,8 +361,11 @@ function _getOneBasedImageIdIndex(displaySets, SOPInstanceUID) {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} points
|
||||
* @param {*} measurement
|
||||
* @param {*} pixelSpacing
|
||||
* @param {*} seriesNumber
|
||||
* @param {*} instanceNumber
|
||||
* @param {*} types
|
||||
*/
|
||||
function _getDisplayText(
|
||||
measurement,
|
||||
|
||||
+28
-17
@@ -1,7 +1,12 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { utils } from '@ohif/core';
|
||||
import { StudyBrowser, useImageViewer, useViewportGrid, Dialog } from '@ohif/ui';
|
||||
import {
|
||||
StudyBrowser,
|
||||
useImageViewer,
|
||||
useViewportGrid,
|
||||
Dialog,
|
||||
} from '@ohif/ui';
|
||||
import { useTrackedMeasurements } from '../../getContextModule';
|
||||
|
||||
const { formatDate } = utils;
|
||||
@@ -63,6 +68,7 @@ function PanelStudyBrowserTracking({
|
||||
referenceStudyUID: StudyInstanceUID,
|
||||
} = measurement;
|
||||
|
||||
sendTrackedMeasurementsEvent('SET_DIRTY', { SeriesInstanceUID });
|
||||
sendTrackedMeasurementsEvent('TRACK_SERIES', {
|
||||
viewportIndex: activeViewportIndex,
|
||||
StudyInstanceUID,
|
||||
@@ -238,10 +244,10 @@ function PanelStudyBrowserTracking({
|
||||
);
|
||||
const updatedExpandedStudyInstanceUIDs = shouldCollapseStudy
|
||||
? [
|
||||
...expandedStudyInstanceUIDs.filter(
|
||||
stdyUid => stdyUid !== StudyInstanceUID
|
||||
),
|
||||
]
|
||||
...expandedStudyInstanceUIDs.filter(
|
||||
stdyUid => stdyUid !== StudyInstanceUID
|
||||
),
|
||||
]
|
||||
: [...expandedStudyInstanceUIDs, StudyInstanceUID];
|
||||
|
||||
setExpandedStudyInstanceUIDs(updatedExpandedStudyInstanceUIDs);
|
||||
@@ -315,7 +321,7 @@ function PanelStudyBrowserTracking({
|
||||
SeriesInstanceUID: displaySet.SeriesInstanceUID,
|
||||
});
|
||||
}}
|
||||
onClickThumbnail={() => { }}
|
||||
onClickThumbnail={() => {}}
|
||||
onDoubleClickThumbnail={onDoubleClickThumbnailHandler}
|
||||
activeDisplaySetInstanceUID={activeDisplaySetInstanceUID}
|
||||
/>
|
||||
@@ -385,11 +391,11 @@ function _mapDisplaySets(
|
||||
const viewportIdentificator = isSingleViewport
|
||||
? []
|
||||
: viewports.reduce((acc, viewportData, index) => {
|
||||
if (viewportData.displaySetInstanceUID === ds.displaySetInstanceUID) {
|
||||
acc.push(_viewportLabels[index]);
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
if (viewportData.displaySetInstanceUID === ds.displaySetInstanceUID) {
|
||||
acc.push(_viewportLabels[index]);
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
const array =
|
||||
componentType === 'thumbnailTracked'
|
||||
@@ -430,7 +436,7 @@ function _mapDisplaySets(
|
||||
contentProps: {
|
||||
title: 'Reject Report',
|
||||
body: () => (
|
||||
<div className="p-4 bg-primary-dark text-white">
|
||||
<div className="p-4 text-white bg-primary-dark">
|
||||
<p>This is a destructive action.</p>
|
||||
<p>Are you sure you want to continue?</p>
|
||||
</div>
|
||||
@@ -444,7 +450,10 @@ function _mapDisplaySets(
|
||||
switch (action.id) {
|
||||
case 'save':
|
||||
try {
|
||||
await dataSource.reject.series(ds.StudyInstanceUID, ds.SeriesInstanceUID);
|
||||
await dataSource.reject.series(
|
||||
ds.StudyInstanceUID,
|
||||
ds.SeriesInstanceUID
|
||||
);
|
||||
DisplaySetService.deleteDisplaySet(displaySetInstanceUID);
|
||||
UIDialogService.dismiss({ id: 'ds-reject-sr' });
|
||||
UINotificationService.show({
|
||||
@@ -525,9 +534,11 @@ function _createStudyBrowserTabs(
|
||||
const displaySetsForStudy = displaySets.filter(
|
||||
ds => ds.StudyInstanceUID === study.studyInstanceUid
|
||||
);
|
||||
|
||||
// Sort them
|
||||
const sortedDisplaySetsForStudy = utils.sortBySeriesDate(displaySetsForStudy);
|
||||
|
||||
// Sort them
|
||||
const sortedDisplaySetsForStudy = utils.sortBySeriesDate(
|
||||
displaySetsForStudy
|
||||
);
|
||||
|
||||
/* Sort by series number, then by series date
|
||||
displaySetsForStudy.sort((a, b) => {
|
||||
@@ -541,7 +552,7 @@ function _createStudyBrowserTabs(
|
||||
return seriesDateA - seriesDateB;
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
// Map the study to it's tab/view representation
|
||||
const tabStudy = Object.assign({}, study, {
|
||||
displaySets: displaySetsForStudy,
|
||||
|
||||
@@ -16,6 +16,8 @@ import { useTrackedMeasurements } from './../getContextModule';
|
||||
import ViewportOverlay from './ViewportOverlay';
|
||||
import ViewportLoadingIndicator from './ViewportLoadingIndicator';
|
||||
import setCornerstoneMeasurementActive from '../_shared/setCornerstoneMeasurementActive';
|
||||
import setActiveAndPassiveToolsForElement from '../_shared/setActiveAndPassiveToolsForElement';
|
||||
import getTools from '../_shared/getTools';
|
||||
|
||||
const scrollToIndex = cornerstoneTools.importInternal('util/scrollToIndex');
|
||||
const { formatDate } = utils;
|
||||
@@ -44,7 +46,7 @@ function TrackedCornerstoneViewport({
|
||||
displaySet,
|
||||
viewportIndex,
|
||||
servicesManager,
|
||||
commandsManager
|
||||
commandsManager,
|
||||
}) {
|
||||
const {
|
||||
ToolBarService,
|
||||
@@ -52,7 +54,10 @@ function TrackedCornerstoneViewport({
|
||||
MeasurementService,
|
||||
} = servicesManager.services;
|
||||
const [trackedMeasurements] = useTrackedMeasurements();
|
||||
const [{ activeViewportIndex, viewports }, viewportGridService] = useViewportGrid();
|
||||
const [
|
||||
{ activeViewportIndex, viewports },
|
||||
viewportGridService,
|
||||
] = useViewportGrid();
|
||||
const [{ isCineEnabled, cines }, cineService] = useCine();
|
||||
const [viewportDialogState, viewportDialogApi] = useViewportDialog();
|
||||
const [viewportData, setViewportData] = useState(null);
|
||||
@@ -126,9 +131,17 @@ function TrackedCornerstoneViewport({
|
||||
const onElementEnabled = evt => {
|
||||
const eventData = evt.detail;
|
||||
const targetElement = eventData.element;
|
||||
const tools = getTools();
|
||||
const toolAlias = ToolBarService.state.primaryToolId;
|
||||
|
||||
// Activate appropriate tool bindings for element
|
||||
setActiveAndPassiveToolsForElement(targetElement, tools);
|
||||
cornerstoneTools.setToolActiveForElement(targetElement, toolAlias, {
|
||||
mouseButtonMask: 1,
|
||||
});
|
||||
|
||||
// Set dashed, based on tracking, for this viewport
|
||||
const allTools = cornerstoneTools.store.state.tools;
|
||||
|
||||
const toolsForElement = allTools.filter(
|
||||
tool => tool.element === targetElement
|
||||
);
|
||||
@@ -154,6 +167,7 @@ function TrackedCornerstoneViewport({
|
||||
}
|
||||
});
|
||||
|
||||
// Update image after setting tool config
|
||||
const enabledElement = cornerstone.getEnabledElement(targetElement);
|
||||
|
||||
if (enabledElement.image) {
|
||||
@@ -166,6 +180,7 @@ function TrackedCornerstoneViewport({
|
||||
'ohif-cornerstone-enabled-element-event',
|
||||
{
|
||||
detail: {
|
||||
context: 'ACTIVE_VIEWPORT::TRACKED',
|
||||
enabledElement: targetElement,
|
||||
viewportIndex,
|
||||
},
|
||||
@@ -256,7 +271,7 @@ function TrackedCornerstoneViewport({
|
||||
PatientSex,
|
||||
PatientAge,
|
||||
SliceThickness,
|
||||
PixelSpacing,
|
||||
SpacingBetweenSlices,
|
||||
ManufacturerModelName,
|
||||
} = displaySet.images[0];
|
||||
|
||||
@@ -300,8 +315,8 @@ function TrackedCornerstoneViewport({
|
||||
}
|
||||
|
||||
const cine = cines[viewportIndex];
|
||||
const isPlaying = cine && cine.isPlaying || false;
|
||||
const frameRate = cine && cine.frameRate || 24;
|
||||
const isPlaying = (cine && cine.isPlaying) || false;
|
||||
const frameRate = (cine && cine.frameRate) || 24;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -315,6 +330,7 @@ function TrackedCornerstoneViewport({
|
||||
label,
|
||||
isTracked,
|
||||
isLocked: false,
|
||||
isRehydratable: false,
|
||||
studyDate: formatDate(SeriesDate), // TODO: This is series date. Is that ok?
|
||||
currentSeries: SeriesNumber,
|
||||
seriesDescription: SeriesDescription,
|
||||
@@ -328,10 +344,8 @@ function TrackedCornerstoneViewport({
|
||||
MRN: PatientID || '',
|
||||
thickness: SliceThickness ? `${SliceThickness.toFixed(2)}mm` : '',
|
||||
spacing:
|
||||
PixelSpacing && PixelSpacing.length
|
||||
? `${PixelSpacing[0].toFixed(2)}mm x ${PixelSpacing[1].toFixed(
|
||||
2
|
||||
)}mm`
|
||||
SpacingBetweenSlices !== undefined
|
||||
? `${SpacingBetweenSlices.toFixed(2)}mm`
|
||||
: '',
|
||||
scanner: ManufacturerModelName || '',
|
||||
},
|
||||
@@ -341,8 +355,10 @@ function TrackedCornerstoneViewport({
|
||||
cineProps={{
|
||||
isPlaying,
|
||||
onClose: () => commandsManager.runCommand('toggleCine'),
|
||||
onPlayPauseChange: isPlaying => cineService.setCine({ id: activeViewportIndex, isPlaying }),
|
||||
onFrameRateChange: frameRate => cineService.setCine({ id: activeViewportIndex, frameRate }),
|
||||
onPlayPauseChange: isPlaying =>
|
||||
cineService.setCine({ id: activeViewportIndex, isPlaying }),
|
||||
onFrameRateChange: frameRate =>
|
||||
cineService.setCine({ id: activeViewportIndex, frameRate }),
|
||||
}}
|
||||
/>
|
||||
{/* TODO: Viewport interface to accept stack or layers of content like this? */}
|
||||
|
||||
Reference in new issue
Block a user