fix(tool): top tool
This commit is contained in:
@@ -307,6 +307,7 @@ const LabelPage = ({
|
|||||||
activeOperation,
|
activeOperation,
|
||||||
setActiveOperation,
|
setActiveOperation,
|
||||||
setDrawOption,
|
setDrawOption,
|
||||||
|
setSubAttrPresetShow,
|
||||||
showObjectList,
|
showObjectList,
|
||||||
showGroupList,
|
showGroupList,
|
||||||
showTaskList,
|
showTaskList,
|
||||||
@@ -1433,6 +1434,31 @@ const LabelPage = ({
|
|||||||
|
|
||||||
const { setShift, focusInput } = useKeyEventStore()
|
const { setShift, focusInput } = useKeyEventStore()
|
||||||
const drawAction = useKeyboardStore((state) => state.drawAction)
|
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<{
|
const drawShortcutSnapshotRef = useRef<{
|
||||||
activeOperation: string
|
activeOperation: string
|
||||||
drawOption: "default" | "intersect" | "unite"
|
drawOption: "default" | "intersect" | "unite"
|
||||||
@@ -1441,20 +1467,17 @@ const LabelPage = ({
|
|||||||
|
|
||||||
const handleShortcut = useCallback(
|
const handleShortcut = useCallback(
|
||||||
(key: string, ctrl: boolean) => {
|
(key: string, ctrl: boolean) => {
|
||||||
let checkOperation = getOperationSchema(key)
|
|
||||||
const mode = usePaperStore.getState().mode
|
const mode = usePaperStore.getState().mode
|
||||||
|
const nextOperationId = ctrl ? (+key + 10).toString() : key
|
||||||
|
const checkOperation = getOperationSchema(nextOperationId)
|
||||||
// 标注方案里面存在的非文本类型标注才能切换
|
// 标注方案里面存在的非文本类型标注才能切换
|
||||||
if (checkOperation) {
|
if (checkOperation) {
|
||||||
// 辅助标注模式下非多边形类型不能切换
|
// 辅助标注模式下非多边形类型不能切换
|
||||||
if (mode === "support" && checkOperation.label_type !== 102) return
|
if (mode === "support" && checkOperation.label_type !== 102) return
|
||||||
if (ctrl) {
|
handleSelectOperation(nextOperationId)
|
||||||
setActiveOperation((+key + 10).toString())
|
|
||||||
} else {
|
|
||||||
setActiveOperation(key)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[getOperationSchema, setActiveOperation]
|
[getOperationSchema, handleSelectOperation]
|
||||||
)
|
)
|
||||||
|
|
||||||
const resolveSelectedObjectContext = useCallback(() => {
|
const resolveSelectedObjectContext = useCallback(() => {
|
||||||
@@ -2564,6 +2587,14 @@ const LabelPage = ({
|
|||||||
drawShortcutSnapshotRef.current = null
|
drawShortcutSnapshotRef.current = null
|
||||||
}, [activeImage])
|
}, [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) => {
|
const handleBeforeUnload = (e: any) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
// 备份
|
// 备份
|
||||||
@@ -2753,6 +2784,7 @@ const LabelPage = ({
|
|||||||
oldWorkLoad={oldWorkLoad}
|
oldWorkLoad={oldWorkLoad}
|
||||||
updateOldWorkLoad={updateOldWorkLoad}
|
updateOldWorkLoad={updateOldWorkLoad}
|
||||||
isLabelTask={isLabelTask}
|
isLabelTask={isLabelTask}
|
||||||
|
onOperationChange={handleSelectOperation}
|
||||||
renderPolygons={
|
renderPolygons={
|
||||||
paperContainerRef.current
|
paperContainerRef.current
|
||||||
? paperContainerRef.current.renderPolygons
|
? paperContainerRef.current.renderPolygons
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ interface TopToolsComponentProps {
|
|||||||
oldWorkLoad: WorkLoad | null
|
oldWorkLoad: WorkLoad | null
|
||||||
updateOldWorkLoad: (data: WorkLoad) => void
|
updateOldWorkLoad: (data: WorkLoad) => void
|
||||||
isLabelTask: boolean
|
isLabelTask: boolean
|
||||||
|
onOperationChange: (operationId: string) => void
|
||||||
renderPolygons: (
|
renderPolygons: (
|
||||||
operationId: string,
|
operationId: string,
|
||||||
imageData: Map<string, [number, any[], any, any[]][]> | undefined
|
imageData: Map<string, [number, any[], any, any[]][]> | undefined
|
||||||
@@ -161,6 +162,7 @@ const TopTools = (
|
|||||||
oldWorkLoad,
|
oldWorkLoad,
|
||||||
updateOldWorkLoad,
|
updateOldWorkLoad,
|
||||||
isLabelTask,
|
isLabelTask,
|
||||||
|
onOperationChange,
|
||||||
renderPolygons,
|
renderPolygons,
|
||||||
} = props
|
} = props
|
||||||
const { backUrl, basePath } = useBackUrlStore()
|
const { backUrl, basePath } = useBackUrlStore()
|
||||||
@@ -2312,7 +2314,7 @@ const TopTools = (
|
|||||||
<UnstyledButton
|
<UnstyledButton
|
||||||
key={item.category_id}
|
key={item.category_id}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setActiveOperation(item.category_id.toString())
|
onOperationChange(item.category_id.toString())
|
||||||
setOperationPickerOpened(false)
|
setOperationPickerOpened(false)
|
||||||
setOperationKeyword("")
|
setOperationKeyword("")
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user