fix(shortcut): h
This commit is contained in:
@@ -1594,6 +1594,50 @@ const LabelPage = ({
|
||||
})
|
||||
}, [activeImage, labelData])
|
||||
|
||||
const handleToggleHideSelectionOrAll = useCallback(() => {
|
||||
const selectedIds =
|
||||
useObjectStore.getState().selectedPath[activeImage] || []
|
||||
if (!selectedIds.length) {
|
||||
handleToggleHideAllObjects()
|
||||
return
|
||||
}
|
||||
|
||||
const activeImageLabel = labelData.get(activeImage)
|
||||
if (!activeImageLabel?.size) {
|
||||
return
|
||||
}
|
||||
|
||||
const selectedIdSet = new Set(selectedIds)
|
||||
const selectedObjects: Array<{
|
||||
operationId: string
|
||||
objectId: number
|
||||
}> = []
|
||||
|
||||
activeImageLabel.forEach((paths, operationId) => {
|
||||
paths.forEach(([objectId]) => {
|
||||
if (!selectedIdSet.has(objectId)) return
|
||||
selectedObjects.push({
|
||||
operationId,
|
||||
objectId,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
if (!selectedObjects.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const { pathStatus } = useObjectStore.getState()
|
||||
const areAllSelectedObjectsHidden = selectedObjects.every(
|
||||
({ objectId }) => pathStatus[activeImage + objectId]?.HIDE ?? false
|
||||
)
|
||||
const nextHide = !areAllSelectedObjectsHidden
|
||||
|
||||
selectedObjects.forEach(({ operationId, objectId }) => {
|
||||
toggleObjectHideByShortcut(activeImage, operationId, objectId, nextHide)
|
||||
})
|
||||
}, [activeImage, handleToggleHideAllObjects, labelData])
|
||||
|
||||
const rerenderActiveImageByLabel = useCallback(
|
||||
(
|
||||
imageId: string,
|
||||
@@ -2185,7 +2229,7 @@ const LabelPage = ({
|
||||
|
||||
if (!e.ctrlKey && !e.metaKey && !e.altKey && lowerKey === "h") {
|
||||
e.preventDefault()
|
||||
handleToggleHideAllObjects()
|
||||
handleToggleHideSelectionOrAll()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2487,6 +2531,7 @@ const LabelPage = ({
|
||||
focusInput,
|
||||
getOperationSchema,
|
||||
handleToggleHideAllObjects,
|
||||
handleToggleHideSelectionOrAll,
|
||||
handleMergeSelectedObjects,
|
||||
handleContinueSelectedPolygon,
|
||||
handleShortcut,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import paper from "paper"
|
||||
import { useLabelStore, useObjectStore } from "../store"
|
||||
import { useOtherToolsStore } from "../useOtherToolsStore"
|
||||
import { usePaperStore } from "../usePaperStore"
|
||||
import { usePaperSupportStore } from "../usePaperSupportStore"
|
||||
import { useTopToolsStore } from "../useTopToolsStore"
|
||||
|
||||
const getTagVisibility = (tagCategory?: string) => {
|
||||
@@ -22,6 +24,32 @@ const setSelectedItemFalse = (id: number) => {
|
||||
})
|
||||
}
|
||||
|
||||
const clearHiddenObjectSelectionState = (imageId: string, objectId: number) => {
|
||||
const { selectedPath, updateSelectedPath } = useObjectStore.getState()
|
||||
if (selectedPath[imageId]?.includes(objectId)) {
|
||||
updateSelectedPath(imageId, "DELETE", objectId)
|
||||
usePaperSupportStore.getState().clearAll()
|
||||
}
|
||||
|
||||
const otherToolsState = useOtherToolsStore.getState()
|
||||
if (
|
||||
otherToolsState.showContextMenu &&
|
||||
otherToolsState.imageId === imageId &&
|
||||
otherToolsState.id === objectId
|
||||
) {
|
||||
otherToolsState.setShowContextMenu({
|
||||
showContextMenu: false,
|
||||
position: {
|
||||
top: 0,
|
||||
left: 0,
|
||||
},
|
||||
imageId: "",
|
||||
operationId: "",
|
||||
id: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const syncObjectItemsVisibility = (objectId: number, hide: boolean) => {
|
||||
const sameIdItems = usePaperStore.getState().getItemsById(objectId)
|
||||
if (!sameIdItems?.length) return
|
||||
@@ -51,6 +79,7 @@ export const toggleObjectHideByShortcut = (
|
||||
updatePathStatus(imageId + objectId, "HIDE", hide)
|
||||
syncObjectItemsVisibility(objectId, hide)
|
||||
setSelectedItemFalse(objectId)
|
||||
clearHiddenObjectSelectionState(imageId, objectId)
|
||||
|
||||
const operationChildren = storeLabel.get(imageId)?.get(operationId) || []
|
||||
const hasVisibleChild = operationChildren.some((child) => {
|
||||
|
||||
Reference in New Issue
Block a user