fix: Creating 2 commands to activate zoom tool and also to move between displaySets (#1446)
This commit is contained in:
parent
6cba41dd8b
commit
06a4af06fa
@ -74,10 +74,6 @@ const commandsModule = ({ servicesManager }) => {
|
||||
}
|
||||
cornerstoneTools.setToolActive(toolName, { mouseButtonMask: 1 });
|
||||
},
|
||||
updateViewportDisplaySet: ({ direction }) => {
|
||||
// TODO
|
||||
console.warn('updateDisplaySet: ', direction);
|
||||
},
|
||||
clearAnnotations: ({ viewports }) => {
|
||||
const element = getEnabledElement(viewports.activeViewportIndex);
|
||||
if (!element) {
|
||||
@ -245,7 +241,7 @@ const commandsModule = ({ servicesManager }) => {
|
||||
},
|
||||
setCornerstoneLayout: () => {
|
||||
setCornerstoneLayout();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const definitions = {
|
||||
@ -334,24 +330,17 @@ const commandsModule = ({ servicesManager }) => {
|
||||
storeContexts: ['viewports'],
|
||||
options: {},
|
||||
},
|
||||
// TODO: First/Last image
|
||||
// Next/Previous series/DisplaySet
|
||||
nextViewportDisplaySet: {
|
||||
commandFn: actions.updateViewportDisplaySet,
|
||||
storeContexts: [],
|
||||
options: { direction: 1 },
|
||||
},
|
||||
previousViewportDisplaySet: {
|
||||
commandFn: actions.updateViewportDisplaySet,
|
||||
storeContexts: [],
|
||||
options: { direction: -1 },
|
||||
},
|
||||
// TOOLS
|
||||
setToolActive: {
|
||||
commandFn: actions.setToolActive,
|
||||
storeContexts: [],
|
||||
options: {},
|
||||
},
|
||||
setZoomTool: {
|
||||
commandFn: actions.setToolActive,
|
||||
storeContexts: [],
|
||||
options: { toolName: 'Zoom' },
|
||||
},
|
||||
setCornerstoneLayout: {
|
||||
commandFn: actions.setCornerstoneLayout,
|
||||
storeContexts: [],
|
||||
|
||||
@ -58,12 +58,12 @@ window.config = {
|
||||
// firstImage
|
||||
// lastImage
|
||||
{
|
||||
commandName: 'nextViewportDisplaySet',
|
||||
commandName: 'previousViewportDisplaySet',
|
||||
label: 'Previous Series',
|
||||
keys: ['pagedown'],
|
||||
},
|
||||
{
|
||||
commandName: 'previousViewportDisplaySet',
|
||||
commandName: 'nextViewportDisplaySet',
|
||||
label: 'Next Series',
|
||||
keys: ['pageup'],
|
||||
},
|
||||
|
||||
@ -48,12 +48,12 @@ window.config = {
|
||||
{ commandName: 'nextImage', label: 'Next Image', keys: ['down'] },
|
||||
{ commandName: 'previousImage', label: 'Previous Image', keys: ['up'] },
|
||||
{
|
||||
commandName: 'nextViewportDisplaySet',
|
||||
commandName: 'previousViewportDisplaySet',
|
||||
label: 'Previous Series',
|
||||
keys: ['pagedown'],
|
||||
},
|
||||
{
|
||||
commandName: 'previousViewportDisplaySet',
|
||||
commandName: 'nextViewportDisplaySet',
|
||||
label: 'Next Series',
|
||||
keys: ['pageup'],
|
||||
},
|
||||
|
||||
@ -53,12 +53,12 @@ window.config = {
|
||||
// firstImage
|
||||
// lastImage
|
||||
{
|
||||
commandName: 'nextViewportDisplaySet',
|
||||
commandName: 'previousViewportDisplaySet',
|
||||
label: 'Previous Series',
|
||||
keys: ['pagedown'],
|
||||
},
|
||||
{
|
||||
commandName: 'previousViewportDisplaySet',
|
||||
commandName: 'nextViewportDisplaySet',
|
||||
label: 'Next Series',
|
||||
keys: ['pageup'],
|
||||
},
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
import { redux } from "@ohif/core";
|
||||
import store from "./../../store";
|
||||
const { setViewportActive } = redux.actions;
|
||||
import { redux, utils } from '@ohif/core';
|
||||
import store from './../../store';
|
||||
const { setViewportActive, setActiveViewportSpecificData } = 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;
|
||||
@ -16,24 +12,63 @@ const actions = {
|
||||
newIndex = newIndex < 0 ? maxIndex : newIndex;
|
||||
|
||||
store.dispatch(setViewportActive(newIndex));
|
||||
}
|
||||
},
|
||||
updateViewportDisplaySet: ({ viewports, direction }) => {
|
||||
const viewportSpecificData = { ...viewports.viewportSpecificData };
|
||||
const activeViewport = viewportSpecificData[viewports.activeViewportIndex];
|
||||
const studyMetadata = utils.studyMetadataManager.get(
|
||||
activeViewport.studyInstanceUid
|
||||
);
|
||||
|
||||
if (!studyMetadata) {
|
||||
return;
|
||||
}
|
||||
|
||||
const allDisplaySets = studyMetadata.getDisplaySets();
|
||||
const currentDisplaySetIndex = allDisplaySets.findIndex(
|
||||
displaySet =>
|
||||
displaySet.displaySetInstanceUid ===
|
||||
activeViewport.displaySetInstanceUid
|
||||
);
|
||||
if (currentDisplaySetIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newDisplaySetIndex = currentDisplaySetIndex + direction;
|
||||
const newDisplaySetData = allDisplaySets[newDisplaySetIndex];
|
||||
if (!newDisplaySetData) {
|
||||
return;
|
||||
}
|
||||
|
||||
store.dispatch(setActiveViewportSpecificData(newDisplaySetData));
|
||||
},
|
||||
};
|
||||
|
||||
const definitions = {
|
||||
// Next/Previous active viewport
|
||||
incrementActiveViewport: {
|
||||
commandFn: actions.updateActiveViewport,
|
||||
storeContexts: ["viewports"],
|
||||
options: { direction: 1 }
|
||||
storeContexts: ['viewports'],
|
||||
options: { direction: 1 },
|
||||
},
|
||||
decrementActiveViewport: {
|
||||
commandFn: actions.updateActiveViewport,
|
||||
storeContexts: ["viewports"],
|
||||
options: { direction: -1 }
|
||||
}
|
||||
storeContexts: ['viewports'],
|
||||
options: { direction: -1 },
|
||||
},
|
||||
nextViewportDisplaySet: {
|
||||
commandFn: actions.updateViewportDisplaySet,
|
||||
storeContexts: ['viewports'],
|
||||
options: { direction: 1 },
|
||||
},
|
||||
previousViewportDisplaySet: {
|
||||
commandFn: actions.updateViewportDisplaySet,
|
||||
storeContexts: ['viewports'],
|
||||
options: { direction: -1 },
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
definitions,
|
||||
defaultContext: "VIEWER"
|
||||
defaultContext: 'VIEWER',
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user