feat(hotkeys): Migrate hotkeys to customization service and fix issues with overrides (#4777)
This commit is contained in:
1 parent
4559d39a91
commit
3e6913b097
39 files changed
+814
-1552
No files matched your search
@@ -25,7 +25,6 @@ import {
|
||||
colorPickerDialog,
|
||||
} from '@ohif/extension-default';
|
||||
import { vec3, mat4 } from 'gl-matrix';
|
||||
|
||||
import CornerstoneViewportDownloadForm from './utils/CornerstoneViewportDownloadForm';
|
||||
import toggleImageSliceSync from './utils/imageSliceSync/toggleImageSliceSync';
|
||||
import { getFirstAnnotationSelected } from './utils/measurementServiceMappings/utils/selection';
|
||||
@@ -34,6 +33,7 @@ import toggleVOISliceSync from './utils/toggleVOISliceSync';
|
||||
import { usePositionPresentationStore, useSegmentationPresentationStore } from './stores';
|
||||
import { toolNames } from './initCornerstoneTools';
|
||||
|
||||
const { DefaultHistoryMemo } = csUtils.HistoryMemo;
|
||||
const toggleSyncFunctions = {
|
||||
imageSlice: toggleImageSliceSync,
|
||||
voi: toggleVOISliceSync,
|
||||
@@ -430,6 +430,37 @@ function commandsModule({
|
||||
|
||||
actions.setViewportWindowLevel({ ...props, viewportId });
|
||||
},
|
||||
setWindowLevelPreset: ({ presetName, presetIndex }) => {
|
||||
const windowLevelPresets = customizationService.getCustomization(
|
||||
'cornerstone.windowLevelPresets'
|
||||
);
|
||||
|
||||
const activeViewport = viewportGridService.getActiveViewportId();
|
||||
const viewport = cornerstoneViewportService.getCornerstoneViewport(activeViewport);
|
||||
const metadata = viewport.getImageData().metadata;
|
||||
|
||||
const modality = metadata.Modality;
|
||||
|
||||
if (!modality) {
|
||||
return;
|
||||
}
|
||||
|
||||
const windowLevelPresetForModality = windowLevelPresets[modality];
|
||||
|
||||
if (!windowLevelPresetForModality) {
|
||||
return;
|
||||
}
|
||||
|
||||
const windowLevelPreset =
|
||||
windowLevelPresetForModality[presetName] ??
|
||||
Object.values(windowLevelPresetForModality)[presetIndex];
|
||||
|
||||
actions.setViewportWindowLevel({
|
||||
viewportId: activeViewport,
|
||||
window: windowLevelPreset.window,
|
||||
level: windowLevelPreset.level,
|
||||
});
|
||||
},
|
||||
setToolEnabled: ({ toolName, toggle, toolGroupId }) => {
|
||||
const { viewports } = viewportGridService.getState();
|
||||
|
||||
@@ -1327,6 +1358,12 @@ function commandsModule({
|
||||
measurementService.remove(activeAnnotationUID);
|
||||
});
|
||||
},
|
||||
undo: () => {
|
||||
DefaultHistoryMemo.undo();
|
||||
},
|
||||
redo: () => {
|
||||
DefaultHistoryMemo.redo();
|
||||
},
|
||||
};
|
||||
|
||||
const definitions = {
|
||||
@@ -1391,6 +1428,9 @@ function commandsModule({
|
||||
setWindowLevel: {
|
||||
commandFn: actions.setWindowLevel,
|
||||
},
|
||||
setWindowLevelPreset: {
|
||||
commandFn: actions.setWindowLevelPreset,
|
||||
},
|
||||
setToolActive: {
|
||||
commandFn: actions.setToolActive,
|
||||
},
|
||||
@@ -1590,6 +1630,8 @@ function commandsModule({
|
||||
deleteActiveAnnotation: {
|
||||
commandFn: actions.deleteActiveAnnotation,
|
||||
},
|
||||
undo: actions.undo,
|
||||
redo: actions.redo,
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user