fix(tool): top tool
This commit is contained in:
@@ -307,6 +307,7 @@ const LabelPage = ({
|
||||
activeOperation,
|
||||
setActiveOperation,
|
||||
setDrawOption,
|
||||
setSubAttrPresetShow,
|
||||
showObjectList,
|
||||
showGroupList,
|
||||
showTaskList,
|
||||
@@ -1433,6 +1434,31 @@ const LabelPage = ({
|
||||
|
||||
const { setShift, focusInput } = useKeyEventStore()
|
||||
const drawAction = useKeyboardStore((state) => state.drawAction)
|
||||
const initializedDrawActionTaskIdRef = useRef<number | null>(null)
|
||||
|
||||
const handleSelectOperation = useCallback(
|
||||
(operationId: string) => {
|
||||
const operationSchema = getOperationSchema(operationId)
|
||||
if (!operationSchema) return false
|
||||
|
||||
setActiveOperation(operationId)
|
||||
setSubAttrPresetShow(!!operationSchema.sub_attributes_describe?.length)
|
||||
|
||||
if (isLabelTask) {
|
||||
setEditMode(true)
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
[
|
||||
getOperationSchema,
|
||||
isLabelTask,
|
||||
setActiveOperation,
|
||||
setEditMode,
|
||||
setSubAttrPresetShow,
|
||||
]
|
||||
)
|
||||
|
||||
const drawShortcutSnapshotRef = useRef<{
|
||||
activeOperation: string
|
||||
drawOption: "default" | "intersect" | "unite"
|
||||
@@ -1441,20 +1467,17 @@ const LabelPage = ({
|
||||
|
||||
const handleShortcut = useCallback(
|
||||
(key: string, ctrl: boolean) => {
|
||||
let checkOperation = getOperationSchema(key)
|
||||
const mode = usePaperStore.getState().mode
|
||||
const nextOperationId = ctrl ? (+key + 10).toString() : key
|
||||
const checkOperation = getOperationSchema(nextOperationId)
|
||||
// 标注方案里面存在的非文本类型标注才能切换
|
||||
if (checkOperation) {
|
||||
// 辅助标注模式下非多边形类型不能切换
|
||||
if (mode === "support" && checkOperation.label_type !== 102) return
|
||||
if (ctrl) {
|
||||
setActiveOperation((+key + 10).toString())
|
||||
} else {
|
||||
setActiveOperation(key)
|
||||
}
|
||||
handleSelectOperation(nextOperationId)
|
||||
}
|
||||
},
|
||||
[getOperationSchema, setActiveOperation]
|
||||
[getOperationSchema, handleSelectOperation]
|
||||
)
|
||||
|
||||
const resolveSelectedObjectContext = useCallback(() => {
|
||||
@@ -2564,6 +2587,14 @@ const LabelPage = ({
|
||||
drawShortcutSnapshotRef.current = null
|
||||
}, [activeImage])
|
||||
|
||||
useEffect(() => {
|
||||
if (!taskDetail?.id || !activeImage || !isLabelTask) return
|
||||
if (initializedDrawActionTaskIdRef.current === taskDetail.id) return
|
||||
|
||||
useKeyboardStore.getState().setDrawAction("subtract")
|
||||
initializedDrawActionTaskIdRef.current = taskDetail.id
|
||||
}, [activeImage, isLabelTask, taskDetail?.id])
|
||||
|
||||
const handleBeforeUnload = (e: any) => {
|
||||
e.preventDefault()
|
||||
// 备份
|
||||
@@ -2753,6 +2784,7 @@ const LabelPage = ({
|
||||
oldWorkLoad={oldWorkLoad}
|
||||
updateOldWorkLoad={updateOldWorkLoad}
|
||||
isLabelTask={isLabelTask}
|
||||
onOperationChange={handleSelectOperation}
|
||||
renderPolygons={
|
||||
paperContainerRef.current
|
||||
? paperContainerRef.current.renderPolygons
|
||||
|
||||
Reference in New Issue
Block a user