2019-05-31 16:25:10 -04:00
|
|
|
import { redux } from 'ohif-core';
|
2019-06-02 22:43:04 -04:00
|
|
|
import store from './../store';
|
2019-05-31 16:25:10 -04:00
|
|
|
const { setViewportActive } = redux.actions;
|
|
|
|
|
|
|
|
|
|
const actions = {
|
|
|
|
|
updateViewportDisplaySet: ({ direction }) => {
|
|
|
|
|
// TODO
|
|
|
|
|
console.warn('updateDisplaySet: ', direction);
|
|
|
|
|
},
|
|
|
|
|
updateActiveViewport: ({ viewports, direction }) => {
|
|
|
|
|
const { viewportSpecificData, activeViewportIndex } = viewports;
|
|
|
|
|
const maxIndex = Object.keys(viewportSpecificData).length - 1;
|
|
|
|
|
|
|
|
|
|
let newIndex = activeViewportIndex + direction;
|
|
|
|
|
newIndex = newIndex > maxIndex ? 0 : newIndex;
|
|
|
|
|
newIndex = newIndex < 0 ? maxIndex : newIndex;
|
|
|
|
|
|
|
|
|
|
store.dispatch(setViewportActive(newIndex));
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-02 22:43:04 -04:00
|
|
|
const definitions = {
|
|
|
|
|
// Next/Previous active viewport
|
|
|
|
|
incrementActiveViewport: {
|
|
|
|
|
commandFn: actions.updateActiveViewport,
|
|
|
|
|
storeContexts: ['viewports'],
|
|
|
|
|
options: { direction: 1 },
|
|
|
|
|
},
|
|
|
|
|
decrementActiveViewport: {
|
|
|
|
|
commandFn: actions.updateActiveViewport,
|
|
|
|
|
storeContexts: ['viewports'],
|
|
|
|
|
options: { direction: -1 },
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-31 16:25:10 -04:00
|
|
|
export default definitions;
|