@@ -3,8 +3,11 @@ import { Tools } from '../store/tools/types';
33import { useRectangleStore } from '../store/tools/rectangles' ;
44import { useRulerStore } from '../store/tools/rulers' ;
55import { usePolygonStore } from '../store/tools/polygons' ;
6+ import { useViewStore } from '../store/views' ;
67import { Action } from '../constants' ;
78import { useKeyboardShortcutsStore } from '../store/keyboard-shortcuts' ;
9+ import { useCurrentImage } from './useCurrentImage' ;
10+ import { useSliceConfig } from './useSliceConfig' ;
811
912const 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+
3958export 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
0 commit comments