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 });
|
cornerstoneTools.setToolActive(toolName, { mouseButtonMask: 1 });
|
||||||
},
|
},
|
||||||
updateViewportDisplaySet: ({ direction }) => {
|
|
||||||
// TODO
|
|
||||||
console.warn('updateDisplaySet: ', direction);
|
|
||||||
},
|
|
||||||
clearAnnotations: ({ viewports }) => {
|
clearAnnotations: ({ viewports }) => {
|
||||||
const element = getEnabledElement(viewports.activeViewportIndex);
|
const element = getEnabledElement(viewports.activeViewportIndex);
|
||||||
if (!element) {
|
if (!element) {
|
||||||
@ -245,7 +241,7 @@ const commandsModule = ({ servicesManager }) => {
|
|||||||
},
|
},
|
||||||
setCornerstoneLayout: () => {
|
setCornerstoneLayout: () => {
|
||||||
setCornerstoneLayout();
|
setCornerstoneLayout();
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const definitions = {
|
const definitions = {
|
||||||
@ -334,24 +330,17 @@ const commandsModule = ({ servicesManager }) => {
|
|||||||
storeContexts: ['viewports'],
|
storeContexts: ['viewports'],
|
||||||
options: {},
|
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
|
// TOOLS
|
||||||
setToolActive: {
|
setToolActive: {
|
||||||
commandFn: actions.setToolActive,
|
commandFn: actions.setToolActive,
|
||||||
storeContexts: [],
|
storeContexts: [],
|
||||||
options: {},
|
options: {},
|
||||||
},
|
},
|
||||||
|
setZoomTool: {
|
||||||
|
commandFn: actions.setToolActive,
|
||||||
|
storeContexts: [],
|
||||||
|
options: { toolName: 'Zoom' },
|
||||||
|
},
|
||||||
setCornerstoneLayout: {
|
setCornerstoneLayout: {
|
||||||
commandFn: actions.setCornerstoneLayout,
|
commandFn: actions.setCornerstoneLayout,
|
||||||
storeContexts: [],
|
storeContexts: [],
|
||||||
|
|||||||
@ -58,12 +58,12 @@ window.config = {
|
|||||||
// firstImage
|
// firstImage
|
||||||
// lastImage
|
// lastImage
|
||||||
{
|
{
|
||||||
commandName: 'nextViewportDisplaySet',
|
commandName: 'previousViewportDisplaySet',
|
||||||
label: 'Previous Series',
|
label: 'Previous Series',
|
||||||
keys: ['pagedown'],
|
keys: ['pagedown'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
commandName: 'previousViewportDisplaySet',
|
commandName: 'nextViewportDisplaySet',
|
||||||
label: 'Next Series',
|
label: 'Next Series',
|
||||||
keys: ['pageup'],
|
keys: ['pageup'],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -48,12 +48,12 @@ window.config = {
|
|||||||
{ commandName: 'nextImage', label: 'Next Image', keys: ['down'] },
|
{ commandName: 'nextImage', label: 'Next Image', keys: ['down'] },
|
||||||
{ commandName: 'previousImage', label: 'Previous Image', keys: ['up'] },
|
{ commandName: 'previousImage', label: 'Previous Image', keys: ['up'] },
|
||||||
{
|
{
|
||||||
commandName: 'nextViewportDisplaySet',
|
commandName: 'previousViewportDisplaySet',
|
||||||
label: 'Previous Series',
|
label: 'Previous Series',
|
||||||
keys: ['pagedown'],
|
keys: ['pagedown'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
commandName: 'previousViewportDisplaySet',
|
commandName: 'nextViewportDisplaySet',
|
||||||
label: 'Next Series',
|
label: 'Next Series',
|
||||||
keys: ['pageup'],
|
keys: ['pageup'],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -53,12 +53,12 @@ window.config = {
|
|||||||
// firstImage
|
// firstImage
|
||||||
// lastImage
|
// lastImage
|
||||||
{
|
{
|
||||||
commandName: 'nextViewportDisplaySet',
|
commandName: 'previousViewportDisplaySet',
|
||||||
label: 'Previous Series',
|
label: 'Previous Series',
|
||||||
keys: ['pagedown'],
|
keys: ['pagedown'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
commandName: 'previousViewportDisplaySet',
|
commandName: 'nextViewportDisplaySet',
|
||||||
label: 'Next Series',
|
label: 'Next Series',
|
||||||
keys: ['pageup'],
|
keys: ['pageup'],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,12 +1,8 @@
|
|||||||
import { redux } from "@ohif/core";
|
import { redux, utils } from '@ohif/core';
|
||||||
import store from "./../../store";
|
import store from './../../store';
|
||||||
const { setViewportActive } = redux.actions;
|
const { setViewportActive, setActiveViewportSpecificData } = redux.actions;
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
updateViewportDisplaySet: ({ direction }) => {
|
|
||||||
// TODO
|
|
||||||
// console.warn('updateDisplaySet: ', direction);
|
|
||||||
},
|
|
||||||
updateActiveViewport: ({ viewports, direction }) => {
|
updateActiveViewport: ({ viewports, direction }) => {
|
||||||
const { viewportSpecificData, activeViewportIndex } = viewports;
|
const { viewportSpecificData, activeViewportIndex } = viewports;
|
||||||
const maxIndex = Object.keys(viewportSpecificData).length - 1;
|
const maxIndex = Object.keys(viewportSpecificData).length - 1;
|
||||||
@ -16,24 +12,63 @@ const actions = {
|
|||||||
newIndex = newIndex < 0 ? maxIndex : newIndex;
|
newIndex = newIndex < 0 ? maxIndex : newIndex;
|
||||||
|
|
||||||
store.dispatch(setViewportActive(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 = {
|
const definitions = {
|
||||||
// Next/Previous active viewport
|
// Next/Previous active viewport
|
||||||
incrementActiveViewport: {
|
incrementActiveViewport: {
|
||||||
commandFn: actions.updateActiveViewport,
|
commandFn: actions.updateActiveViewport,
|
||||||
storeContexts: ["viewports"],
|
storeContexts: ['viewports'],
|
||||||
options: { direction: 1 }
|
options: { direction: 1 },
|
||||||
},
|
},
|
||||||
decrementActiveViewport: {
|
decrementActiveViewport: {
|
||||||
commandFn: actions.updateActiveViewport,
|
commandFn: actions.updateActiveViewport,
|
||||||
storeContexts: ["viewports"],
|
storeContexts: ['viewports'],
|
||||||
options: { direction: -1 }
|
options: { direction: -1 },
|
||||||
}
|
},
|
||||||
|
nextViewportDisplaySet: {
|
||||||
|
commandFn: actions.updateViewportDisplaySet,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: { direction: 1 },
|
||||||
|
},
|
||||||
|
previousViewportDisplaySet: {
|
||||||
|
commandFn: actions.updateViewportDisplaySet,
|
||||||
|
storeContexts: ['viewports'],
|
||||||
|
options: { direction: -1 },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
definitions,
|
definitions,
|
||||||
defaultContext: "VIEWER"
|
defaultContext: 'VIEWER',
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user