* Snapshot -- Switching branches * fix classes and hooks for panel componet * Restore button functionality * feat: support for expandableToolMenu * Shift cornerstoneTools config up a layer, and use globalToolSync * Remaining initCornerstoneTools changes * Pull in Segmentation Plugin * Shift MeasurementsPanel to an extension * Note regarding where data is coming from * Make sure measurement callback is available * Bump core version * Shift MeasurementsTable to a local extensions directory * Register appCommands as an extension * Update package dependencies and yarn lock * Support for panel width * Ability to pass props to our panel component * Add a safety check around calling our tacked on method for tool options * Left sidebar plugins + fix activeIndex prop passed to sidebar. * fix: viewer height Now in a shared container w/ top bar, so we need to factor that in when calculating height * lock file latest * Update thumbnails if studies has changes * bump cornerstone version to resolve globalToolSynch history issue * Default panel to open; studies optional * Bump minor version for ohif-cornestone-extension * Simplify button logic * Accommodate odd roundedButtonGroup value change emit * Map viewers + selectedViewport instead of pulling off the window
235 lines
6.1 KiB
JavaScript
235 lines
6.1 KiB
JavaScript
import OHIF from 'ohif-core';
|
|
import updateTableWithNewMeasurementData from './lib/updateTableWithNewMeasurementData';
|
|
|
|
function getToolLabellingFlowCallback(store) {
|
|
const setLabellingFlowDataAction = labellingFlowData => ({
|
|
type: 'SET_LABELLING_FLOW_DATA',
|
|
labellingFlowData,
|
|
});
|
|
|
|
const setLabellingFlowData = labellingFlowData => {
|
|
store.dispatch(setLabellingFlowDataAction(labellingFlowData));
|
|
};
|
|
|
|
return function toolLabellingFlowCallback(
|
|
measurementData,
|
|
eventData,
|
|
doneCallback,
|
|
options = {}
|
|
) {
|
|
const updateLabelling = ({ location, response, description }) => {
|
|
// Update the measurement data with the labelling parameters
|
|
|
|
if (location) {
|
|
measurementData.location = location;
|
|
}
|
|
if (description) {
|
|
measurementData.description = description;
|
|
}
|
|
if (response) {
|
|
measurementData.response = response;
|
|
}
|
|
|
|
updateTableWithNewMeasurementData(measurementData);
|
|
};
|
|
|
|
const labellingDoneCallback = () => {
|
|
setLabellingFlowData({ visible: false });
|
|
};
|
|
|
|
const labellingFlowData = {
|
|
visible: true,
|
|
eventData,
|
|
measurementData,
|
|
skipAddLabelButton: options.skipAddLabelButton,
|
|
editLocation: options.editLocation,
|
|
editDescription: options.editDescription,
|
|
editResponse: options.editResponse,
|
|
editDescriptionOnDialog: options.editDescriptionOnDialog,
|
|
labellingDoneCallback,
|
|
updateLabelling,
|
|
};
|
|
|
|
setLabellingFlowData(labellingFlowData);
|
|
};
|
|
}
|
|
|
|
const resetLabellingAndContextMenuAction = state => ({
|
|
type: 'RESET_LABELLING_AND_CONTEXT_MENU',
|
|
state,
|
|
});
|
|
|
|
const setToolContextMenuDataAction = (viewportIndex, toolContextMenuData) => ({
|
|
type: 'SET_TOOL_CONTEXT_MENU_DATA',
|
|
viewportIndex,
|
|
toolContextMenuData,
|
|
});
|
|
|
|
function getOnRightClickCallback(store) {
|
|
const setToolContextMenuData = (viewportIndex, toolContextMenuData) => {
|
|
store.dispatch(resetLabellingAndContextMenuAction());
|
|
store.dispatch(
|
|
setToolContextMenuDataAction(viewportIndex, toolContextMenuData)
|
|
);
|
|
};
|
|
|
|
const getOnCloseCallback = viewportIndex => {
|
|
return function onClose() {
|
|
const toolContextMenuData = {
|
|
visible: false,
|
|
};
|
|
|
|
store.dispatch(
|
|
setToolContextMenuDataAction(viewportIndex, toolContextMenuData)
|
|
);
|
|
};
|
|
};
|
|
|
|
return function onRightClick(event) {
|
|
const eventData = event.detail;
|
|
const viewportIndex = parseInt(eventData.element.dataset.viewportIndex, 10);
|
|
|
|
const toolContextMenuData = {
|
|
eventData,
|
|
isTouchEvent: false,
|
|
onClose: getOnCloseCallback(viewportIndex),
|
|
};
|
|
|
|
setToolContextMenuData(viewportIndex, toolContextMenuData);
|
|
};
|
|
}
|
|
|
|
function getOnTouchPressCallback(store) {
|
|
const setToolContextMenuData = (viewportIndex, toolContextMenuData) => {
|
|
store.dispatch(resetLabellingAndContextMenuAction());
|
|
store.dispatch(
|
|
setToolContextMenuDataAction(viewportIndex, toolContextMenuData)
|
|
);
|
|
};
|
|
|
|
const getOnCloseCallback = viewportIndex => {
|
|
return function onClose() {
|
|
const toolContextMenuData = {
|
|
visible: false,
|
|
};
|
|
|
|
store.dispatch(
|
|
setToolContextMenuDataAction(viewportIndex, toolContextMenuData)
|
|
);
|
|
};
|
|
};
|
|
|
|
return function onTouchPress(event) {
|
|
const eventData = event.detail;
|
|
const viewportIndex = parseInt(eventData.element.dataset.viewportIndex, 10);
|
|
|
|
const toolContextMenuData = {
|
|
eventData,
|
|
isTouchEvent: true,
|
|
onClose: getOnCloseCallback(viewportIndex),
|
|
};
|
|
|
|
setToolContextMenuData(viewportIndex, toolContextMenuData);
|
|
};
|
|
}
|
|
|
|
function getResetLabellingAndContextMenu(store) {
|
|
return function resetLabellingAndContextMenu() {
|
|
store.dispatch(resetLabellingAndContextMenuAction());
|
|
};
|
|
}
|
|
|
|
export default function setupTools(store) {
|
|
const toolLabellingFlowCallback = getToolLabellingFlowCallback(store);
|
|
const availableTools = [
|
|
{ name: 'Pan', mouseButtonMasks: [1, 4] },
|
|
{ name: 'Zoom', mouseButtonMasks: [1, 2] },
|
|
{ name: 'Wwwc', mouseButtonMasks: [1] },
|
|
{
|
|
name: 'Bidirectional',
|
|
props: {
|
|
configuration: {
|
|
getMeasurementLocationCallback: toolLabellingFlowCallback,
|
|
},
|
|
},
|
|
mouseButtonMasks: [1],
|
|
},
|
|
{
|
|
name: 'Length',
|
|
props: {
|
|
configuration: {
|
|
getMeasurementLocationCallback: toolLabellingFlowCallback,
|
|
},
|
|
},
|
|
mouseButtonMasks: [1],
|
|
},
|
|
{
|
|
name: 'Angle',
|
|
props: {
|
|
configuration: {
|
|
getMeasurementLocationCallback: toolLabellingFlowCallback,
|
|
},
|
|
},
|
|
mouseButtonMasks: [1],
|
|
},
|
|
{ name: 'StackScroll', mouseButtonMasks: [1] },
|
|
{ name: 'Brush', mouseButtonMasks: [1] },
|
|
{
|
|
name: 'FreehandMouse',
|
|
configuration: {
|
|
configuration: {
|
|
getMeasurementLocationCallback: toolLabellingFlowCallback,
|
|
},
|
|
},
|
|
mouseButtonMasks: [1],
|
|
},
|
|
{
|
|
name: 'EllipticalRoi',
|
|
props: {
|
|
configuration: {
|
|
getMeasurementLocationCallback: toolLabellingFlowCallback,
|
|
},
|
|
},
|
|
mouseButtonMasks: [1],
|
|
},
|
|
{
|
|
name: 'CircleRoi',
|
|
props: {
|
|
configuration: {
|
|
getMeasurementLocationCallback: toolLabellingFlowCallback,
|
|
},
|
|
},
|
|
mouseButtonMasks: [1],
|
|
},
|
|
{
|
|
name: 'RectangleRoi',
|
|
props: {
|
|
configuration: {
|
|
getMeasurementLocationCallback: toolLabellingFlowCallback,
|
|
},
|
|
},
|
|
mouseButtonMasks: [1],
|
|
},
|
|
{ name: 'PanMultiTouch' },
|
|
{ name: 'ZoomTouchPinch' },
|
|
{ name: 'StackScrollMouseWheel' },
|
|
{ name: 'StackScrollMultiTouch' },
|
|
];
|
|
|
|
const onRightClick = getOnRightClickCallback(store);
|
|
const onTouchPress = getOnTouchPressCallback(store);
|
|
const onNewImage = getResetLabellingAndContextMenu(store);
|
|
const onMouseClick = getResetLabellingAndContextMenu(store);
|
|
const onTouchStart = getResetLabellingAndContextMenu(store);
|
|
const toolAction = OHIF.redux.actions.setExtensionData('cornerstone', {
|
|
availableTools,
|
|
onNewImage,
|
|
onRightClick,
|
|
onTouchPress,
|
|
onTouchStart,
|
|
onMouseClick,
|
|
});
|
|
|
|
store.dispatch(toolAction);
|
|
}
|