Shift commands to appropriate extension

This commit is contained in:
dannyrb 2019-06-13 09:50:07 -04:00
parent 59c6c4dc34
commit 0318203770

View File

@ -1,8 +1,12 @@
import cornerstone from 'cornerstone-core'; import cornerstone from 'cornerstone-core';
import { redux } from 'ohif-core';
import store from './../store/';
const { setToolActive } = redux.actions; // TODO: Just emit the tool's name?
// TODO: Let local context handle the active tool propogation to redux?
// import { redux } from 'ohif-core';
// import store from './../store/';
// const { setToolActive } = redux.actions;
const actions = { const actions = {
rotateViewport: ({ viewports, rotation }) => { rotateViewport: ({ viewports, rotation }) => {
@ -85,7 +89,8 @@ const actions = {
// the `toolName` needs to equal the button's `command` property. // the `toolName` needs to equal the button's `command` property.
// NOTE: It would be nice if `hotkeys` could set this, instead of creating a command per tool // NOTE: It would be nice if `hotkeys` could set this, instead of creating a command per tool
setCornerstoneToolActive: ({ toolName }) => { setCornerstoneToolActive: ({ toolName }) => {
store.dispatch(setToolActive(toolName)); console.warn(toolName);
// store.dispatch(setToolActive(toolName));
}, },
updateViewportDisplaySet: ({ direction }) => { updateViewportDisplaySet: ({ direction }) => {
// TODO // TODO
@ -100,56 +105,56 @@ const actions = {
// if (!cornerstoneImageId || cornerstoneImageId === imageId) // if (!cornerstoneImageId || cornerstoneImageId === imageId)
// delete toolState[imageId]; // delete toolState[imageId];
// }); // });
}, }
}; };
const definitions = { const definitions = {
rotateViewportCW: { rotateViewportCW: {
commandFn: actions.rotateViewport, commandFn: actions.rotateViewport,
storeContexts: ['viewports'], storeContexts: ['viewports'],
options: { rotation: 90 }, options: { rotation: 90 }
}, },
rotateViewportCCW: { rotateViewportCCW: {
commandFn: actions.rotateViewport, commandFn: actions.rotateViewport,
storeContexts: ['viewports'], storeContexts: ['viewports'],
options: { rotation: -90 }, options: { rotation: -90 }
}, },
invertViewport: { invertViewport: {
commandFn: actions.invertViewport, commandFn: actions.invertViewport,
storeContexts: ['viewports'], storeContexts: ['viewports'],
options: {}, options: {}
}, },
flipViewportVertical: { flipViewportVertical: {
commandFn: actions.flipViewportVertical, commandFn: actions.flipViewportVertical,
storeContexts: ['viewports'], storeContexts: ['viewports'],
options: {}, options: {}
}, },
flipViewportHorizontal: { flipViewportHorizontal: {
commandFn: actions.flipViewportHorizontal, commandFn: actions.flipViewportHorizontal,
storeContexts: ['viewports'], storeContexts: ['viewports'],
options: {}, options: {}
}, },
scaleUpViewport: { scaleUpViewport: {
keys: '', keys: '',
commandFn: actions.scaleViewport, commandFn: actions.scaleViewport,
storeContexts: ['viewports'], storeContexts: ['viewports'],
options: { direction: 1 }, options: { direction: 1 }
}, },
scaleDownViewport: { scaleDownViewport: {
keys: '', keys: '',
commandFn: actions.scaleViewport, commandFn: actions.scaleViewport,
storeContexts: ['viewports'], storeContexts: ['viewports'],
options: { direction: -1 }, options: { direction: -1 }
}, },
fitViewportToWindow: { fitViewportToWindow: {
commandFn: actions.scaleViewport, commandFn: actions.scaleViewport,
storeContexts: ['viewports'], storeContexts: ['viewports'],
options: { direction: 0 }, options: { direction: 0 }
}, },
resetViewport: { resetViewport: {
commandFn: actions.resetViewport, commandFn: actions.resetViewport,
storeContexts: ['viewports'], storeContexts: ['viewports'],
options: {}, options: {}
}, },
// TODO: Clear Annotations // TODO: Clear Annotations
// TODO: Next/Previous image // TODO: Next/Previous image
@ -158,19 +163,19 @@ const definitions = {
nextViewportDisplaySet: { nextViewportDisplaySet: {
commandFn: actions.updateViewportDisplaySet, commandFn: actions.updateViewportDisplaySet,
storeContexts: [], storeContexts: [],
options: { direction: 1 }, options: { direction: 1 }
}, },
previousViewportDisplaySet: { previousViewportDisplaySet: {
commandFn: actions.updateViewportDisplaySet, commandFn: actions.updateViewportDisplaySet,
storeContexts: [], storeContexts: [],
options: { direction: -1 }, options: { direction: -1 }
}, },
// TOOLS // TOOLS
setZoomTool: { setZoomTool: {
commandFn: actions.setCornerstoneToolActive, commandFn: actions.setCornerstoneToolActive,
storeContexts: [], storeContexts: [],
options: { toolName: 'Zoom' }, options: { toolName: 'Zoom' }
}, }
}; };
/** /**
@ -182,4 +187,7 @@ function _getActiveViewportEnabledElement(viewports, activeIndex) {
return activeViewport.dom; return activeViewport.dom;
} }
export default definitions; export default {
actions,
definitions
};