Skip to content

Commit 86d72bf

Browse files
author
Laurent Chauvin
committed
feat(Slice): Use keyboard to change slices
1 parent a76e8fb commit 86d72bf

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/composables/actions.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import { Tools } from '../store/tools/types';
33
import { useRectangleStore } from '../store/tools/rectangles';
44
import { useRulerStore } from '../store/tools/rulers';
55
import { usePolygonStore } from '../store/tools/polygons';
6+
import { useViewStore } from '../store/views';
67
import { Action } from '../constants';
78
import { useKeyboardShortcutsStore } from '../store/keyboard-shortcuts';
9+
import { useCurrentImage } from './useCurrentImage';
10+
import { useSliceConfig } from './useSliceConfig';
811

912
const applyLabelOffset = (offset: number) => () => {
1013
const toolToStore = {
@@ -36,6 +39,22 @@ const showKeyboardShortcuts = () => {
3639
keyboardStore.settingsOpen = !keyboardStore.settingsOpen;
3740
};
3841

42+
const nextSlice = () => () => {
43+
const { currentImageID } = useCurrentImage();
44+
const { activeViewID } = useViewStore();
45+
46+
const { slice: currentSlice } = useSliceConfig(activeViewID, currentImageID);
47+
currentSlice.value += 1;
48+
};
49+
50+
const previousSlice = () => () => {
51+
const { currentImageID } = useCurrentImage();
52+
const { activeViewID } = useViewStore();
53+
54+
const { slice: currentSlice } = useSliceConfig(activeViewID, currentImageID);
55+
currentSlice.value -= 1;
56+
};
57+
3958
export const ACTION_TO_FUNC = {
4059
windowLevel: setTool(Tools.WindowLevel),
4160
pan: setTool(Tools.Pan),
@@ -48,6 +67,9 @@ export const ACTION_TO_FUNC = {
4867
polygon: setTool(Tools.Polygon),
4968
select: setTool(Tools.Select),
5069

70+
nextSlice: nextSlice(),
71+
previousSlice: previousSlice(),
72+
5173
decrementLabel: applyLabelOffset(-1),
5274
incrementLabel: applyLabelOffset(1),
5375

src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ export const ACTION_TO_KEY = {
281281
mergeNewPolygon: 'Shift',
282282
select: 's',
283283

284+
nextSlice: 'arrowdown',
285+
previousSlice: 'arrowup',
286+
284287
decrementLabel: 'q',
285288
incrementLabel: 'w',
286289

src/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ export const ACTIONS = {
5353
readable: 'Activate Select tool',
5454
},
5555

56+
nextSlice: {
57+
readable: 'Next Slice',
58+
},
59+
previousSlice: {
60+
readable: 'Previous Slice',
61+
},
62+
5663
decrementLabel: {
5764
readable: 'Activate previous Label',
5865
},

0 commit comments

Comments
 (0)