From c81affcc30df5b6046472617bb71ff0ed523a072 Mon Sep 17 00:00:00 2001 From: Laurent Chauvin Date: Thu, 24 Oct 2024 14:58:08 -0400 Subject: [PATCH 1/2] feat(View): Save active view id --- src/components/LayoutGrid.vue | 8 ++++++++ src/store/views.ts | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/components/LayoutGrid.vue b/src/components/LayoutGrid.vue index ea161001..e748adf1 100644 --- a/src/components/LayoutGrid.vue +++ b/src/components/LayoutGrid.vue @@ -13,6 +13,7 @@ :id="item.id" :type="item.viewType" v-bind="item.props" + @focus="onFocusView(item.id!, item.viewType!)" /> @@ -28,6 +29,13 @@ import { useViewStore } from '../store/views'; export default defineComponent({ name: 'LayoutGrid', + methods: { + onFocusView(id: string, type: string) { + if (type === '2D') { + useViewStore().setActiveViewID(id); + } + }, + }, props: { layout: { type: Object as PropType, diff --git a/src/store/views.ts b/src/store/views.ts index d4513e73..18c435a6 100644 --- a/src/store/views.ts +++ b/src/store/views.ts @@ -12,6 +12,7 @@ import { interface State { layout: Layout; viewSpecs: Record; + activeViewID: string; } export const useViewStore = defineStore('view', { @@ -21,6 +22,7 @@ export const useViewStore = defineStore('view', { items: [], }, viewSpecs: structuredClone(InitViewSpecs), + activeViewID: '', }), getters: { viewIDs(state) { @@ -28,6 +30,9 @@ export const useViewStore = defineStore('view', { }, }, actions: { + setActiveViewID(id: string) { + this.activeViewID = id; + }, addView(id: string) { if (!(id in this.viewSpecs)) { this.viewSpecs[id] = structuredClone(DefaultViewSpec); From ce8aac86d94007fd1a911fa534c4a0fb1bf5ceec Mon Sep 17 00:00:00 2001 From: Laurent Chauvin Date: Mon, 28 Oct 2024 13:45:03 -0400 Subject: [PATCH 2/2] feat(Slice): Use keyboard to change slices --- src/composables/actions.ts | 22 ++++++++++++++++++++++ src/config.ts | 3 +++ src/constants.ts | 7 +++++++ 3 files changed, 32 insertions(+) diff --git a/src/composables/actions.ts b/src/composables/actions.ts index beb0a9a3..b9a7de1e 100644 --- a/src/composables/actions.ts +++ b/src/composables/actions.ts @@ -3,8 +3,11 @@ import { Tools } from '../store/tools/types'; import { useRectangleStore } from '../store/tools/rectangles'; import { useRulerStore } from '../store/tools/rulers'; import { usePolygonStore } from '../store/tools/polygons'; +import { useViewStore } from '../store/views'; import { Action } from '../constants'; import { useKeyboardShortcutsStore } from '../store/keyboard-shortcuts'; +import { useCurrentImage } from './useCurrentImage'; +import { useSliceConfig } from './useSliceConfig'; const applyLabelOffset = (offset: number) => () => { const toolToStore = { @@ -36,6 +39,22 @@ const showKeyboardShortcuts = () => { keyboardStore.settingsOpen = !keyboardStore.settingsOpen; }; +const nextSlice = () => () => { + const { currentImageID } = useCurrentImage(); + const { activeViewID } = useViewStore(); + + const { slice: currentSlice } = useSliceConfig(activeViewID, currentImageID); + currentSlice.value += 1; +}; + +const previousSlice = () => () => { + const { currentImageID } = useCurrentImage(); + const { activeViewID } = useViewStore(); + + const { slice: currentSlice } = useSliceConfig(activeViewID, currentImageID); + currentSlice.value -= 1; +}; + export const ACTION_TO_FUNC = { windowLevel: setTool(Tools.WindowLevel), pan: setTool(Tools.Pan), @@ -48,6 +67,9 @@ export const ACTION_TO_FUNC = { polygon: setTool(Tools.Polygon), select: setTool(Tools.Select), + nextSlice: nextSlice(), + previousSlice: previousSlice(), + decrementLabel: applyLabelOffset(-1), incrementLabel: applyLabelOffset(1), diff --git a/src/config.ts b/src/config.ts index d0511aa9..d2e95b39 100644 --- a/src/config.ts +++ b/src/config.ts @@ -281,6 +281,9 @@ export const ACTION_TO_KEY = { mergeNewPolygon: 'Shift', select: 's', + nextSlice: 'arrowdown', + previousSlice: 'arrowup', + decrementLabel: 'q', incrementLabel: 'w', diff --git a/src/constants.ts b/src/constants.ts index ebc62ce1..07675230 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -53,6 +53,13 @@ export const ACTIONS = { readable: 'Activate Select tool', }, + nextSlice: { + readable: 'Next Slice', + }, + previousSlice: { + readable: 'Previous Slice', + }, + decrementLabel: { readable: 'Activate previous Label', },