Switch folder; dependency injection; note about moving to extensions
This commit is contained in:
parent
b0706e5544
commit
c1f8984c1b
@ -1,69 +1,5 @@
|
|||||||
import cornerstone from 'cornerstone-core';
|
import cornerstone from 'cornerstone-core';
|
||||||
|
|
||||||
const definitions = {
|
|
||||||
rotateViewportCW: {
|
|
||||||
commandFn: actions.rotateViewport,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: { rotation: 90 },
|
|
||||||
},
|
|
||||||
rotateViewportCCW: {
|
|
||||||
commandFn: actions.rotateViewport,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: { rotation: -90 },
|
|
||||||
},
|
|
||||||
invertViewport: {
|
|
||||||
commandFn: actions.invertViewport,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: {},
|
|
||||||
},
|
|
||||||
flipViewportVertical: {
|
|
||||||
commandFn: actions.flipViewportVertical,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: {},
|
|
||||||
},
|
|
||||||
flipViewportHorizontal: {
|
|
||||||
commandFn: actions.flipViewportHorizontal,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: {},
|
|
||||||
},
|
|
||||||
scaleUpViewport: {
|
|
||||||
keys: '',
|
|
||||||
commandFn: actions.scaleViewport,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: { direction: 1 },
|
|
||||||
},
|
|
||||||
scaleDownViewport: {
|
|
||||||
keys: '',
|
|
||||||
commandFn: actions.scaleViewport,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: { direction: -1 },
|
|
||||||
},
|
|
||||||
fitViewportToWindow: {
|
|
||||||
commandFn: actions.scaleViewport,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: { direction: 0 },
|
|
||||||
},
|
|
||||||
resetViewport: {
|
|
||||||
commandFn: actions.resetViewport,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: {},
|
|
||||||
},
|
|
||||||
// TODO: Clear Annotations
|
|
||||||
// TODO: Next/Previous image
|
|
||||||
// TODO: First/Last image
|
|
||||||
// Next/Previous series/DisplaySet
|
|
||||||
nextViewportDisplaySet: {
|
|
||||||
commandFn: actions.updateViewportDisplaySet,
|
|
||||||
storeContexts: [],
|
|
||||||
options: { direction: 1 },
|
|
||||||
},
|
|
||||||
previousViewportDisplaySet: {
|
|
||||||
commandFn: actions.updateViewportDisplaySet,
|
|
||||||
storeContexts: [],
|
|
||||||
options: { direction: 1 },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
rotateViewport: ({ viewports, rotation }) => {
|
rotateViewport: ({ viewports, rotation }) => {
|
||||||
const enabledElement = _getActiveViewportEnabledElement(
|
const enabledElement = _getActiveViewportEnabledElement(
|
||||||
@ -157,6 +93,70 @@ const actions = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const definitions = {
|
||||||
|
rotateViewportCW: {
|
||||||
|
commandFn: actions.rotateViewport,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: { rotation: 90 },
|
||||||
|
},
|
||||||
|
rotateViewportCCW: {
|
||||||
|
commandFn: actions.rotateViewport,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: { rotation: -90 },
|
||||||
|
},
|
||||||
|
invertViewport: {
|
||||||
|
commandFn: actions.invertViewport,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
flipViewportVertical: {
|
||||||
|
commandFn: actions.flipViewportVertical,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
flipViewportHorizontal: {
|
||||||
|
commandFn: actions.flipViewportHorizontal,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
scaleUpViewport: {
|
||||||
|
keys: '',
|
||||||
|
commandFn: actions.scaleViewport,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: { direction: 1 },
|
||||||
|
},
|
||||||
|
scaleDownViewport: {
|
||||||
|
keys: '',
|
||||||
|
commandFn: actions.scaleViewport,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: { direction: -1 },
|
||||||
|
},
|
||||||
|
fitViewportToWindow: {
|
||||||
|
commandFn: actions.scaleViewport,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: { direction: 0 },
|
||||||
|
},
|
||||||
|
resetViewport: {
|
||||||
|
commandFn: actions.resetViewport,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
// TODO: Clear Annotations
|
||||||
|
// TODO: Next/Previous image
|
||||||
|
// TODO: First/Last image
|
||||||
|
// Next/Previous series/DisplaySet
|
||||||
|
nextViewportDisplaySet: {
|
||||||
|
commandFn: actions.updateViewportDisplaySet,
|
||||||
|
storeContexts: [],
|
||||||
|
options: { direction: 1 },
|
||||||
|
},
|
||||||
|
previousViewportDisplaySet: {
|
||||||
|
commandFn: actions.updateViewportDisplaySet,
|
||||||
|
storeContexts: [],
|
||||||
|
options: { direction: 1 },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs `dom` reference for the enabledElement of
|
* Grabs `dom` reference for the enabledElement of
|
||||||
* the active viewport
|
* the active viewport
|
||||||
60
src/appCommands/index.js
Normal file
60
src/appCommands/index.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import cornerstoneCommandDefinitions from './cornerstone.js';
|
||||||
|
import viewerCommandDefinitions from './viewer.js';
|
||||||
|
|
||||||
|
const CONTEXTS = {
|
||||||
|
viewer: 'VIEWER',
|
||||||
|
cornerstone: 'VIEWER::CORNERSTONE',
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register all commands.
|
||||||
|
* TODO: Extensions should self-register their commands
|
||||||
|
*/
|
||||||
|
function init(commandsManager) {
|
||||||
|
_registerViewerCommands(commandsManager);
|
||||||
|
_registerCornerstoneCommands(commandsManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register all Viewer commands
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function _registerViewerCommands(commandsManager) {
|
||||||
|
const commandContext = CONTEXTS.viewer;
|
||||||
|
|
||||||
|
commandsManager.createContext(commandContext);
|
||||||
|
Object.keys(viewerCommandDefinitions).forEach(commandName => {
|
||||||
|
const commandDefinition = viewerCommandDefinitions[commandName];
|
||||||
|
|
||||||
|
commandsManager.registerCommand(
|
||||||
|
commandContext,
|
||||||
|
commandName,
|
||||||
|
commandDefinition
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register all Cornerstone commands
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function _registerCornerstoneCommands(commandsManager) {
|
||||||
|
const commandContext = CONTEXTS.cornerstone;
|
||||||
|
|
||||||
|
commandsManager.createContext(commandContext);
|
||||||
|
Object.keys(cornerstoneCommandDefinitions).forEach(commandName => {
|
||||||
|
const commandDefinition = cornerstoneCommandDefinitions[commandName];
|
||||||
|
|
||||||
|
commandsManager.registerCommand(
|
||||||
|
commandContext,
|
||||||
|
commandName,
|
||||||
|
commandDefinition
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
init,
|
||||||
|
};
|
||||||
@ -1,21 +1,7 @@
|
|||||||
import { redux } from 'ohif-core';
|
import { redux } from 'ohif-core';
|
||||||
import store from './store';
|
import store from './../store';
|
||||||
const { setViewportActive } = redux.actions;
|
const { setViewportActive } = redux.actions;
|
||||||
|
|
||||||
const definitions = {
|
|
||||||
// Next/Previous active viewport
|
|
||||||
incrementActiveViewport: {
|
|
||||||
commandFn: actions.updateActiveViewport,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: { direction: 1 },
|
|
||||||
},
|
|
||||||
decrementActiveViewport: {
|
|
||||||
commandFn: actions.updateActiveViewport,
|
|
||||||
storeContexts: ['viewports'],
|
|
||||||
options: { direction: -1 },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
updateViewportDisplaySet: ({ direction }) => {
|
updateViewportDisplaySet: ({ direction }) => {
|
||||||
// TODO
|
// TODO
|
||||||
@ -33,4 +19,18 @@ const actions = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const definitions = {
|
||||||
|
// Next/Previous active viewport
|
||||||
|
incrementActiveViewport: {
|
||||||
|
commandFn: actions.updateActiveViewport,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: { direction: 1 },
|
||||||
|
},
|
||||||
|
decrementActiveViewport: {
|
||||||
|
commandFn: actions.updateActiveViewport,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: { direction: -1 },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export default definitions;
|
export default definitions;
|
||||||
@ -1,52 +0,0 @@
|
|||||||
import { CommandsManager } from 'ohif-core';
|
|
||||||
import cornerstoneCommandDefinitions from 'cornerstone.js';
|
|
||||||
import viewerCommandDefinitions from 'viewer.js';
|
|
||||||
|
|
||||||
const CONTEXTS = {
|
|
||||||
viewer: 'VIEWER',
|
|
||||||
cornerstone: 'VIEWER::CORNERSTONE',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register all commands
|
|
||||||
*/
|
|
||||||
function init() {
|
|
||||||
_registerViewerCommands();
|
|
||||||
_registerCornerstoneCommands();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register all Viewer commands
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function _registerViewerCommands() {
|
|
||||||
const commandContext = CONTEXTS.viewer;
|
|
||||||
|
|
||||||
CommandsManager.createContext(commandContext);
|
|
||||||
Object.keys(viewerCommandDefinitions).forEach(commandName => {
|
|
||||||
const commandDefinition = viewerCommandDefinitions[commandName];
|
|
||||||
|
|
||||||
CommandsManager.register(commandContext, commandName, commandDefinition);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register all Cornerstone commands
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function _registerCornerstoneCommands() {
|
|
||||||
const commandContext = CONTEXTS.cornerstone;
|
|
||||||
|
|
||||||
CommandsManager.createContext(commandContext);
|
|
||||||
Object.keys(cornerstoneCommandDefinitions).forEach(commandName => {
|
|
||||||
const commandDefinition = cornerstoneCommandDefinitions[commandName];
|
|
||||||
|
|
||||||
CommandsManager.register(commandContext, commandName, commandDefinition);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
init,
|
|
||||||
};
|
|
||||||
Loading…
Reference in New Issue
Block a user