From 58c69975cc1703931ba1669818f0075311bbc588 Mon Sep 17 00:00:00 2001 From: guhaomine <18380425155@163.com> Date: Thu, 22 Feb 2024 16:06:08 +0800 Subject: [PATCH] fix: bugs Signed-off-by: guhaomine <18380425155@163.com> --- .../src/business/chengdu/Editor.vue | 299 ------ .../src/business/chengdu/actions/flow.ts | 65 -- .../src/business/chengdu/actions/index.ts | 1 - .../src/business/chengdu/api/aiTools.ts | 27 - .../src/business/chengdu/api/base.ts | 70 -- .../src/business/chengdu/api/common.ts | 274 ------ .../src/business/chengdu/api/index.ts | 2 - .../src/business/chengdu/api/model.ts | 52 - .../src/business/chengdu/api/typing.ts | 37 - .../src/business/chengdu/common/BSError.ts | 10 - .../business/chengdu/common/DataManager.ts | 300 ------ .../business/chengdu/common/DataResource.ts | 196 ---- .../src/business/chengdu/common/Tool.ts | 435 --------- .../chengdu/components/Collapse/index.vue | 73 -- .../chengdu/components/Header/TheKeyboard.vue | 255 ----- .../chengdu/components/Header/data.ts | 90 -- .../chengdu/components/Header/index.vue | 465 --------- .../chengdu/components/Header/useHeader.ts | 308 ------ .../chengdu/components/MainView/EditClass.vue | 291 ------ .../chengdu/components/MainView/index.vue | 19 - .../components/MainView/sub/AttrValue.vue | 65 -- .../chengdu/components/MainView/sub/Check.vue | 33 - .../chengdu/components/MainView/sub/Radio.vue | 36 - .../components/MainView/sub/Select.vue | 36 - .../chengdu/components/MainView/sub/Text.vue | 31 - .../chengdu/components/Modal/ModelRun.vue | 240 ----- .../Operation/Classification/AttrValue.vue | 90 -- .../Operation/Classification/index.vue | 96 -- .../components/Operation/Instance/Filter.vue | 114 --- .../components/Operation/Instance/Header.vue | 294 ------ .../components/Operation/Instance/Item.vue | 159 --- .../components/Operation/Instance/index.vue | 264 ----- .../components/Operation/Instance/type.ts | 50 - .../Operation/Instance/useInstance.ts | 529 ---------- .../components/Operation/Instance/useItem.ts | 47 - .../Operation/Instructions/index.vue | 36 - .../components/Operation/Results/index.vue | 181 ---- .../chengdu/components/Operation/index.vue | 40 - .../business/chengdu/components/Tool/Info.vue | 55 -- .../components/Tool/InteractiveConfig.vue | 215 ---- .../chengdu/components/Tool/Setting.vue | 296 ------ .../chengdu/components/Tool/index.vue | 378 -------- .../business/chengdu/components/Tool/item.ts | 157 --- .../chengdu/components/Tool/modelConfig.vue | 215 ---- .../chengdu/components/Tool/useTool.ts | 171 ---- .../src/business/chengdu/config/action.ts | 31 - .../src/business/chengdu/config/event.ts | 5 - .../src/business/chengdu/config/hotkey.ts | 14 - .../src/business/chengdu/config/mode.ts | 67 -- .../src/business/chengdu/config/type.ts | 0 .../src/business/chengdu/config/ui.ts | 22 - .../src/business/chengdu/data/classType.ts | 90 -- .../src/business/chengdu/hook/useFlow.ts | 85 -- .../src/business/chengdu/hook/useQuery.ts | 7 - .../src/business/chengdu/hook/useToken.ts | 19 - .../src/business/chengdu/hook/useTool.ts | 63 -- .../src/business/chengdu/hook/useUI.ts | 37 - .../src/business/chengdu/pages/dev.ts | 27 - .../src/business/chengdu/pages/execute.ts | 55 -- .../src/business/chengdu/pages/index.ts | 3 - .../src/business/chengdu/pages/view.ts | 68 -- .../src/business/chengdu/registry.ts | 10 - .../image-tool/src/business/chengdu/state.ts | 75 -- .../image-tool/src/business/chengdu/type.ts | 246 ----- .../src/business/chengdu/utils/classType.ts | 34 - .../business/chengdu/utils/classification.ts | 308 ------ .../src/business/chengdu/utils/common.ts | 25 - .../src/business/chengdu/utils/confirm.css | 8 - .../src/business/chengdu/utils/confirm.less | 10 - .../src/business/chengdu/utils/confirm.ts | 41 - .../src/business/chengdu/utils/error.ts | 15 - .../src/business/chengdu/utils/index.ts | 6 - .../src/business/chengdu/utils/result.ts | 252 ----- .../image-tool/src/businessNew/api/data.ts | 28 + .../businessNew/components/Layout/index.vue | 1 + .../components/Modal/HotkeyHelp/index.ts | 12 +- .../Operation/Results/components/Item.vue | 59 +- .../components/Operation/Results/index.vue | 45 +- .../components/Operation/index.vue | 7 +- .../src/businessNew/configs/action.ts | 1 + .../src/businessNew/hook/useDataflow.ts | 20 +- .../src/businessNew/hook/useQuery.ts | 2 +- .../image-tool/src/businessNew/pages/view.ts | 4 +- .../src/editor/ActionManager/action/clip.ts | 25 - .../src/editor/ActionManager/action/common.ts | 80 -- .../src/editor/ActionManager/action/index.ts | 6 - .../src/editor/ActionManager/action/page.ts | 29 - .../editor/ActionManager/action/translate.ts | 25 - .../editor/ActionManager/action/undo-redo.ts | 20 - .../src/editor/ActionManager/action/viewUI.ts | 39 - .../src/editor/ActionManager/define.ts | 27 - .../src/editor/ActionManager/index.ts | 106 -- .../src/editor/ActionManager/type.ts | 4 - .../src/editor/CmdManager/CmdBase.ts | 30 - .../src/editor/CmdManager/cmd/AddInterior.ts | 20 - .../src/editor/CmdManager/cmd/AddModelRun.ts | 35 - .../src/editor/CmdManager/cmd/AddObject.ts | 39 - .../src/editor/CmdManager/cmd/AddPoint.ts | 22 - .../src/editor/CmdManager/cmd/ClipPolygon.ts | 35 - .../src/editor/CmdManager/cmd/DeleteObject.ts | 22 - .../src/editor/CmdManager/cmd/HotkeyMove.ts | 38 - .../src/editor/CmdManager/cmd/MoveObject.ts | 33 - .../src/editor/CmdManager/cmd/MovePoint.ts | 20 - .../src/editor/CmdManager/cmd/MoveSide.ts | 22 - .../editor/CmdManager/cmd/RemoveInterior.ts | 20 - .../src/editor/CmdManager/cmd/RemovePoint.ts | 19 - .../src/editor/CmdManager/cmd/SelectObject.ts | 24 - .../src/editor/CmdManager/cmd/Update2DBox.ts | 54 -- .../src/editor/CmdManager/cmd/Update2DRect.ts | 37 - .../editor/CmdManager/cmd/UpdateTransform.ts | 38 - .../editor/CmdManager/cmd/UpdateUserData.ts | 43 - .../src/editor/CmdManager/cmd/index.ts | 80 -- .../image-tool/src/editor/CmdManager/index.ts | 82 -- .../image-tool/src/editor/CmdManager/type.ts | 2 - frontend/image-tool/src/editor/Editor.ts | 197 ---- .../src/editor/HotkeyManager/config.ts | 0 .../src/editor/HotkeyManager/index.ts | 69 -- .../src/editor/HotkeyManager/type.ts | 9 - .../src/editor/ImageLabel/config.ts | 33 - .../src/editor/ImageLabel/domeventhandle.js | 55 -- .../editor/ImageLabel/helper/bisectrixline.js | 124 --- .../ImageLabel/helper/icon/iconcache.js | 32 - .../image-tool/src/editor/ImageLabel/index.ts | 791 --------------- .../src/editor/ImageLabel/layer/background.ts | 91 -- .../editor/ImageLabel/layer/singleimage.ts | 131 --- .../ImageLabel/region/base/base_shape.js | 869 ----------------- .../ImageLabel/region/base/base_tool.js | 48 - .../region/interactive/interactive_shape.js | 456 --------- .../region/interactive/interactive_tool.js | 524 ---------- .../ImageLabel/region/polygon/polygon.js | 104 -- .../region/polygon/polygon_shape.js | 534 ---------- .../ImageLabel/region/polygon/polygon_tool.js | 127 --- .../region/polyline/polyline_shape.js | 329 ------- .../region/polyline/polyline_tool.js | 247 ----- .../region/rectangle/rectangle_shape.js | 269 ----- .../region/rectangle/rectangle_tool.js | 123 --- .../editor/ImageLabel/region/shape_index.js | 11 - .../src/editor/ImageLabel/region/shapelist.js | 68 -- .../src/editor/ImageLabel/region/tagable.js | 18 - .../src/editor/ImageLabel/tools/tool_index.js | 11 - .../editor/ImageLabel/tools/toolmanager.js | 105 -- .../image-tool/src/editor/ImageLabel/util.ts | 916 ------------------ .../src/editor/components/Modal/Confirm.ts | 29 - .../src/editor/components/Modal/Loading.vue | 74 -- .../src/editor/components/Modal/Message.ts | 13 - .../src/editor/components/Modal/Warning.ts | 30 - .../src/editor/components/Modal/index.vue | 143 --- .../components/Modal/sub/Annotation.vue | 109 --- .../image-tool/src/editor/config/event.ts | 26 - .../image-tool/src/editor/config/hotkey.ts | 77 -- .../image-tool/src/editor/config/keyboard.ts | 200 ---- frontend/image-tool/src/editor/config/mode.ts | 53 - frontend/image-tool/src/editor/config/type.ts | 22 - frontend/image-tool/src/editor/index.ts | 23 - frontend/image-tool/src/editor/inject.ts | 23 - frontend/image-tool/src/editor/state.ts | 139 --- frontend/image-tool/src/editor/type.ts | 182 ---- .../src/package/image-editor/Editor.ts | 9 +- .../common/ActionManager/action/common.ts | 12 + .../image-editor/common/LoadManager.ts | 60 +- .../image-editor/common/TrackManager.ts | 4 + .../package/image-editor/configs/hotkey.ts | 3 +- .../image-editor/configs/tools/config.ts | 4 +- .../src/package/image-editor/types/enum.ts | 2 +- 164 files changed, 244 insertions(+), 17259 deletions(-) delete mode 100644 frontend/image-tool/src/business/chengdu/Editor.vue delete mode 100644 frontend/image-tool/src/business/chengdu/actions/flow.ts delete mode 100644 frontend/image-tool/src/business/chengdu/actions/index.ts delete mode 100644 frontend/image-tool/src/business/chengdu/api/aiTools.ts delete mode 100644 frontend/image-tool/src/business/chengdu/api/base.ts delete mode 100644 frontend/image-tool/src/business/chengdu/api/common.ts delete mode 100644 frontend/image-tool/src/business/chengdu/api/index.ts delete mode 100644 frontend/image-tool/src/business/chengdu/api/model.ts delete mode 100644 frontend/image-tool/src/business/chengdu/api/typing.ts delete mode 100644 frontend/image-tool/src/business/chengdu/common/BSError.ts delete mode 100644 frontend/image-tool/src/business/chengdu/common/DataManager.ts delete mode 100644 frontend/image-tool/src/business/chengdu/common/DataResource.ts delete mode 100644 frontend/image-tool/src/business/chengdu/common/Tool.ts delete mode 100644 frontend/image-tool/src/business/chengdu/components/Collapse/index.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Header/TheKeyboard.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Header/data.ts delete mode 100644 frontend/image-tool/src/business/chengdu/components/Header/index.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Header/useHeader.ts delete mode 100644 frontend/image-tool/src/business/chengdu/components/MainView/EditClass.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/MainView/index.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/MainView/sub/AttrValue.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/MainView/sub/Check.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/MainView/sub/Radio.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/MainView/sub/Select.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/MainView/sub/Text.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Modal/ModelRun.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Classification/AttrValue.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Classification/index.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Instance/Filter.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Instance/Header.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Instance/Item.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Instance/index.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Instance/type.ts delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Instance/useInstance.ts delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Instance/useItem.ts delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Instructions/index.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/Results/index.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Operation/index.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Tool/Info.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Tool/InteractiveConfig.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Tool/Setting.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Tool/index.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Tool/item.ts delete mode 100644 frontend/image-tool/src/business/chengdu/components/Tool/modelConfig.vue delete mode 100644 frontend/image-tool/src/business/chengdu/components/Tool/useTool.ts delete mode 100644 frontend/image-tool/src/business/chengdu/config/action.ts delete mode 100644 frontend/image-tool/src/business/chengdu/config/event.ts delete mode 100644 frontend/image-tool/src/business/chengdu/config/hotkey.ts delete mode 100644 frontend/image-tool/src/business/chengdu/config/mode.ts delete mode 100644 frontend/image-tool/src/business/chengdu/config/type.ts delete mode 100644 frontend/image-tool/src/business/chengdu/config/ui.ts delete mode 100644 frontend/image-tool/src/business/chengdu/data/classType.ts delete mode 100644 frontend/image-tool/src/business/chengdu/hook/useFlow.ts delete mode 100644 frontend/image-tool/src/business/chengdu/hook/useQuery.ts delete mode 100644 frontend/image-tool/src/business/chengdu/hook/useToken.ts delete mode 100644 frontend/image-tool/src/business/chengdu/hook/useTool.ts delete mode 100644 frontend/image-tool/src/business/chengdu/hook/useUI.ts delete mode 100644 frontend/image-tool/src/business/chengdu/pages/dev.ts delete mode 100644 frontend/image-tool/src/business/chengdu/pages/execute.ts delete mode 100644 frontend/image-tool/src/business/chengdu/pages/index.ts delete mode 100644 frontend/image-tool/src/business/chengdu/pages/view.ts delete mode 100644 frontend/image-tool/src/business/chengdu/registry.ts delete mode 100644 frontend/image-tool/src/business/chengdu/state.ts delete mode 100644 frontend/image-tool/src/business/chengdu/type.ts delete mode 100644 frontend/image-tool/src/business/chengdu/utils/classType.ts delete mode 100644 frontend/image-tool/src/business/chengdu/utils/classification.ts delete mode 100644 frontend/image-tool/src/business/chengdu/utils/common.ts delete mode 100644 frontend/image-tool/src/business/chengdu/utils/confirm.css delete mode 100644 frontend/image-tool/src/business/chengdu/utils/confirm.less delete mode 100644 frontend/image-tool/src/business/chengdu/utils/confirm.ts delete mode 100644 frontend/image-tool/src/business/chengdu/utils/error.ts delete mode 100644 frontend/image-tool/src/business/chengdu/utils/index.ts delete mode 100644 frontend/image-tool/src/business/chengdu/utils/result.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/action/clip.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/action/common.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/action/index.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/action/page.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/action/translate.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/action/undo-redo.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/action/viewUI.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/define.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/index.ts delete mode 100644 frontend/image-tool/src/editor/ActionManager/type.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/CmdBase.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/AddInterior.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/AddModelRun.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/AddObject.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/AddPoint.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/ClipPolygon.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/DeleteObject.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/HotkeyMove.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/MoveObject.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/MovePoint.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/MoveSide.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/RemoveInterior.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/RemovePoint.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/SelectObject.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/Update2DBox.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/Update2DRect.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/UpdateTransform.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/UpdateUserData.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/cmd/index.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/index.ts delete mode 100644 frontend/image-tool/src/editor/CmdManager/type.ts delete mode 100644 frontend/image-tool/src/editor/Editor.ts delete mode 100644 frontend/image-tool/src/editor/HotkeyManager/config.ts delete mode 100644 frontend/image-tool/src/editor/HotkeyManager/index.ts delete mode 100644 frontend/image-tool/src/editor/HotkeyManager/type.ts delete mode 100644 frontend/image-tool/src/editor/ImageLabel/config.ts delete mode 100644 frontend/image-tool/src/editor/ImageLabel/domeventhandle.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/helper/bisectrixline.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/helper/icon/iconcache.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/index.ts delete mode 100644 frontend/image-tool/src/editor/ImageLabel/layer/background.ts delete mode 100644 frontend/image-tool/src/editor/ImageLabel/layer/singleimage.ts delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/base/base_shape.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/base/base_tool.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/interactive/interactive_shape.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/interactive/interactive_tool.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/polygon/polygon.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/polygon/polygon_shape.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/polygon/polygon_tool.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/polyline/polyline_shape.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/polyline/polyline_tool.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/rectangle/rectangle_shape.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/rectangle/rectangle_tool.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/shape_index.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/shapelist.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/region/tagable.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/tools/tool_index.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/tools/toolmanager.js delete mode 100644 frontend/image-tool/src/editor/ImageLabel/util.ts delete mode 100644 frontend/image-tool/src/editor/components/Modal/Confirm.ts delete mode 100644 frontend/image-tool/src/editor/components/Modal/Loading.vue delete mode 100644 frontend/image-tool/src/editor/components/Modal/Message.ts delete mode 100644 frontend/image-tool/src/editor/components/Modal/Warning.ts delete mode 100644 frontend/image-tool/src/editor/components/Modal/index.vue delete mode 100644 frontend/image-tool/src/editor/components/Modal/sub/Annotation.vue delete mode 100644 frontend/image-tool/src/editor/config/event.ts delete mode 100644 frontend/image-tool/src/editor/config/hotkey.ts delete mode 100644 frontend/image-tool/src/editor/config/keyboard.ts delete mode 100644 frontend/image-tool/src/editor/config/mode.ts delete mode 100644 frontend/image-tool/src/editor/config/type.ts delete mode 100644 frontend/image-tool/src/editor/index.ts delete mode 100644 frontend/image-tool/src/editor/inject.ts delete mode 100644 frontend/image-tool/src/editor/state.ts delete mode 100644 frontend/image-tool/src/editor/type.ts diff --git a/frontend/image-tool/src/business/chengdu/Editor.vue b/frontend/image-tool/src/business/chengdu/Editor.vue deleted file mode 100644 index d5473e3b..00000000 --- a/frontend/image-tool/src/business/chengdu/Editor.vue +++ /dev/null @@ -1,299 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/actions/flow.ts b/frontend/image-tool/src/business/chengdu/actions/flow.ts deleted file mode 100644 index 9e61edae..00000000 --- a/frontend/image-tool/src/business/chengdu/actions/flow.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Editor, defineAction } from 'editor'; -import Event from '../config/event'; - -export const flowHung = defineAction({ - valid(editor: Editor) { - return true; - }, - execute(editor: Editor) { - editor.dispatchEvent({ type: Event.FLOW_ACTION, data: 'hung' }); - }, -}); - -export const flowReject = defineAction({ - valid(editor: Editor) { - return true; - }, - execute(editor: Editor) { - editor.dispatchEvent({ type: Event.FLOW_ACTION, data: 'reject' }); - }, -}); - -export const flowSubmit = defineAction({ - valid(editor: Editor) { - return true; - }, - execute(editor: Editor) { - editor.dispatchEvent({ type: Event.FLOW_ACTION, data: 'submit' }); - }, -}); - -export const flowSubmitExit = defineAction({ - valid(editor: Editor) { - return true; - }, - execute(editor: Editor) { - editor.dispatchEvent({ type: Event.FLOW_ACTION, data: 'submitExit' }); - }, -}); - -export const flowSave = defineAction({ - valid(editor: Editor) { - return true; - }, - execute(editor: Editor) { - editor.dispatchEvent({ type: Event.FLOW_ACTION, data: 'save' }); - }, -}); - -export const flowPass = defineAction({ - valid(editor: Editor) { - return true; - }, - execute(editor: Editor) { - editor.dispatchEvent({ type: Event.FLOW_ACTION, data: 'pass' }); - }, -}); - -export const flowEdit = defineAction({ - valid(editor: Editor) { - return true; - }, - execute(editor: Editor) { - editor.dispatchEvent({ type: Event.FLOW_ACTION, data: 'edit' }); - }, -}); diff --git a/frontend/image-tool/src/business/chengdu/actions/index.ts b/frontend/image-tool/src/business/chengdu/actions/index.ts deleted file mode 100644 index 5851cb1e..00000000 --- a/frontend/image-tool/src/business/chengdu/actions/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './flow'; diff --git a/frontend/image-tool/src/business/chengdu/api/aiTools.ts b/frontend/image-tool/src/business/chengdu/api/aiTools.ts deleted file mode 100644 index 420335c7..00000000 --- a/frontend/image-tool/src/business/chengdu/api/aiTools.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { get, post } from './base'; -import { Point } from '../type'; -import { AxiosRequestConfig } from 'axios'; - -export async function getModelList() {} - -interface IClickSeq extends Point { - type: string; -} -export interface IIdentify { - crop: Point[]; - clickSeq: IClickSeq[]; - imgUrl: string; -} - -export async function identifyImage(params: IIdentify, config: AxiosRequestConfig) { - const url = '/api/dataset/annotation/object/image/identify'; - - return await post( - url, - { - datas: [params], - params: {}, - }, - config, - ); -} diff --git a/frontend/image-tool/src/business/chengdu/api/base.ts b/frontend/image-tool/src/business/chengdu/api/base.ts deleted file mode 100644 index 7e502bd3..00000000 --- a/frontend/image-tool/src/business/chengdu/api/base.ts +++ /dev/null @@ -1,70 +0,0 @@ -import axios, { AxiosRequestHeaders, AxiosRequestConfig } from 'axios'; -import BSError from '../common/BSError'; - -// token -export const requestConfig = { - token: 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIzMDA4MCIsInRlYW1JZCI6IjUxIiwiaXNzIjoiYmFzaWMuYWkiLCJpYXQiOjE2NTI0MDc3MDcsImV4cCI6MTY1MjQ1MDkwN30.HC2tAjiDdYpjVvlnLXfNO_2_V7b0AAHrLVPm7Ox0tyuBA-c4-asQnDkbu6P4Nn1yvW2K9-8THpJEnOruA1Yf5g', -}; - -export function setToken(token: string) { - requestConfig.token = token; -} - -function isResource(headers: AxiosRequestHeaders) { - // 'x-request-type': 'resource' - return headers['x-request-type'] === 'resource'; -} - -// Service -let host = location.hostname || location.host; -const BaseURL = ''; -export const Service = axios.create({ - timeout: 1000 * 60 * 20, // 请求超时时间 - baseURL: BaseURL, - headers: { - 'Content-Type': 'application/json', - }, -}); - -Service.interceptors.request.use((config) => { - config.headers = config.headers || {}; - if (!isResource(config.headers)) { - config.headers['Authorization'] = requestConfig.token; - } - - return config; -}); - -Service.interceptors.response.use( - (response) => { - let data = response.data; - if (!isResource(response.config.headers || {}) && data.message) { - return Promise.reject(new BSError('', 'Network Error')); - } - return data; - }, - (error) => { - return Promise.reject(new BSError('', 'Network Error')); - }, -); - -export function get(url: string, data?: any, config?: AxiosRequestConfig) { - return Service.request({ - url, - method: 'get', - params: data, - ...config, - }); -} - -export function post(url: string, data?: any, config?: AxiosRequestConfig) { - let headers = {} as AxiosRequestHeaders; - - return Service.request({ - url, - data, - method: 'post', - headers, - ...config, - }); -} diff --git a/frontend/image-tool/src/business/chengdu/api/common.ts b/frontend/image-tool/src/business/chengdu/api/common.ts deleted file mode 100644 index e431ac7f..00000000 --- a/frontend/image-tool/src/business/chengdu/api/common.ts +++ /dev/null @@ -1,274 +0,0 @@ -import { get, post } from './base'; -import { - IModelResult, - IDataMeta, - IClassType, - IFileConfig, - IResultSource, - SourceType, -} from '../type'; -import { traverseClassification2Arr, empty, parseClassesFromBackend } from '../utils'; - -enum Api { - API = '/api', - DATA = '/api/data', - DATASET_ANNOTATION = '/api/annotate', - DATASET_DATA = '/api/data', - ANNOTATION = '/api', -} - -export async function getUrl(url: string) { - return get(url, null, { headers: { 'x-request-type': 'resource' } }); -} -// annotation ------- -export async function saveObject(config: any) { - let url = `${Api.DATASET_ANNOTATION}/object/save`; - let data = await post(url, config); - data = data.data || []; - - let keyMap = {} as Record>; - data.forEach((e: any) => { - let dataId = e.dataId + ''; - keyMap[dataId] = keyMap[dataId] || {}; - keyMap[dataId][e.frontId + ''] = e.id + ''; - }); - - return keyMap; -} - -export async function getDataObject(dataId: string) { - let url = `${Api.DATASET_ANNOTATION}/object/listByDataIds`; - let data = await get(url, { dataIds: dataId }); - data = data.data || []; - - let objects = [] as any[]; - (data.dataAnnotationObjects || []).forEach((e: any) => { - e.classAttributes.uuid = e.id + ''; - e.classAttributes.modelRun = empty(e.modelRunId) ? '' : e.modelRunId + ''; - objects.push(e.classAttributes); - }); - return { - objects, - queryTime: data.queryDate, - }; -} - -export async function saveDataClassification(config: any) { - let url = `${Api.DATASET_ANNOTATION}/data/save`; - await post(url, config); -} - -export async function getDataClassification(dataId: string) { - let url = `${Api.DATASET_ANNOTATION}/data/listByDataIds`; - let data = await get(url, { dataIds: dataId }); - data = data.data || {}; - let dataAnnotations = data.dataAnnotations || []; - - let attrsMap = {}; - dataAnnotations.forEach((e: any) => { - Object.assign(attrsMap, e.classificationAttributes || {}); - }); - return attrsMap; -} - -// data ------- -export async function getDataFile(dataId: string) { - let url = `${Api.DATASET_DATA}/listByIds`; - let data = await get(url, { dataIds: dataId }); - - data = data.data || []; - // console.log('getDataFile', data); - let configs = [] as IFileConfig[]; - data[0].content.forEach((config: any) => { - let file = config.file || (config.files && config.files[0]?.file); - configs.push({ - name: config.name, - size: +file.size, - url: file.url, - }); - }); - - const annotationStatus = data[0].annotationStatus; - const validStatus = data[0].status; - - return { - info: configs[0], - annotationStatus, - validStatus, - }; -} -export async function unlockRecord(recordId: string) { - let url = `${Api.DATASET_DATA}/unLock/${recordId}`; - return await post(url); -} -export async function getInfoByRecordId(recordId: string) { - let url = `${Api.DATASET_DATA}/findDataAnnotationRecord/${recordId}`; - let data = await get(url); - data = data.data; - // no result - if (!data) return { dataInfos: [], isSeriesFrame: false, seriesFrameId: '' }; - - let isSeriesFrame = data.dataType === 'FRAME_SERIES'; - let seriesFrameId = data.frameSeriesId ? data.frameSeriesId + '' : ''; - let modelRecordId = data.serialNo || ''; - let model = undefined as IModelResult | undefined; - if (modelRecordId) { - model = { - recordId: modelRecordId, - id: '', - version: '', - state: '', - }; - } - let dataInfos: IDataMeta[] = []; - (data.datas || []).forEach((config: any) => { - dataInfos.push({ - // id: config.id, - dataId: config.dataId, - datasetId: config.datasetId, - needSave: false, - model: model, - } as IDataMeta); - }); - - return { dataInfos, isSeriesFrame, seriesFrameId }; -} - -export async function getDataSetClassification(datasetId: string) { - let url = `${Api.ANNOTATION}/datasetClassification/findAll/${datasetId}`; - let data = await get(url); - data = data.data || []; - - let classifications = traverseClassification2Arr(data); - - return classifications; -} - -export async function getDataSetClass(datasetId: string) { - let url = `${Api.ANNOTATION}/datasetClass/findAll/${datasetId}`; - let data = await get(url); - data = data.data || []; - - let classTypes = parseClassesFromBackend(data); - - return classTypes; -} - -/** Data flow */ -export async function setInvalid(dataId: string) { - const url = `${Api.API}/data/flow/markAsInvalid/${dataId}`; - await post(url); -} -export async function setValid(dataId: string) { - const url = `${Api.API}/data/flow/markAsValid/${dataId}`; - await post(url); -} -export async function submit(dataId: string) { - const url = `${Api.API}/data/flow/submit/${dataId}`; - await post(url); -} - -export async function takeRecordByData(params: any) { - const url = `${Api.DATASET_DATA}/annotate`; - console.log(123); - const res = await post(url, params); - return res; -} - -export async function getAnnotationStatus(datasetId: string) { - let url = `${Api.DATASET_DATA}/getAnnotationStatusStatisticsByDatasetId`; - let data = await get(url, { datasetId: datasetId }); - - data = data.data || []; - - return data; -} - -export async function getDataStatusByIds(dataId: string) { - let url = `${Api.DATASET_DATA}/getDataStatusByIds`; - let data = await get(url, { dataIds: dataId }); - - data = data.data || []; - - return data[0]; -} - -/** Get Data Annotation By DataIds */ -export interface IGetAnnotationParams { - classificationValues: any[]; - dataId: number; - objects: any[]; -} -export async function getAnnotationByDataIds(dataIds: Array) { - const url = `${Api.DATASET_ANNOTATION}/data/listByDataIds`; - - const res = await get(url, { dataIds: dataIds.join(',') }); - const data = res.data as IGetAnnotationParams; - // console.log(data[0]); - const { classificationValues } = data[0]; - - const classifications = classificationValues.map((item: any) => item.classificationAttributes); - - return { - ...data[0], - classificationValues: classifications, - }; -} - -/** Save */ -export interface ISaveAnnotationParams { - datasetId: number | string; - dataInfos: Array; -} -export interface IDataInfos { - dataId: number; - objects: IObjects; - dataAnnotations: IAnnotation; -} -export interface IObjects { - id: number; - frontId: string; - classId: number; - classAttributes: any; -} -export interface IAnnotation { - id: number; - classificationId: string; - classificationAttributes: any; -} -export async function saveAnnotation(params: ISaveAnnotationParams) { - const url = `${Api.DATASET_ANNOTATION}/data/save`; - - let data = await post(url, params); - data = data.data || []; - let keyMap = {} as Record>; - data.forEach((e: any) => { - let dataId = e.dataId; - keyMap[dataId] = keyMap[dataId] || {}; - keyMap[dataId][e.frontId] = e.id; - }); - - return keyMap; -} -export async function getResultSources(dataId: string) { - let url = `/api/data/getDataModelRunResult/${dataId}`; - // let url = `/api/dataset/dataset/getDatasetAnnotateResult/${datasetId}`; - let data = await get(url); - - data = data.data || {}; - - let sources = [] as IResultSource[]; - data.forEach((item: any) => { - let { modelId, modelName, runRecords = [] } = item; - runRecords.forEach((e: any) => { - sources.push({ - name: e.runNo, - sourceId: e.id, - modelId: modelId, - modelName: modelName, - sourceType: SourceType.MODEL, - }); - }); - }); - return sources.filter((e) => e.sourceType !== SourceType.DATA_FLOW); -} diff --git a/frontend/image-tool/src/business/chengdu/api/index.ts b/frontend/image-tool/src/business/chengdu/api/index.ts deleted file mode 100644 index f701b53a..00000000 --- a/frontend/image-tool/src/business/chengdu/api/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './common'; -export * from './model'; diff --git a/frontend/image-tool/src/business/chengdu/api/model.ts b/frontend/image-tool/src/business/chengdu/api/model.ts deleted file mode 100644 index 06c612e5..00000000 --- a/frontend/image-tool/src/business/chengdu/api/model.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { get, post } from './base'; -import { IModel, IModelClass } from '../type'; - -export async function getModelList() { - let url = '/api/model/list'; - let data = await get(url); - data = data.data || []; - - let models = [] as IModel[]; - data.forEach((e: any) => { - if (e.datasetType !== 'IMAGE') return; - let classes = (e.classes || []) as IModelClass[]; - // The model of COCO has subClass - classes = classes - .map((item) => { - return item.subClasses || item; - }) - .flat(1) - .map((e: any) => { - return { ...e, label: e.name, value: e.code }; - }); - models.push({ - id: e.id + '', - name: e.name, - version: e.version, - code: e.modelCode, - classes, - }); - }); - - return models; -} - -export async function clearModel(dataIds: number[], recordId: string) { - let url = `/api/data/removeModelDataResult`; - let data = await post(url, { serialNo: recordId, dataIds }); -} - -export async function getModelResult(dataIds: string[], recordId: string) { - let url = '/api/data/modelAnnotationResult'; - let args = []; - dataIds.forEach((e) => { - args.push(`dataIds=${e}`); - }); - args.push(`serialNo=${recordId}`); - return await get(`${url}?${args.join('&')}`); -} - -export async function runModel(config: any) { - let url = '/api/data/modelAnnotate'; - return await post(url, config); -} diff --git a/frontend/image-tool/src/business/chengdu/api/typing.ts b/frontend/image-tool/src/business/chengdu/api/typing.ts deleted file mode 100644 index 8da321b4..00000000 --- a/frontend/image-tool/src/business/chengdu/api/typing.ts +++ /dev/null @@ -1,37 +0,0 @@ -export interface IClassification { - id: string; - name: string; - label?: string; - attrs: IClassificationAttr[]; -} -export interface IClassificationAttr { - classificationId: string; - parent: string; - parentAttr: string; - parentValue: any; - key: string; - id: string; - type: AttrType; - name: string; - label?: string; - required: boolean; - options: { value: any; label: string }[]; - value: any; - leafFlag?: boolean; -} - -export enum AttrType { - RADIO = 'RADIO', - MULTI_SELECTION = 'MULTI_SELECTION', - DROPDOWN = 'DROPDOWN', - TEXT = 'TEXT', -} - -export interface IClassAttr { - label: string; - name: string; - options: IClassAttr[]; - required?: boolean; - type: AttrType; - value: any; -} diff --git a/frontend/image-tool/src/business/chengdu/common/BSError.ts b/frontend/image-tool/src/business/chengdu/common/BSError.ts deleted file mode 100644 index 2f8bb422..00000000 --- a/frontend/image-tool/src/business/chengdu/common/BSError.ts +++ /dev/null @@ -1,10 +0,0 @@ -export default class BSError { - code: string; - message: string; - oriError: any; - constructor(code?: string, message?: string, oriError?: any) { - this.code = code || ''; - this.message = message || ''; - this.oriError = oriError; - } -} diff --git a/frontend/image-tool/src/business/chengdu/common/DataManager.ts b/frontend/image-tool/src/business/chengdu/common/DataManager.ts deleted file mode 100644 index 0b6cc9fd..00000000 --- a/frontend/image-tool/src/business/chengdu/common/DataManager.ts +++ /dev/null @@ -1,300 +0,0 @@ -import { IObject, IDataMeta, IModelResult, AnnotateObject } from '../type'; -import Tool from './Tool'; -import * as api from '../api'; -import * as utils from '../utils'; -import { Event, ICmdName, ICmdOption } from 'editor'; -import { isArray } from 'lodash'; -import { convertModelRunResult } from '../utils'; - -let timer: any; - -export default class DataManager { - tool: Tool; - dataMap: Record = {}; - modelMap: Record = {}; - constructor(tool: Tool) { - this.tool = tool; - this.initEvent(); - } - - initEvent() { - // this.tool.editor.on(Event.ADD_OBJECT, () => { - // this.handleEditorResultChange(); - // }); - this.tool.editor.on(Event.ADD_OBJECT, (data: any) => { - let object = data?.data?.object; - if (object) { - this.onEditorAdd(object.toJSON()); - } - }); - this.tool.editor.on(Event.REMOVE_OBJECT, (data: any) => { - let ids = data?.data?.removed || []; - let { dataList, dataIndex } = this.tool.state; - let dataInfo = dataList[dataIndex]; - if (!dataInfo) return; - let allObjects = this.getDataObject(dataInfo.dataId) || []; - this.onEditorRemove(allObjects.filter((e) => ids.indexOf(e.uuid) >= 0)); - }); - this.tool.editor.on(Event.DIMENSION_CHANGE, (data: any) => { - let object = data?.data; - let { dataList, dataIndex } = this.tool.state; - let dataInfo = dataList[dataIndex]; - if (!dataInfo || !object) return; - let allObjects = this.getDataObject(dataInfo.dataId) || []; - let index = allObjects.findIndex((item) => item.uuid == object.uuid); - if (index > 0) { - allObjects[index] = object.toJSON(); - this.setDataObject(dataInfo.dataId, allObjects); - } - }); - [ - Event.ADD_OBJECT, - Event.CLEAR_DATA, - Event.DIMENSION_CHANGE, - Event.REMOVE_OBJECT, - Event.USER_DATA_CHANGE, - ].forEach((evt) => { - this.tool.editor.on(evt, () => { - this.handleEditorResultChange(); - }); - }); - // this.tool.editor.cmdManager.addEventListener(Event.EXECUTE, (data) => { - // this.handleEditorCmd(data.data.cmd, 'execute'); - // }); - this.tool.editor.cmdManager.addEventListener(Event.REDO, (data) => { - this.handleEditorCmd(data.data.cmd, 'redo'); - }); - this.tool.editor.cmdManager.addEventListener(Event.UNDO, (data) => { - this.handleEditorCmd(data.data.cmd, 'undo'); - }); - } - handleEditorResultChange() { - let { dataList, dataIndex } = this.tool.state; - let curData = dataList[dataIndex]; - // // let allObjects = this.getDataObject(curData.dataId) || []; - // let objects = this.tool.editor.getObjects(); - if (curData) curData.needSave = true; - // // allObjects.push(...objects); - // this.setDataObject(curData.dataId, objects); - } - handleEditorCmd(cmd: any, cmdType: 'undo' | 'redo' | 'execute') { - let { dataList, dataIndex } = this.tool.state; - let curData = dataList[dataIndex]; - - let name = cmd.name as ICmdName; - // if (name === 'add-object') { - // let data = cmd.data as any; - // if (cmdType === 'undo') { - // this.onEditorRemove(data); - // } else { - // this.onEditorAdd(data); - // } - // // console.log('handleEditorCmd', name, cmdType); - // } else - if (name === 'delete-object') { - let data = cmd.data as any; - if (cmdType === 'undo') { - this.onEditorAdd(data); - } else { - this.onEditorRemove(data); - } - // console.log('handleEditorCmd', name, cmdType); - } else if ( - name === 'update-2d-box' || - name === 'update-2d-rect' || - name === 'update-transform' || - name === 'update-userData' - ) { - curData.needSave = true; - } else { - return; - } - } - - onEditorAdd(objects: AnnotateObject[], dataInfo?: IDataMeta) { - // console.log('onEditorAdd', objects); - let { dataList, dataIndex } = this.tool.state; - - dataInfo = dataInfo || dataList[dataIndex]; - let allObjects = this.getDataObject(dataInfo.dataId) || []; - - dataInfo.needSave = true; - if (!isArray(objects)) { - objects = [objects]; - } - allObjects.push(...objects); - this.setDataObject(dataInfo.dataId, allObjects); - } - - onEditorRemove(objects: AnnotateObject[]) { - console.log('onEditorRemove', objects); - let { dataList, dataIndex } = this.tool.state; - let curData = dataList[dataIndex]; - let allObjects = this.dataMap[curData.dataId]; - if (!allObjects) return; - - curData.needSave = true; - - let removeMap = {} as Record; - if (!isArray(objects)) { - objects = [objects]; - } - objects.forEach((e) => { - removeMap[e.uuid] = true; - }); - - let remainObjects = allObjects.filter((e) => !removeMap[e.uuid]); - this.setDataObject(curData.dataId, remainObjects); - } - - setDataObject(dataId: string | number, objects: AnnotateObject[]) { - dataId = dataId + ''; - this.dataMap[dataId] = objects; - } - - getDataObject(dataId: string | number) { - dataId = dataId + ''; - return this.dataMap[dataId]; - } - - // model - getModelResult(dataId: number) { - return this.modelMap[dataId]; - } - clearModelResult(dataId: number) { - delete this.modelMap[dataId]; - } - - addModelTrackData(dataIds: string[], objectsMap: Record) { - let { dataList } = this.tool.state; - - let dataMap = {} as Record; - dataList.forEach((e) => { - dataMap[e.dataId] = e; - }); - - Object.keys(objectsMap).forEach((e) => { - let index = +e; - let dataId = dataIds[index]; - dataMap[dataId].needSave = true; - - let idStart = this.tool.getMaxId(dataId) + 1; - let objects = utils.convertObject2Annotate(objectsMap[e], this.tool.editor); - objects.forEach((e) => { - e.userData.id = idStart + ''; - idStart++; - }); - - if (objects.length > 0) { - this.onEditorAdd(objects, dataMap[dataId]); - } - }); - } - - async pollDataModelResult() { - let _this = this; - let { editor, state } = this.tool; - let modelMap = {} as Record; - let confidence = state.modelConfig.confidence || [0.5, 1]; - let dataList = this.tool.state.dataList; - - dataList.forEach((data) => { - if (data.model && data.model.state !== 'complete') { - let id = data.model.recordId; - modelMap[id] = modelMap[id] || []; - modelMap[id].push(data); - } - }); - - if (Object.keys(modelMap).length === 0) return; - - // console.log('pollModel'); - - let requests = [] as Promise[]; - Object.keys(modelMap).forEach((recordId) => { - requests.push(createRequest(recordId, modelMap[recordId])); - }); - console.log('requests', requests); - - await Promise.all(requests); - - setTimeout(this.pollDataModelResult.bind(this), 1000); - - function createRequest(recordId: string, dataList: IDataMeta[]) { - let ids = dataList.map((e) => e.dataId); - let request = api - .getModelResult(ids, recordId) - .then((data) => { - // console.log('getModelResult ==> ', data); - let { dataIndex, dataList } = _this.tool.state; - let curData = dataList[dataIndex]; - // return; - data = data.data || {}; - let resultList = data.modelDataResults; - if (!resultList) return; - - // let hasErrorMessage = resultList.some((item: any) => - // item.modelResult.message.includes('UnknownHostException'), - // ); - // console.log(hasErrorMessage); - - // if (hasErrorMessage) { - // console.log('Interval'); - // timer = setInterval(() => { - // return createRequest(recordId, dataList); - // }, 1000); - // } else { - // console.log('clearInterval'); - // clearInterval(timer); - // } - - let resultMap = {} as Record; - resultList.forEach((e: any) => { - resultMap[e.dataId] = e; - }); - - dataList.forEach((dataMeta) => { - let info = resultMap[dataMeta.dataId]; - let model = dataMeta.model as IModelResult; - - if (info) { - let modelResult = info.modelResult; - let objects = (modelResult.objects || []) as IObject[]; - if (modelResult.code != 'OK') { - dataMeta.model = undefined; - if (dataMeta.dataId === curData.dataId) - editor.showMsg('error', 'Model Run Error.'); - clearInterval(timer); - return; - } - if (objects.length > 0) { - // 更新状态 - model.state = 'complete'; - // 过滤 - objects = objects.filter((e) => { - let c = e.confidence; - return !c || (c >= confidence[0] && c <= confidence[1]); - }); - _this.modelMap[dataMeta.dataId] = convertModelRunResult(objects); - } else { - dataMeta.model = undefined; - if (dataMeta.dataId === curData.dataId) - editor.showMsg('warning', 'No Model Results.'); - } - } else { - dataMeta.model = undefined; - if (dataMeta.dataId === curData.dataId) - editor.showMsg('warning', 'No Model Results.'); - } - }); - - // data.forEach((info: any) => { - }) - .catch(() => { - clearInterval(timer); - }); - - return request; - } - } -} diff --git a/frontend/image-tool/src/business/chengdu/common/DataResource.ts b/frontend/image-tool/src/business/chengdu/common/DataResource.ts deleted file mode 100644 index a38f7b2e..00000000 --- a/frontend/image-tool/src/business/chengdu/common/DataResource.ts +++ /dev/null @@ -1,196 +0,0 @@ -import { IDataResource, IDataMeta, IFileConfig } from '../type'; -// import { PCDLoader } from 'pc-render'; -import Tool from './Tool'; -import * as api from '../api'; -// import { createViewConfig } from '../utils'; -import BSError from './BSError'; - -export class ResourceLoader { - manual: boolean = false; - data: IDataMeta; - dataResource: DataResource; - promise: Promise = {} as Promise; - constructor(dataResource: DataResource, data: IDataMeta) { - this.data = data; - this.dataResource = dataResource; - this.handleProgress = this.handleProgress.bind(this); - } - remove() { - this.dataResource.loaders = this.dataResource.loaders.filter( - (e) => e.data.dataId !== this.data.dataId, - ); - - // if (!this.manual) - this.dataResource.load(); - } - get() { - return this.promise; - } - load() { - let promise: Promise = new Promise(async (resolve, reject) => { - try { - const { info, annotationStatus, validStatus } = - await this.dataResource.loadDataFile(this.data); - console.log('====>', info, this.data); - this.data.imageUrl = info.url; - this.data.dataConfig = info; - this.data.annotationStatus = annotationStatus; - this.data.validStatus = validStatus; - - // test resource - // if (import.meta.env.DEV) { - // this.data.imageUrl = '/image/M1 Abrams (202).jpg'; - // } - - let data = await this.dataResource.loadPoints( - this.data.imageUrl, - this.handleProgress, - ); - this.dataResource.setResource(this.data, { - time: Date.now(), - image: data, - }); - - console.log(`load resource: ${this.data.dataId} completed`); - this.data.loadState = 'complete'; - this.remove(); - resolve(this.dataResource.dataMap[this.data.dataId]); - // resolve({ - // info: this.dataResource.dataMap[this.data.dataId], - // annotationStatus: this.data.annotationStatus, - // validStatus: this.data.validStatus, - // }); - } catch (e) { - console.log(`load resource: ${this.data.dataId} err`); - this.data.loadState = 'error'; - this.remove(); - reject(e); - } - }); - - this.promise = promise; - } - handleProgress(percent: number) { - this.onProgress(percent); - } - onProgress(percent: number) { - // console.log(percent); - } -} - -export default class DataResource { - loadMax: number = 50; - tool: Tool; - dataMap: Record = {}; - loaders: ResourceLoader[] = []; - // pointsLoader: PCDLoader = new PCDLoader(); - constructor(tool: Tool) { - this.tool = tool; - } - - async loadDataFile(data: IDataMeta) { - console.log('loadDataFile'); - return await api.getDataFile(data.dataId + ''); - } - - async loadPoints(pointsUrl: string, onProgress?: (percent: number) => void): Promise { - return new Promise((resolve, reject) => { - let img = new Image(); - img.onload = () => { - resolve(img); - }; - img.onerror = () => { - reject(); - }; - console.log('pointsUrl ==> ', pointsUrl); - img.src = pointsUrl; - }); - } - - load(fromIndex?: number) { - let { dataIndex } = this.tool.state; - if (this.loaders.length > 0) return; - - let loaderN = Object.keys(this.dataMap).filter((e) => this.dataMap[e]).length; - if (loaderN > this.loadMax) return; - - fromIndex = fromIndex || dataIndex; - let data = this.getNext(fromIndex < 0 ? 0 : fromIndex); - - if (!data) { - // console.log('load complete'); - return; - } - - this.loadNext(data); - } - - getNext(fromIndex: number) { - let { dataIndex, dataList } = this.tool.state; - - let hasLoader = {} as Record; - this.loaders.forEach((e) => { - hasLoader[e.data.dataId] = true; - }); - - // The data near the current frame is preferentially loaded into the previous two frames - let indexData = [] as number[]; - dataList.forEach((data, index) => { - if ( - data.loadState === '' && - !hasLoader[data.dataId] && - Math.abs(index - fromIndex) <= 1 - ) - indexData.push(index); - }); - - console.log('indexData', indexData); - - if (indexData.length === 0) return null; - else return dataList[indexData[0]]; - } - - getResource(data: IDataMeta) { - let resource = this.dataMap[data.dataId]; - if (resource) { - resource.time = Date.now(); - return resource; - } - return this.loadNext(data, true); - } - - setResource(data: IDataMeta, resource: IDataResource) { - let { dataList } = this.tool.state; - let resourceKeys = Object.keys(this.dataMap).filter((e) => this.dataMap[e]); - // clear cache - if (resourceKeys.length > this.loadMax) { - let dataMap = {} as Record; - dataList.forEach((e) => { - dataMap[e.dataId] = e; - }); - resourceKeys.sort((a, b) => { - return this.dataMap[b].time - this.dataMap[a].time; - }); - while (resourceKeys.length > this.loadMax - 2) { - let key = resourceKeys.pop() as string; - let data = dataMap[key]; - if (data) data.loadState = ''; - delete this.dataMap[key]; - } - } - this.dataMap[data.dataId] = resource; - } - - loadNext(data: IDataMeta, manual: boolean = false) { - let oldLoader = this.loaders.find((e) => e.data.dataId === data.dataId); - if (this.loaders.length > 0 && oldLoader) return oldLoader; - - let loader = new ResourceLoader(this, data); - console.log('loadNext', loader); - loader.manual = manual; - this.loaders.push(loader); - loader.load(); - - return loader; - } -} diff --git a/frontend/image-tool/src/business/chengdu/common/Tool.ts b/frontend/image-tool/src/business/chengdu/common/Tool.ts deleted file mode 100644 index eec5072b..00000000 --- a/frontend/image-tool/src/business/chengdu/common/Tool.ts +++ /dev/null @@ -1,435 +0,0 @@ -import { - IToolState, - IToolConfig, - IDataResource, - IObject, - ObjectType, - IResultFilter, - IClassificationAttr, - IClassification, - AttrType, - SourceType, - IResultSource, -} from '../type'; -import { Editor } from 'editor'; -import { getDefault, getDefaultConfig } from '../state'; -import DataManager from './DataManager'; -import DataResource, { ResourceLoader } from './DataResource'; -import * as utils from '../utils'; -import * as api from '../api'; -import BSError from './BSError'; -import * as THREE from 'three'; -import { classificationToSave, saveToClassificationValue } from '../utils'; - -type AnnotateObject = any; - -export default class Tool { - config: IToolConfig = getDefaultConfig(); - editor: Editor; - state: IToolState = getDefault(); - dataManager: DataManager; - dataResource: DataResource; - constructor() { - this.editor = new Editor(this); - this.dataManager = new DataManager(this); - this.dataResource = new DataResource(this); - } - async loadData(index: number, showLoading: boolean = true) { - index = +index; - if (index === this.state.dataIndex) return; - this.state.dataIndex = index; - - showLoading && this.editor.showLoading(true); - try { - await this.loadResource(); - await Promise.all([this.loadObject()]); - } catch (error: any) { - this.handleErr(error); - } - - showLoading && this.editor.showLoading(false); - - this.dataResource.load(); - } - - async loadObject() { - console.log('======= loadObject ======='); - const dataInfo = this.state.dataList[this.state.dataIndex]; - - const objects = this.dataManager.getDataObject(dataInfo.dataId); - if (!objects) { - try { - const res = await api.getAnnotationByDataIds([dataInfo.dataId]); - - // objects ==> - const annotationObject = res.objects ?? []; - const annotates = utils.convertObject2Annotate(annotationObject, this.editor); - this.editor.state.isAnnotated = annotates.length > 0; - this.dataManager.setDataObject(dataInfo.dataId, annotates); - - // classification ==> - const annotationClassification = res.classificationValues ?? []; - - const classifications = [] as IClassification[]; - this.state.classifications.forEach((classification) => { - let copyClassification = {} as IClassification; - copyClassification = JSON.parse(JSON.stringify(classification)); - copyClassification.attrs.forEach((attr) => { - // console.log('attr', attr); - attr.value = attr.type === AttrType.MULTI_SELECTION ? [] : ''; - const target = annotationClassification.find( - (item: any) => item.id == attr.classificationId, - ); - if (target) { - const classificationAttributes = saveToClassificationValue( - target.values, - ); - attr.value = classificationAttributes[attr.id]; - } - }); - classifications.push(copyClassification); - }); - dataInfo.classifications = classifications; - } catch (error: any) { - this.handleErr(new BSError('', 'Load Object Error', error)); - } - } - // console.log(annotates); - this.getResultSources(); - this.editor.reset(); - this.state.resultActive = []; - this.setFilterFromData(); - this.loadDataFromManager(true); - } - getMaxId(dataId?: string) { - let { dataIndex, dataList } = this.state; - let curData = dataList[dataIndex]; - let objects = this.dataManager.getDataObject(dataId || curData.dataId) || []; - let maxId = 0; - objects.forEach((e) => { - if (!e.intId) return; - let id = parseInt(e.intId); - if (id > maxId) maxId = id; - }); - return maxId; - } - getCurrentFrame() { - return this.state.dataList[this.state.dataIndex]; - } - addModelData(flag?: boolean) { - let { state } = this; - let dataInfo = state.dataList[state.dataIndex]; - // console.log(dataInfo.dataId); - let objects = this.dataManager.modelMap[dataInfo.dataId]; - // let oldAnnotate = this.dataManager.getDataObject(dataInfo.dataId); - let annotates = utils.convertObject2Annotate(objects, this.editor); - annotates.forEach((e) => { - e.userData.sourceId = state.withoutTaskId; - e.userData.sourceType = SourceType.DATA_FLOW; - }); - // this.dataManager.setDataObject(dataInfo.dataId, [...oldAnnotate, ...annotates]); - this.editor.cmdManager.execute('add-object', annotates); - // if (!flag) { - // this.editor.cmdManager.execute('add-modelRun', { - // annotates, - // objects, - // id: dataInfo.dataId, - // }); - // } - dataInfo.model = undefined; - - dataInfo.needSave = true; - - this.setFilterFromData(); - this.loadDataFromManager(true); - - // delete this.dataManager.modelMap[dataInfo.dataId]; - } - - createTrackId() { - let { seriesFrameId } = this.state; - let uuid6 = THREE.MathUtils.generateUUID().slice(0, 6); - return `${seriesFrameId}-${uuid6}`; - } - - loadDataFromManager(clear: boolean = false) { - if (clear) { - this.editor.tool?.removeAll(false); - } - let config = this.state.dataList[this.state.dataIndex]; - let objects = this.dataManager.dataMap[config.dataId]; - - let filterMap = this.getActiveFilter(); - let withoutTaskId = this.state.withoutTaskId; - // console.log('filterMap', filterMap); - let filterObjects = [] as AnnotateObject[]; - objects.forEach((e) => { - let sourceId = e.userData.sourceId || withoutTaskId; - let valid = filterMap.all || filterMap.source[sourceId]; - - if (!valid) return; - - filterObjects.push(e); - }); - this.editor.addObject(filterObjects); - this.editor.idCount = this.getMaxId() + 1; - } - - getActiveFilter() { - let { sourceFilters, FILTER_ALL } = this.state; - - let filterMap = { - all: false, - source: {}, - // project: {}, - // model: {}, - }; - sourceFilters.forEach((filter) => { - if (filter === FILTER_ALL) filterMap.all = true; - else { - filterMap.source[filter] = true; - } - }); - - return filterMap; - } - - setFilterFromData() { - let config = this.state.dataList[this.state.dataIndex]; - let objects = this.dataManager.getDataObject(config.dataId + ''); - let { FILTER_ALL } = this.config; - let all: IResultFilter = { value: FILTER_ALL, label: FILTER_ALL, type: '' }; - let project: IResultFilter = { label: 'Ground Truth', options: [], type: 'project' }; - let model: IResultFilter = { label: 'Model Runs', options: [], type: 'model' }; - - let projectMap = {}; - let modelMap = {}; - - objects.forEach((object) => { - if (object.modelRun) { - let name = object.modelRun; - if (!modelMap[name]) { - let option = { value: name, label: `Model Runs ${name}` }; - model.options?.push(option); - modelMap[name] = option; - } - } else { - let name = object.project || ''; - if (!projectMap[name]) { - let option = { value: name, label: name || 'No Project' }; - project.options?.push(option); - projectMap[name] = option; - } - } - }); - - let filters = [all] as IResultFilter[]; - - if ((project as any).options.length > 0) filters.push(project); - if ((model as any).options.length > 0) filters.push(model); - - this.state.resultFilter = filters; - if (this.state.resultActive.length === 0) this.state.resultActive = [FILTER_ALL]; - } - - async loadResource() { - let data = this.state.dataList[this.state.dataIndex]; - let resource = this.dataResource.getResource(data); - - if (resource instanceof ResourceLoader) { - // console.log('load Resource'); - resource.onProgress = (ratio: number) => { - let percent = (ratio * 100).toFixed(2); - this.editor.showLoading({ - type: 'loading', - content: `Load Points....${percent}%`, - }); - }; - return resource - .get() - .then((data) => { - this.setResource(data); - }) - .catch((e) => { - this.handleErr(new BSError('', 'Load Resource Error', e)); - }); - } else { - this.setResource(resource); - } - } - - setResource(resource: IDataResource) { - let data = this.state.dataList[this.state.dataIndex]; - // console.log('setResource ==>', resource, data); - - this.editor.state.dataId = data.dataId; - this.editor.state.imageSize = data.dataConfig.size; - this.editor.state.dataName = data.dataConfig.name; - this.editor.state.imageUrl = data.dataConfig.url; - this.editor.state.annotationStatus = data.annotationStatus; - this.editor.state.validStatus = data.validStatus; - if (this.state?.focus?.focusId) { - this.editor.state.focusId = this.state?.focus?.focusId; - } - - this.editor.loadImage(resource.image); - } - setResultSource(sources: IResultSource[]) { - if (!sources) return; - let { FILTER_ALL, withoutTaskId } = this.state; - this.state.sources = sources; - - let sourceMap = {}; - sources.forEach((e) => { - sourceMap[e.sourceId] = true; - }); - - this.state.sourceFilters = this.state.sourceFilters.filter((e) => sourceMap[e]); - if (this.state.sourceFilters.length === 0) this.state.sourceFilters = [FILTER_ALL]; - } - async getResultSources() { - let frame = this.getCurrentFrame(); - if (!frame) return; - if (!frame.sources) { - let state = this.state; - let sources = await api.getResultSources(frame.dataId); - sources.unshift({ - name: 'Without Task', - sourceId: state.withoutTaskId, - sourceType: SourceType.DATA_FLOW, - }); - frame.sources = sources; - } - this.setResultSource(frame.sources); - // let sourceMap = {}; - // sources.forEach((e) => { - // sourceMap[e.sourceId] = true; - // }); - // state.sourceFilters = [state.withoutTaskId]; - // state.sources = sources; - // return sources; - } - - needSave() { - let needSaveData = this.state.dataList.filter((e) => e.needSave); - return needSaveData.length > 0; - } - - // NOTE - async saveObject() { - let { state, editor } = this; - let { withoutTaskId } = state; - // let dataMeta = state.dataList[state.dataIndex]; - if (state.saving) return; - - if (!this.needSave()) return; - - // currentData - const currentData = state.dataList[state.dataIndex]; - // class - let classMap = {}; - editor.state.classTypes.forEach((e) => { - classMap[e.name] = e; - }); - - const dataInfos = [] as any; - state.dataList.forEach((dataMeta) => { - if (!dataMeta.needSave) return; - - // object ==> - const objectInfos = [] as any[]; - const annotates = this.dataManager.getDataObject(dataMeta.dataId) || []; - let data = utils.convertAnnotate2Object(annotates, editor); - - data.forEach((e) => { - objectInfos.push({ - id: e.backId, - frontId: e.id, - classId: +e.classId, - sourceId: +e.sourceId, - sourceType: e.sourceType, - classAttributes: e, - }); - }); - // const data = utils.convertAnnotate2Object(annotates, editor); // 转换数据 - // data.forEach((e) => { - // console.log('object ==>', e); - // objectInfos.push(e); - // }); - - // classification ==> - const classificationInfos = [] as any[]; - (dataMeta.classifications || []).forEach((classification: any) => { - const newClassification = classificationToSave(classification); - const classificationAttributes = { - id: +classification.id, - values: newClassification, - }; - classificationInfos.push({ - id: undefined, - classificationId: classification.id, - classificationAttributes, - }); - }); - - dataInfos.push({ - dataId: dataMeta.dataId, - objects: objectInfos, - dataAnnotations: classificationInfos, - }); - }); - - try { - state.saving = true; - const saveParams = { - datasetId: currentData.datasetId, - dataInfos, - }; - const keyMap = await api.saveAnnotation(saveParams); - this.updateBackId(keyMap); - state.dataList.forEach((e) => { - e.needSave = false; - }); - editor.showMsg('success', 'Save Success'); - state.saving = false; - return true; - } catch (error: any) { - this.editor.showMsg('error', error.message || 'Save Error'); - state.saving = false; - return false; - } - - // tool - function isAttrVisible( - attr: IClassificationAttr, - attrMap: Record, - ): boolean { - if (!attr.parent) return true; - let parentAttr = attrMap[attr.parent]; - let visible = - parentAttr.type !== AttrType.MULTI_SELECTION - ? parentAttr.value === attr.parentValue - : (parentAttr.value as any[]).indexOf(attr.parentValue) >= 0; - - return visible && isAttrVisible(parentAttr, attrMap); - } - } - - handleErr(err: BSError | Error) { - utils.handleError(this, err); - } - - updateBackId(keyMap: Record>) { - Object.keys(keyMap).forEach((dataId) => { - let dataKeyMap = keyMap[dataId]; - let annotates = this.dataManager.getDataObject(dataId) || []; - annotates.forEach((annotate) => { - let frontId = annotate.uuid; - let backId = dataKeyMap[frontId]; - if (!backId) return; - annotate.id = backId; - // annotate.uuid = backId; - }); - }); - } -} diff --git a/frontend/image-tool/src/business/chengdu/components/Collapse/index.vue b/frontend/image-tool/src/business/chengdu/components/Collapse/index.vue deleted file mode 100644 index 084634a4..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Collapse/index.vue +++ /dev/null @@ -1,73 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Header/TheKeyboard.vue b/frontend/image-tool/src/business/chengdu/components/Header/TheKeyboard.vue deleted file mode 100644 index 2a653c4f..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Header/TheKeyboard.vue +++ /dev/null @@ -1,255 +0,0 @@ - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Header/data.ts b/frontend/image-tool/src/business/chengdu/components/Header/data.ts deleted file mode 100644 index 58c14f17..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Header/data.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { AttrType, IClassType } from 'pc-editor'; - -const colors = [ - '#1f77b4', - '#ff7f0e', - '#2ca02c', - '#d62728', - '#9467bd', - '#8c564b', - '#e377c2', - '#7f7f7f', - '#bcbd22', - '#17becf', -]; - -let classTypesConfig: IClassType[] = [ - { - id: 1 + '', - label: 'Car', - name: 'Car', - color: '', - attrs: [ - { name: 'name', type: AttrType.TEXT, required: true, options: [] }, - { - name: 'color', - type: AttrType.DROPDOWN, - required: true, - options: [ - { value: '#d62728', label: '#d62728' }, - { value: '#9467bd', label: '#9467bd' }, - ], - }, - { - name: 'type', - type: AttrType.MULTI_SELECTION, - required: true, - options: [ - { value: 'Apple', label: 'Apple' }, - { value: 'Orange', label: 'Orange' }, - { value: 'Pear', label: 'Pear' }, - ], - }, - ], - }, - { - id: 2 + '', - label: 'Pedestrain', - name: 'Pedestrain', - color: '', - attrs: [ - { name: 'name', type: AttrType.TEXT, required: true, options: [] }, - { - name: 'type', - type: AttrType.RADIO, - required: true, - options: [ - { value: 'type1', label: 'type1' }, - { value: 'type2', label: 'type2' }, - { value: 'type3', label: 'type3' }, - ], - }, - ], - }, - { - id: 3 + '', - label: 'Bicycle', - name: 'Bicycle', - color: '', - attrs: [ - { name: 'name', type: AttrType.TEXT, required: true, options: [] }, - { - name: 'type', - required: true, - type: AttrType.DROPDOWN, - options: [ - { value: 'Apples', label: 'Apples' }, - { value: 'Nails', label: 'Nails' }, - { value: 'Bananas', label: 'Bananas' }, - { value: 'Helicopters', label: 'Helicopters' }, - ], - }, - ], - }, -]; - -classTypesConfig = classTypesConfig.map((e, index) => { - return { ...e, color: colors[index] }; -}); - -export { classTypesConfig, colors }; diff --git a/frontend/image-tool/src/business/chengdu/components/Header/index.vue b/frontend/image-tool/src/business/chengdu/components/Header/index.vue deleted file mode 100644 index 86bc25fc..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Header/index.vue +++ /dev/null @@ -1,465 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Header/useHeader.ts b/frontend/image-tool/src/business/chengdu/components/Header/useHeader.ts deleted file mode 100644 index 2ae2d8dd..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Header/useHeader.ts +++ /dev/null @@ -1,308 +0,0 @@ -import { computed, reactive, ref, watch, createVNode } from 'vue'; -import { message } from 'ant-design-vue'; -import { useInjectTool } from '../../state'; -import { StatusType, Event } from 'editor'; -import * as _ from 'lodash'; -import * as api from '../../api'; -import { FilterEnum } from '../Operation/Instance/type'; -import { ModalConfirmCustom } from '../../utils'; -import { ValidStatus, AnnotateStatus } from '../../../../editor/type'; - -export default function useHeader() { - let tool = useInjectTool(); - let state = tool.state; - let editor = tool.editor; - let editorState = editor.state; - let dataIndex = ref(state.dataIndex + 1); - watch( - () => state.dataIndex, - () => { - if (dataIndex.value !== state.dataIndex + 1) dataIndex.value = state.dataIndex + 1; - }, - ); - - let onIndexChange = _.debounce(() => { - // console.log('change', dataIndex.value); - if (dataIndex.value && dataIndex.value - 1 >= 0) tool.loadData(dataIndex.value - 1); - }, 200); - - function onIndexBlur() { - if (!dataIndex.value) dataIndex.value = state.dataIndex + 1; - } - async function onSave() { - await tool.saveObject(); - } - - async function onPre() { - editorState.showClassView = false; - if (tool.needSave()) { - editor - .showWarning({ - title: 'Warning', - subTitle: 'Please save the results before switching data', - }) - .then( - async () => {}, - async () => {}, - ); - } else { - if (state.dataIndex > 0) { - editor.emit(Event.IMAGE_CHANGE); - state.showVerify = false; - tool.loadData(state.dataIndex - 1); - } - } - } - function onNext() { - editorState.showClassView = false; - if (tool.needSave()) { - editor - .showWarning({ - title: 'Warning', - subTitle: 'Please save the results before switching data', - }) - .then( - async () => {}, - async () => {}, - ); - } else { - console.log(state.dataIndex); - if (state.dataIndex < state.dataList.length - 1) { - editor.emit(Event.IMAGE_CHANGE); - state.showVerify = false; - tool.loadData(state.dataIndex + 1); - } - } - } - - async function saveChange() { - if (tool.needSave()) { - await editor - .showConfirm({ title: 'Save Change', subTitle: 'Do you want to save changes?' }) - .then( - async () => { - await tool.saveObject(); - }, - async () => {}, - ); - } - } - async function onClose() { - if (editor.state.mode !== 'view') { - await saveChange(); - // has error - if (tool.state.showVerify) { - return; - } - await api.unlockRecord(tool.state.recordId); - } - closeTab(); - function closeTab() { - let win = window.open('about:blank', '_self'); - win && win.close(); - } - } - - async function onMark(markType: string) { - try { - const dataId = state.dataList[0].dataId; - if (markType == ValidStatus.INVALID) { - await api.setInvalid(dataId); - await setDataStatus(); - return ValidStatus.INVALID; - } else { - await api.setValid(dataId); - await setDataStatus(); - return ValidStatus.VALID; - } - } catch (error) { - console.log(error); - return null; - } - } - - async function onSubmit() { - console.log('onSubmit', tool, editor); - console.log(state.dataList[state.dataIndex]); - - const current = state.dataList[state.dataIndex]; - const { annotationStatus, needSave } = current; - const hasAnnotated = annotationStatus == AnnotateStatus.ANNOTATED || needSave; - // const isAnnotated = editorState.isAnnotated; - // const hasAnnotated = annotationStatus == AnnotateStatus.ANNOTATED || needSave || isAnnotated; - - await onSave(); - - const validStatus = editorState.validStatus; - if (validStatus == ValidStatus.INVALID) { - await handleSubmit(); - await switchData(); - } else if (validStatus == ValidStatus.VALID) { - if (hasAnnotated) { - // no empty - await handleSubmit(); - await switchData(); - } else { - // empty - ModalConfirmCustom({ - title: 'Reminder', - content: createVNode( - 'div', - null, - `you don't have any annotation yet, are you sure you want to submit this data? If you can't annotate this data, you'd better mark this data as invaild.`, - ), - okText: 'submit anyway', - okButtonProps: { - type: 'primary', - }, - onOk: async () => { - await handleSubmit(); - await switchData(); - }, - }); - } - } - function switchData() { - if (state.dataIndex < state.dataList.length - 1) { - // not last - editor.emit(Event.IMAGE_CHANGE); - state.showVerify = false; - tool.loadData(state.dataIndex + 1); - } else { - // last - // -- is Not_Annotated - console.log('all dataList: ', state.dataList); - const notAnnotateIndex = state.dataList.findIndex((item) => { - console.log(item); - return item.annotationStatus == AnnotateStatus.NOT_ANNOTATED; - }); - console.log('Not_Annotated index', notAnnotateIndex); - if (notAnnotateIndex != -1) { - // NOT_Annotated -- switch to notAnnotateIndex - editor.emit(Event.IMAGE_CHANGE); - state.showVerify = false; - tool.loadData(notAnnotateIndex); - } else { - // All Annotated - ModalConfirmCustom({ - title: 'Reminder', - content: createVNode('div', null, [ - createVNode('div', null, 'Well Done!'), - createVNode('div', null, 'You have finish all the annotation!'), - ]), - okText: 'Close and release those data', - okButtonProps: { - type: 'primary', - }, - cancelButtonProps: { - style: { - display: 'none', - }, - }, - onOk: async () => { - // unlock & close - await api.unlockRecord(tool.state.recordId); - closeTab(); - function closeTab() { - let win = window.open('about:blank', '_self'); - win && win.close(); - } - }, - }); - } - } - } - } - async function handleSubmit() { - try { - const dataId = state.dataList[0].dataId; - await api.submit(dataId); - await setDataStatus(); - } catch (error) { - console.log(error); - } - } - async function setDataStatus() { - const dataId = state.dataList[0].dataId; - const res = await api.getDataStatusByIds(dataId); - console.log('setDataStatus', res); - - state.dataList[state.dataIndex].validStatus = res.status; - state.dataList[state.dataIndex].annotationStatus = res.annotationStatus; - } - - async function onSkip() { - editorState.showClassView = false; - if (tool.needSave()) { - onSave(); - } - - if (state.dataIndex < state.dataList.length - 1) { - editor.emit(Event.IMAGE_CHANGE); - state.showVerify = false; - tool.loadData(state.dataIndex + 1); - } else { - message.info('This is last data '); - } - } - - async function onModify() { - const { dataId, datasetId, dataConfig } = state.dataList[0]; - console.log(state.dataList[0]); - try { - const res = await api.takeRecordByData({ - datasetId: datasetId, - dataIds: [dataId], - dataType: 'SINGLE_DATA', - }); - console.log(res); - - const { origin, pathname } = window.location; - window.location.href = `${origin}${pathname}?recordId=${res.data}`; - } catch (error) { - // DATASET_DATA_EXIST_ANNOTATE - console.log(error); - message.warning(`Fail to modify data because it is being annotated by others`); - } - } - - // Shortcut - const toggleKeyboard = _.debounce(() => { - editorState.showKeyboard = !editorState.showKeyboard; - }, 150); - - // Bind the method to the editor for easy access to shortcut keys - editor.handlePageUp = onPre; - editor.handlePageDown = onNext; - editor.handleToggleKeyboard = toggleKeyboard; - editor.handleSaveObject = onSave; - - let blocking = computed(() => { - return ( - state.saving || - editorState.status === StatusType.Loading || - editorState.status === StatusType.Create - ); - }); - // console.log('useheader', editor); - // console.log('so this==', this); - // editor.hotkeyManager.registryHotkey('T', () => { - // toggleKeyboard(); - // }); - - return { - blocking, - dataIndex, - onIndexChange, - onIndexBlur, - onSave, - onPre, - onNext, - onClose, - toggleKeyboard, - onMark, - onSubmit, - onSkip, - onModify, - }; -} diff --git a/frontend/image-tool/src/business/chengdu/components/MainView/EditClass.vue b/frontend/image-tool/src/business/chengdu/components/MainView/EditClass.vue deleted file mode 100644 index dbfb6c1b..00000000 --- a/frontend/image-tool/src/business/chengdu/components/MainView/EditClass.vue +++ /dev/null @@ -1,291 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/MainView/index.vue b/frontend/image-tool/src/business/chengdu/components/MainView/index.vue deleted file mode 100644 index 5d026880..00000000 --- a/frontend/image-tool/src/business/chengdu/components/MainView/index.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/MainView/sub/AttrValue.vue b/frontend/image-tool/src/business/chengdu/components/MainView/sub/AttrValue.vue deleted file mode 100644 index 1076036d..00000000 --- a/frontend/image-tool/src/business/chengdu/components/MainView/sub/AttrValue.vue +++ /dev/null @@ -1,65 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/MainView/sub/Check.vue b/frontend/image-tool/src/business/chengdu/components/MainView/sub/Check.vue deleted file mode 100644 index dbebe07f..00000000 --- a/frontend/image-tool/src/business/chengdu/components/MainView/sub/Check.vue +++ /dev/null @@ -1,33 +0,0 @@ - - - diff --git a/frontend/image-tool/src/business/chengdu/components/MainView/sub/Radio.vue b/frontend/image-tool/src/business/chengdu/components/MainView/sub/Radio.vue deleted file mode 100644 index 66baa460..00000000 --- a/frontend/image-tool/src/business/chengdu/components/MainView/sub/Radio.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/frontend/image-tool/src/business/chengdu/components/MainView/sub/Select.vue b/frontend/image-tool/src/business/chengdu/components/MainView/sub/Select.vue deleted file mode 100644 index 78020cf0..00000000 --- a/frontend/image-tool/src/business/chengdu/components/MainView/sub/Select.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/frontend/image-tool/src/business/chengdu/components/MainView/sub/Text.vue b/frontend/image-tool/src/business/chengdu/components/MainView/sub/Text.vue deleted file mode 100644 index 5255220e..00000000 --- a/frontend/image-tool/src/business/chengdu/components/MainView/sub/Text.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Modal/ModelRun.vue b/frontend/image-tool/src/business/chengdu/components/Modal/ModelRun.vue deleted file mode 100644 index faa7fc38..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Modal/ModelRun.vue +++ /dev/null @@ -1,240 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Classification/AttrValue.vue b/frontend/image-tool/src/business/chengdu/components/Operation/Classification/AttrValue.vue deleted file mode 100644 index 01caf27d..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Classification/AttrValue.vue +++ /dev/null @@ -1,90 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Classification/index.vue b/frontend/image-tool/src/business/chengdu/components/Operation/Classification/index.vue deleted file mode 100644 index caa6b4ed..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Classification/index.vue +++ /dev/null @@ -1,96 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/Filter.vue b/frontend/image-tool/src/business/chengdu/components/Operation/Instance/Filter.vue deleted file mode 100644 index 6b3273de..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/Filter.vue +++ /dev/null @@ -1,114 +0,0 @@ - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/Header.vue b/frontend/image-tool/src/business/chengdu/components/Operation/Instance/Header.vue deleted file mode 100644 index 08e32060..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/Header.vue +++ /dev/null @@ -1,294 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/Item.vue b/frontend/image-tool/src/business/chengdu/components/Operation/Instance/Item.vue deleted file mode 100644 index 5b3983c3..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/Item.vue +++ /dev/null @@ -1,159 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/index.vue b/frontend/image-tool/src/business/chengdu/components/Operation/Instance/index.vue deleted file mode 100644 index abcf462e..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/index.vue +++ /dev/null @@ -1,264 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/type.ts b/frontend/image-tool/src/business/chengdu/components/Operation/Instance/type.ts deleted file mode 100644 index 03316402..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/type.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { AttrType } from 'editor'; -// import { AnnotateType } from 'pc-render'; - -export interface IItem { - lineLength?: any; - type: string; - id: string; - name: string; - annotateType: string; // todo - visible: boolean; - isModel: boolean; - attrs: IItemAttrs; - width?: number; - height?: number; - area?: number; - filterVisible: boolean; -} -export type IItemAttrs = string[] | string[][]; -export interface IInstanceList { - isModel: boolean; - classType: string; - data: IItem[]; - color: string; - // bgColor: string; - visible: boolean; - annotateType: string; - filterVisible: boolean; -} - -export interface IInstanceState { - activeKey: string[]; - select: string[]; - objectN: number; - list: IInstanceList[]; - noClassList: IInstanceList; -} - -export interface IAttrItem { - type: AttrType; - name: string; - options: { value: any; label: string }[]; - value: any; -} - -export enum FilterEnum { - class = 'Class', - noClass = 'NoClass', - predictedClass = 'PredictedClass', - noPredictedClass = 'NoPredictedClass', -} diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/useInstance.ts b/frontend/image-tool/src/business/chengdu/components/Operation/Instance/useInstance.ts deleted file mode 100644 index 350035e7..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/useInstance.ts +++ /dev/null @@ -1,529 +0,0 @@ -import { reactive, ref, createVNode, onMounted, onBeforeUnmount, nextTick } from 'vue'; -import * as _ from 'lodash'; -import { - IUserData, - Event, - ToolType2AnnotatteType, - AnnotateType2ToolType, - AnnotateType, -} from 'editor'; -import type { IInstanceList, IInstanceState, IItem, IItemAttrs } from './type'; -import { useInjectEditor, useInjectEditorState } from '../../../../../editor/inject'; -import useItem from './useItem'; -import { FilterEnum } from './type'; - -export default function useInstance() { - let editor = useInjectEditor(); - const noClassKey = 'notClassed'; - const editorState = useInjectEditorState(); - let { onAnnotation, onDelete, onEdit, onToggleVisible } = useItem(); - const state = reactive({ - activeKey: [], - select: [], - list: [], - objectN: 0, - noClassList: { - classType: '', - data: [], - visible: true, - color: '', - isModel: false, - annotateType: '', - filterVisible: true, - }, - }); - const allFilter = ref([FilterEnum.class, FilterEnum.predictedClass]); - const filterValue = ref([FilterEnum.class, FilterEnum.predictedClass]); - const lastNoClassList = ref([]); - const lastHasClassList = ref([]); - const allVisible = ref(); - - // *****life hook****** - onMounted(() => { - editor.on(Event.SELECT, onSelect); - editor.on(Event.CLEAR_DATA, onClear); - editor.on(Event.REMOVE_OBJECT, update); - editor.on(Event.ADD_OBJECT, update); - editor.on(Event.DIMENSION_CHANGE, update); - editor.on(Event.VISIBLE_CHANGE, update); - editor.on(Event.USER_DATA_CHANGE, onUserDataChange); - editor.on(Event.LOAD_OBJECTS, update); - editor.on(Event.FILTER_CHANGE, onToggleFilterVisible); - editor.on(Event.FILTER_TOGGLE, toggleVisibleByFilter); - editor.on(Event.IMAGE_CHANGE, changeImage); - editor.on(Event.RESET_SELECT, resetStateSelect); - }); - - onBeforeUnmount(() => { - editor.off(Event.SELECT, onSelect); - editor.off(Event.CLEAR_DATA, onClear); - editor.off(Event.REMOVE_OBJECT, update); - editor.off(Event.ADD_OBJECT, update); - editor.off(Event.DIMENSION_CHANGE, update); - editor.off(Event.VISIBLE_CHANGE, update); - editor.off(Event.USER_DATA_CHANGE, onUserDataChange); - editor.off(Event.LOAD_OBJECTS, update); - editor.off(Event.FILTER_CHANGE, onToggleFilterVisible); - editor.off(Event.FILTER_TOGGLE, toggleVisibleByFilter); - editor.off(Event.IMAGE_CHANGE, changeImage); - editor.off(Event.RESET_SELECT, resetStateSelect); - }); - - // *****life hook****** - - let update = _.debounce(() => { - let objects = editor.tool?.toJSON() || []; - - state.objectN = objects.length; - editorState.allVisible = - objects.length > 0 ? !objects.every((item: any) => !item.visible) : true; - - let classConfigMap: Record = {}; - editorState.classTypes.forEach((e) => { - classConfigMap[e.name] = e; - }); - // console.log('state.list ==>', state.list); - - // TODO classType 作为Map有bug, classType可能会重复 - let existMap: Record> = {}; - let classMap: Record = {}; - state.list.forEach((info) => { - existMap[info.classType] = existMap[info.classType] || {}; - classMap[info.classType] = info.data; - info.data.forEach((data) => { - existMap[info.classType][data.id] = data; - }); - }); - - existMap[''] = existMap[''] || {}; - classMap[''] = state.noClassList.data; - state.noClassList.data.forEach((data) => { - existMap[''][data.id] = data; - }); - // console.log(existMap, classMap); - - let objectMap: Record> = {}; - objects.forEach((obj: any) => { - let uuid = obj.uuid; - let classType = obj.userData.classType || obj.userData.modelClass || ''; - if (!allFilter.value.includes(classType)) { - allFilter.value.push(classType); - filterValue.value.push(classType); - } - const filterClassType = classType == '' ? FilterEnum.noClass : classType; - - objectMap[classType] = objectMap[classType] || {}; - - let name = obj.intId; - if (existMap[classType] && existMap[classType][uuid]) { - // console.log(obj); - let item = existMap[classType][uuid]; - item.visible = obj.visible; - item.name = '#' + name; - item.attrs = Object.values(obj.userData.attrs || {}) as IItemAttrs; - item.width = obj.width; - item.height = obj.height; - item.area = obj.area; - item.lineLength = obj.lineLength; - item.type = obj.type; - - item.filterVisible = - filterValue.value.includes(FilterEnum.class) || - filterValue.value.includes(filterClassType); - - if (obj.userData?.modelClass) { - item.isModel = true; - item.filterVisible = - filterValue.value.includes(FilterEnum.predictedClass) || - filterValue.value.includes(filterClassType); - } - - objectMap[classType][uuid] = item; - } else { - let item: IItem = { - id: uuid, - annotateType: obj.type, - name: '#' + name, - visible: obj.visible, - isModel: false, - attrs: Object.values(obj.userData.attrs || {}) as IItemAttrs, - type: obj.type, - filterVisible: true, - }; - item.width = obj.width; - item.height = obj.height; - item.area = obj.area; - item.lineLength = obj.lineLength; - - item.filterVisible = - filterValue.value.includes(FilterEnum.class) || - filterValue.value.includes(filterClassType); - - if (obj.userData?.modelClass) { - item.isModel = true; - item.filterVisible = - filterValue.value.includes(FilterEnum.predictedClass) || - filterValue.value.includes(filterClassType); - } - - if (!classMap[classType]) { - let { color, toolType } = getColor(obj); - // let color = classConfigMap[classType] - // ? classConfigMap[classType].color - // : obj.color || '#ffffff'; - // let bgColor = colord(color).alpha(0.3).toRgbString(); - let insList: IInstanceList = { - classType, - color, - // annotateType: ToolType2AnnotatteType[classConfigMap[classType]?.toolType], - annotateType: ToolType2AnnotatteType[toolType], - // bgColor, - data: [], - visible: true, - isModel: item.isModel, - filterVisible: true, - }; - - insList.filterVisible = - filterValue.value.includes(FilterEnum.class) || - filterValue.value.includes(filterClassType); - if (item.isModel) { - insList.isModel = true; - insList.filterVisible = - filterValue.value.includes(FilterEnum.predictedClass) || - filterValue.value.includes(filterClassType); - } - state.list.push(insList); - - classMap[classType] = insList.data; - } - - classMap[classType].push(item); - - existMap[classType] = existMap[classType] || {}; - existMap[classType][uuid] = item; - objectMap[classType][uuid] = item; - } - }); - - filterInfo(state.noClassList, objectMap); - // console.log('state', state); - state.list = state.list.filter((info) => { - filterInfo(info, objectMap); - return info.data.length; - }); - selectedScrollToView(); - - toggleVisibleByFilter(); - }, 100); - - function selectedScrollToView() { - nextTick(() => { - let selected = document.querySelector('.operation-instance .item.active'); - if (selected) { - selected.scrollIntoView({ - behavior: 'smooth', - block: 'center', - }); - } - }); - } - function filterInfo(info: IInstanceList, objectMap: Record>) { - let data: IItem[] = []; - let hasNoVisible = false; - let hasNoModel = false; - info.data.forEach((e) => { - if (objectMap[info.classType] && objectMap[info.classType][e.id]) { - data.push(e); - if (!e.isModel) hasNoModel = true; - } - }); - info.data = data; - info.visible = !data.every((item) => !item.visible); - info.isModel = !hasNoModel; - } - - function onDeleteClassObject(item: IInstanceList) { - editor.showConfirm({ title: 'Delete', subTitle: 'Delete Objects?' }).then( - () => { - let idMap = [] as string[]; - item.data.forEach((e) => { - idMap.push(e.id); - }); - editor.cmdManager.execute('delete-object', { - object: editor.tool - ?.toJSON() - .filter((record: any) => idMap.includes(record.uuid)), - id: idMap, - }); - if (idMap.length > 0) { - editor.tool?.removeById(idMap); - } - - const filterClassType = item.classType == '' ? FilterEnum.noClass : item.classType; - const index = allFilter.value.findIndex((filter) => filter == filterClassType); - allFilter.value.splice(index, 1); - filterValue.value.splice(index, 1); - }, - () => {}, - ); - } - - function onEditModelClass(item: IInstanceList) { - let idMap = {}; - item.data.forEach((e) => { - idMap[e.id] = true; - }); - } - - function onToggleClassVisible(item: IInstanceList) { - let visible = item.filterVisible && !item.visible; - item.visible = visible; - - let idMap = [] as string[]; - item.data.forEach((e) => { - idMap.push(e.id); - }); - if (idMap.length > 0) { - editor.setVisible(idMap, visible); - } - } - - function onItemClick(item: IItem, e: MouseEvent) { - editor.tool?.selectShapeById(item.id, e ? e.shiftKey : false); - } - - function onItemTool(action: string, item: IItem, e: MouseEvent) { - switch (action) { - case 'itemClick': - onItemClick(item, e); - break; - case 'toggleVisible': - onToggleVisible(item); - break; - case 'annotation': - onAnnotation(item); - break; - case 'edit': - onEdit(item); - break; - case 'delete': - onDelete(item); - break; - } - } - - function onClear() { - state.objectN = 0; - state.list = []; - state.noClassList.data = []; - editorState.allVisible = true; - } - - function onSelect(data: any) { - let selection = data.data.curSelection; - if (selection.length > 0) { - let classType = selection.map((item) => { - return item.userData.classType || item.userData.modelClass || noClassKey; - }); - state.select = selection.map((t: any) => t.uuid); - state.activeKey = [...new Set(classType)]; - } else { - state.select = []; - } - selectedScrollToView(); - } - - function onUserDataChange(data: any) { - let options = data.data.options; - let option = Array.isArray(options) ? options[0] : options; - if ('classType' in option.userData || 'modelClass' in option.userData) { - if (option.userData.classType || option.userData.modelClass) - state.activeKey = [option.userData.classType || option.userData.modelClass]; - } - update(); - } - - function onToggleFilterVisible(selectedKeys: FilterEnum[]) { - console.log('filter --- ', selectedKeys); - filterValue.value = selectedKeys; - - state.noClassList.filterVisible = - filterValue.value.includes(FilterEnum.class) || - filterValue.value.includes(FilterEnum.noClass); - state.noClassList.visible = state.noClassList.filterVisible; - - state.noClassList.data.forEach((shape: any) => { - shape.filterVisible = state.noClassList.filterVisible; - shape.visible = shape.filterVisible; - }); - - state.list.forEach((item: any) => { - if (item.isModel) { - if ( - filterValue.value.includes(FilterEnum.predictedClass) || - filterValue.value.includes(item.classType) - ) { - item.filterVisible = true; - item.visible = true; - item.data.forEach((shape: any) => { - shape.filterVisible = true; - shape.visible = true; - }); - } else { - item.filterVisible = false; - item.visible = false; - item.data.forEach((shape: any) => { - shape.filterVisible = false; - shape.visible = false; - }); - } - } else { - if ( - filterValue.value.includes(FilterEnum.class) || - filterValue.value.includes(item.classType) - ) { - item.filterVisible = true; - item.visible = true; - item.data.forEach((shape: any) => { - shape.filterVisible = true; - shape.visible = true; - }); - } else { - item.filterVisible = false; - item.visible = false; - item.data.forEach((shape: any) => { - shape.filterVisible = false; - shape.visible = false; - }); - } - } - }); - } - - function toggleVisibleByFilter(isAllVisible?: boolean) { - console.log('toggleVisibleByFilter'); - const currentNoClassIds: string[] = []; - state.noClassList.data.forEach((item: any) => { - if (!_.isUndefined(isAllVisible)) item.visible = isAllVisible; - if (item.filterVisible && item.visible) currentNoClassIds.push(item.id); - }); - - const currentHasClassIds: string[] = []; - state.list.forEach((item: any) => { - item.data.forEach((child: any) => { - if (!_.isUndefined(isAllVisible)) child.visible = isAllVisible; - if (child.filterVisible && child.visible) currentHasClassIds.push(child.id); - }); - }); - if ( - _.isEqual(lastNoClassList.value, state.noClassList.data) && - _.isEqual(lastHasClassList.value, state.list) - ) { - if (_.isUndefined(isAllVisible)) { - return; - } else if (_.isEqual(allVisible.value, isAllVisible)) { - return; - } - } - - console.log(2); - lastNoClassList.value = _.cloneDeep(state.noClassList.data); - lastHasClassList.value = _.cloneDeep(state.list); - allVisible.value = editorState.allVisible; - - editor.setVisible([], false); - if (currentNoClassIds.length > 0 || currentHasClassIds.length > 0) { - editor.setVisible([...currentNoClassIds, ...currentHasClassIds], isAllVisible ?? true); - } - - if (state.select.length > 0) { - console.log('select', state); - const selectId = state.select[0]; - const flag1 = state.noClassList.data.some((item) => { - if (item.id == selectId) { - editor.setVisible([selectId], item.visible); - return true; - } else { - return false; - } - }); - if (flag1) return; - - let flag2 = false; - state.list.forEach((item) => { - if (!flag2) { - item.data.forEach((child) => { - if (!flag2 && child.id == selectId) { - flag2 = true; - editor.setVisible([selectId], child.visible); - } - }); - } - }); - } - } - - function changeImage() { - const defaultFilter = [FilterEnum.class, FilterEnum.predictedClass]; - onToggleFilterVisible(defaultFilter); - } - - function resetStateSelect() { - const selectId = state.select[0]; - console.log('reset state select', state.select); - const flag1 = state.noClassList.data.some((item) => item.id == selectId); - if (flag1) { - editor.setVisible([selectId], state.noClassList.filterVisible); - return; - } - let flag2 = false; - state.list.forEach((item) => { - if (!flag2) { - item.data.forEach((child) => { - if (!flag2 && child.id == selectId) { - flag2 = true; - editor.setVisible([selectId], child.visible); - } - }); - } - }); - } - - // 根据 obj.classType 和 obj.toolType 获取颜色。,防止 name 重复 - function getColor(obj: any) { - const classIdMap: Record = {}; - editorState.classTypes.forEach((e) => { - classIdMap[e.id] = e; - }); - const classType = obj.userData.classType || obj.userData.modelClass || ''; - const toolType = AnnotateType2ToolType[obj.type] || AnnotateType.RECTANGLE || ''; - - let targetClassType: any; - Object.keys(classIdMap).forEach((item: any) => { - const tempObj = classIdMap?.[item]; - if (tempObj?.name == classType && tempObj?.toolType == toolType) { - targetClassType = tempObj; - } - }); - - const color = targetClassType ? targetClassType.color : obj.color || '#ffffff'; - - return { - color, - toolType, - }; - } - - return { - noClassKey, - state, - onDeleteClassObject, - onItemTool, - onToggleClassVisible, - onEditModelClass, - filterValue, - onToggleFilterVisible, - toggleVisibleByFilter, - }; -} diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/useItem.ts b/frontend/image-tool/src/business/chengdu/components/Operation/Instance/useItem.ts deleted file mode 100644 index f90406a4..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Instance/useItem.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { useInjectEditor } from '../../../../../editor/inject'; -import { IItem } from './type'; -import { Event as EditorEvent } from '../../../../../editor'; -import * as _ from 'lodash'; - -export default function useItem() { - let editor = useInjectEditor(); - - function onEdit(item: IItem) { - let find = editor.tool?.shapes.getItemById(item.id); - - if (find) { - editor.emit(EditorEvent.SHOW_CLASS_INFO, { - data: { object: find }, - }); - } - } - - function onDelete(item: IItem) { - editor.showConfirm({ title: 'Delete', subTitle: 'Delete Objects?' }).then( - () => { - editor.cmdManager.execute('delete-object', { - object: editor.tool?.toJSON().filter((record: any) => record.uuid === item.id), - id: item.id, - }); - editor.tool?.removeById(item.id); - }, - () => {}, - ); - } - - function onToggleVisible(item: IItem) { - let visible = item.filterVisible && !item.visible; - item.visible = visible; - - editor.setVisible([item.id], visible); - } - - function onAnnotation(item: IItem): any {} - - return { - onEdit, - onDelete, - onToggleVisible, - onAnnotation, - }; -} diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Instructions/index.vue b/frontend/image-tool/src/business/chengdu/components/Operation/Instructions/index.vue deleted file mode 100644 index c30cc7b4..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Instructions/index.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/Results/index.vue b/frontend/image-tool/src/business/chengdu/components/Operation/Results/index.vue deleted file mode 100644 index 82526b89..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/Results/index.vue +++ /dev/null @@ -1,181 +0,0 @@ - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Operation/index.vue b/frontend/image-tool/src/business/chengdu/components/Operation/index.vue deleted file mode 100644 index bf092b45..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Operation/index.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Tool/Info.vue b/frontend/image-tool/src/business/chengdu/components/Tool/Info.vue deleted file mode 100644 index 175213c4..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Tool/Info.vue +++ /dev/null @@ -1,55 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Tool/InteractiveConfig.vue b/frontend/image-tool/src/business/chengdu/components/Tool/InteractiveConfig.vue deleted file mode 100644 index 906f6a80..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Tool/InteractiveConfig.vue +++ /dev/null @@ -1,215 +0,0 @@ - - diff --git a/frontend/image-tool/src/business/chengdu/components/Tool/Setting.vue b/frontend/image-tool/src/business/chengdu/components/Tool/Setting.vue deleted file mode 100644 index 4deb0eb4..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Tool/Setting.vue +++ /dev/null @@ -1,296 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Tool/index.vue b/frontend/image-tool/src/business/chengdu/components/Tool/index.vue deleted file mode 100644 index 742f4b74..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Tool/index.vue +++ /dev/null @@ -1,378 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/business/chengdu/components/Tool/item.ts b/frontend/image-tool/src/business/chengdu/components/Tool/item.ts deleted file mode 100644 index 08a156e8..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Tool/item.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { UIType } from 'editor'; -import Tool from '../../common/Tool'; -import { Component } from 'vue'; -import ModelToolTip from './modelConfig.vue'; -import InteractiveToolTip from './InteractiveConfig.vue'; -export interface IItemConfig { - action: string; - title: string; - hotkey: number; - bottomBar: boolean; - // active: boolean; - // display: boolean; - getStyle?: (tool: Tool) => object; - extra?: () => Component; - hasMsg?: (tool: Tool) => boolean; - getIcon: (tool: Tool) => string; - isDisplay: (tool: Tool) => boolean; - isActive: (tool: Tool) => boolean; -} - -export const allItems: IItemConfig[] = [ - { - action: 'edit', - title: 'Resize', - hotkey: 2, - bottomBar: true, - getIcon: function (tool: Tool) { - return 'iconfont icon-edit'; - }, - isDisplay: function (tool: Tool) { - let state = tool.editor.state; - return state.modeConfig.ui[UIType.edit]; - }, - isActive: function (tool: Tool) { - let state = tool.editor.state; - return state.activeItem === UIType.edit; - }, - }, - { - action: 'rectangle', - title: 'Rectangle', - hotkey: 3, - bottomBar: false, - getIcon: function (tool: Tool) { - return 'iconfont icon-rectangle'; - }, - isDisplay: function (tool: Tool) { - let state = tool.editor.state; - return state.modeConfig.ui[UIType.rectangle]; - }, - isActive: function (tool: Tool) { - let state = tool.editor.state; - return state.activeItem === UIType.rectangle; - }, - }, - { - action: 'polygon', - title: 'Polygon', - hotkey: 4, - bottomBar: false, - getIcon: function (tool: Tool) { - return 'iconfont icon-polygon'; - }, - isDisplay: function (tool: Tool) { - let state = tool.editor.state; - return state.modeConfig.ui[UIType.polygon]; - }, - isActive: function (tool: Tool) { - let state = tool.editor.state; - return state.activeItem === UIType.polygon; - }, - }, - { - action: 'polyline', - title: 'Polyline', - hotkey: 5, - bottomBar: true, - getIcon: function (tool: Tool) { - return 'iconfont icon-polyline'; - }, - isDisplay: function (tool: Tool) { - let state = tool.editor.state; - return state.modeConfig.ui[UIType.polyline]; - }, - isActive: function (tool: Tool) { - let state = tool.editor.state; - return state.activeItem === UIType.polyline; - }, - }, - { - action: 'model', - title: 'Smart Tool', - hotkey: 7, - bottomBar: false, - hasMsg: function (tool: Tool) { - let state = tool.state; - let dataInfo = state.dataList[state.dataIndex]; - return dataInfo && !!dataInfo.model && dataInfo.model.state === 'complete'; - }, - extra: () => ModelToolTip, - getStyle: function (tool: Tool) { - return { - 'margin-bottom': 0, - 'border-bottom-right-radius': 0, - 'border-bottom-left-radius': 0, - 'padding-bottom': 0, - 'margin-top': 4, - }; - }, - getIcon: function (tool: Tool) { - let state = tool.state; - let dataInfo = state.dataList[state.dataIndex]; - return dataInfo && !!dataInfo.model && dataInfo.model.state === 'loading' - ? 'iconfont icon-loading loading' - : 'iconfont icon-ai'; - }, - isDisplay: function (tool: Tool) { - let state = tool.editor.state; - return state.modeConfig.ui[UIType.model]; - }, - isActive: function (tool: Tool) { - let state = tool.state; - let dataInfo = state.dataList[state.dataIndex]; - return dataInfo && !!dataInfo.model && dataInfo.model.state === 'loading'; - // return state.activeItem === UIType.model; - }, - }, - // { - // action: 'interactive', - // title: 'Interactive Tool', - // hotkey: 8, - // bottomBar: false, - // // extra: () => InteractiveToolTip, - // // getStyle: function (tool: Tool) { - // // return { - // // 'margin-bottom': 0, - // // 'border-bottom-right-radius': 0, - // // 'border-bottom-left-radius': 0, - // // 'padding-bottom': 0, - // // 'margin-top': 4, - // // background: '#1e1f22', - // // }; - // // }, - // getIcon: function (tool: Tool) { - // return 'iconfont icon-interactive'; - // // return 'iconfont icon-interactive interactive'; - // }, - // isDisplay: function (tool: Tool) { - // let state = tool.editor.state; - // return state.modeConfig.ui[UIType.interactive]; - // }, - // isActive: function (tool: Tool) { - // let state = tool.editor.state; - // return state.activeItem === UIType.interactive; - // }, - // }, -]; diff --git a/frontend/image-tool/src/business/chengdu/components/Tool/modelConfig.vue b/frontend/image-tool/src/business/chengdu/components/Tool/modelConfig.vue deleted file mode 100644 index 31956ff7..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Tool/modelConfig.vue +++ /dev/null @@ -1,215 +0,0 @@ - - diff --git a/frontend/image-tool/src/business/chengdu/components/Tool/useTool.ts b/frontend/image-tool/src/business/chengdu/components/Tool/useTool.ts deleted file mode 100644 index d4e4c25f..00000000 --- a/frontend/image-tool/src/business/chengdu/components/Tool/useTool.ts +++ /dev/null @@ -1,171 +0,0 @@ -import { reactive, toRefs } from 'vue'; -import { useInjectTool } from '../../state'; -import { IModelResult, IModel } from '../../type'; -import * as api from '../../api'; -import BSError from '../../common/BSError'; -import { allItems } from './item'; -import { BsUIType } from '../../config/ui'; -import { handleError } from '../../utils'; -export interface IClass { - label: string; - value: string; - selected: boolean; -} -export default function useTool() { - let tool = useInjectTool(); - let editor = tool.editor; - let innerState = reactive({ - allItems, - }); - - function onTool(name: string, args?: any) { - // let config = editor.state.config; - console.log('select', name); - switch (name) { - case 'edit': { - if (editor.toolConfig.isDrawing) { - handleError(tool, new BSError('', 'Please finish drawing first')); - return; - } - if (editor.tool) { - editor.tool.toolmanager.currentTool = null; - } - editor.tool?.setMode('edit'); - editor.state.activeItem = BsUIType.edit; - editor.state.helpLineVisible = false; - break; - } - case 'rectangle': - case 'polygon': - case 'polyline': { - if (editor.toolConfig.isDrawing) { - handleError(tool, new BSError('', 'Please finish drawing first')); - return; - } - editor.tool?.setMode('draw'); - editor.tool?.toolmanager.selectTool(name); - editor.state.activeItem = BsUIType[name]; - editor.state.helpLineVisible = true; - break; - } - case 'model': - if (editor.toolConfig.isDrawing) { - handleError(tool, new BSError('', 'Please finish drawing first')); - return; - } - onModel(); - break; - case 'interactive': { - if (editor.toolConfig.isDrawing) { - handleError(tool, new BSError('', 'Please finish drawing first')); - return; - } - editor.tool?.setMode('draw'); - editor.tool?.toolmanager.selectTool('interactive'); - editor.state.activeItem = BsUIType.interactive; - editor.state.helpLineVisible = true; - break; - } - case 'addInterior': { - editor.tool?.addInteriorToShape(); - // editor.cmdManager.execute('add-interior', {}); - break; - } - case 'removeInterior': { - editor.tool?.removeInterior(); - // editor.cmdManager.execute('remove-interior', {}); - break; - } - case 'clipPolygon': { - editor.tool?.clipPolygon(args); - break; - } - } - } - async function runModel() { - const modelConfig = tool.state.modelConfig; - if (!modelConfig.model) { - editor.showMsg('warning', 'Please choose Model'); - return; - } - let toolState = tool.state; - let data = toolState.dataList[toolState.dataIndex]; - let model = toolState.models.find((e) => e.name === modelConfig.model) as IModel; - const resultFilterParam = { - minConfidence: 0.5, - maxConfidence: 1, - classes: model?.classes.map((e) => e.value), - }; - if (!modelConfig.predict) { - const selectedClasses = (modelConfig.classes[modelConfig.model] || []).reduce( - (classes, item) => { - if (item.selected) { - classes.push(item.value); - } - return classes; - }, - [] as string[], - ); - if (selectedClasses.length <= 0) { - editor.showMsg('warning', 'Select at least one Class!'); - return; - } - resultFilterParam.minConfidence = modelConfig.confidence[0]; - resultFilterParam.maxConfidence = modelConfig.confidence[1]; - resultFilterParam.classes = selectedClasses; - } - let config = { - datasetId: data.datasetId, - dataIds: [+data.dataId], - modelId: +model.id, - modelVersion: model?.version, - dataType: 'SINGLE_DATA', - modelCode: model.code, - // annotationRecordId: +toolState.recordId, - resultFilterParam, - }; - - modelConfig.loading = true; - try { - let result = await api.runModel(config); - if (!result.data) throw new Error('Model Run Error'); - data.model = { - recordId: result.data, - id: model.id, - version: model.version, - state: 'loading', - }; - } catch (error) { - tool.editor.showMsg('error', 'Model Run Error'); - } - modelConfig.loading = false; - tool.dataManager.pollDataModelResult(); - } - function onModel() { - let toolState = tool.state; - let dataInfo = toolState.dataList[toolState.dataIndex]; - - if (dataInfo.loadState === 'loading') return; - - // if (dataInfo.model) { - if (dataInfo.model && dataInfo.model.state === 'complete') { - let model = dataInfo.model as IModelResult; - console.log(model); - editor.showConfirm({ title: 'Model Results', subTitle: 'Add Results?' }).then( - async () => { - await api.clearModel([+dataInfo.dataId], model.recordId); - tool.addModelData(); - }, - () => {}, - ); - } else { - // editor.showModal('modelRun', { title: 'AI Annotation', data: {} }); - runModel(); - } - } - return { - ...toRefs(innerState), - runModel, - onTool, - }; -} diff --git a/frontend/image-tool/src/business/chengdu/config/action.ts b/frontend/image-tool/src/business/chengdu/config/action.ts deleted file mode 100644 index 79eb618b..00000000 --- a/frontend/image-tool/src/business/chengdu/config/action.ts +++ /dev/null @@ -1,31 +0,0 @@ -import * as BsActions from '../actions'; -import { IActionName, AllActions as editorActions } from 'editor'; - -export type IBsActionName = keyof typeof BsActions | IActionName; - -export const allActions = [...editorActions, ...Object.keys(BsActions)] as IBsActionName[]; - -export const viewActions: IBsActionName[] = []; - -// pending -- -export const commonActions: IBsActionName[] = [ - 'KeyEscDown', - 'KeyEnterDown', - 'onDelete', - 'onSave', - 'toggleKeyboard', - 'undo', - 'redo', - 'pageUp', - 'pageDown', -]; -export const rectActions: IBsActionName[] = [...commonActions]; -export const polygonActions: IBsActionName[] = [...commonActions]; -export const polylineActions: IBsActionName[] = [...commonActions]; -export const interactiveActions: IBsActionName[] = [...commonActions]; - -// The following is not used for the time being -export const configActions: IBsActionName[] = ['toggleClassView']; -export const sideActions: IBsActionName[] = ['toggleKeyboard']; -export const executeActions: IBsActionName[] = ['undo', 'redo']; -export const verifyActions: IBsActionName[] = [...configActions]; diff --git a/frontend/image-tool/src/business/chengdu/config/event.ts b/frontend/image-tool/src/business/chengdu/config/event.ts deleted file mode 100644 index a6c395f7..00000000 --- a/frontend/image-tool/src/business/chengdu/config/event.ts +++ /dev/null @@ -1,5 +0,0 @@ -const Event = { - FLOW_ACTION: 'flow_action', -}; - -export default Event; diff --git a/frontend/image-tool/src/business/chengdu/config/hotkey.ts b/frontend/image-tool/src/business/chengdu/config/hotkey.ts deleted file mode 100644 index 71f675f3..00000000 --- a/frontend/image-tool/src/business/chengdu/config/hotkey.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { IHotkeyConfig } from 'pc-editor'; -import { IBsActionName } from './action'; - -const hotkeyConfig: IHotkeyConfig[] = [ - // flow - { key: 'ctrl+s', action: 'flowSave' }, - { key: 'shift+s', action: 'flowHung' }, - { key: 'shift+d', action: ['flowSubmit', 'flowPass'] }, - { key: 'ctrl+shift+d', action: 'flowSubmitExit' }, - { key: 'shift+r', action: 'flowReject' }, - { key: 'shift+e', action: 'flowEdit' }, -]; - -export default hotkeyConfig; diff --git a/frontend/image-tool/src/business/chengdu/config/mode.ts b/frontend/image-tool/src/business/chengdu/config/mode.ts deleted file mode 100644 index 2063f582..00000000 --- a/frontend/image-tool/src/business/chengdu/config/mode.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { IModeConfig, OPType } from 'editor'; -import { BsUIType, IBsUIType, executeUI, verifyUI } from './ui'; -import { - IBsActionName, - allActions, - rectActions, - polygonActions, - polylineActions, - interactiveActions, -} from './action'; - -function toMap(arr: T[]) { - let map = {} as Record; - arr.forEach((e) => (map[e] = true)); - return map; -} - -const execute: IModeConfig = { - op: OPType.EXECUTE, - ui: toMap([...executeUI]), - actions: toMap(allActions), // For the time being, all methods are directly configured as initial values. -}; - -const view: IModeConfig = { - op: OPType.VIEW, - ui: toMap([...verifyUI]), - actions: toMap([]), -}; - -const rect: IModeConfig = { - op: OPType.EXECUTE, - ui: toMap([...executeUI]), - actions: toMap(rectActions), -}; -const polygon: IModeConfig = { - op: OPType.EXECUTE, - ui: toMap([...executeUI]), - actions: toMap(polygonActions), -}; -const polyline: IModeConfig = { - op: OPType.EXECUTE, - ui: toMap([...executeUI]), - actions: toMap(polylineActions), -}; -const interactive: IModeConfig = { - op: OPType.EXECUTE, - ui: toMap([...executeUI]), - actions: toMap(interactiveActions), -}; - -let modes = { - execute, - view, - rect, - polygon, - polyline, - interactive, -}; - -export type IModeType = keyof typeof modes; -export const ModeKeys = Object.keys(modes).filter((e) => e !== 'all') as IModeType[]; - -Object.keys(modes).forEach((name) => { - let mode = modes[name as IModeType]; - mode.name = name; -}); -export default modes; diff --git a/frontend/image-tool/src/business/chengdu/config/type.ts b/frontend/image-tool/src/business/chengdu/config/type.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/frontend/image-tool/src/business/chengdu/config/ui.ts b/frontend/image-tool/src/business/chengdu/config/ui.ts deleted file mode 100644 index b13496f5..00000000 --- a/frontend/image-tool/src/business/chengdu/config/ui.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { UIType } from 'editor'; - -export const BsUIType = { - ...UIType, - flowSave: 'flowSave', -}; -export type IBsUIType = keyof typeof BsUIType; -export const allUI = Object.keys(BsUIType) as IBsUIType[]; - -export const executeUI = [ - BsUIType.edit, - BsUIType.rectangle, - BsUIType.interactive, - BsUIType.model, - BsUIType.polygon, - BsUIType.polyline, - BsUIType.info, - BsUIType.setting, - BsUIType.flowSave, -] as IBsUIType[]; - -export const verifyUI = [BsUIType.setting, BsUIType.info] as IBsUIType[]; diff --git a/frontend/image-tool/src/business/chengdu/data/classType.ts b/frontend/image-tool/src/business/chengdu/data/classType.ts deleted file mode 100644 index 74211228..00000000 --- a/frontend/image-tool/src/business/chengdu/data/classType.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { AttrType, IClassType } from 'editor'; - -const colors = [ - '#1f77b4', - '#ff7f0e', - '#2ca02c', - '#d62728', - '#9467bd', - '#8c564b', - '#e377c2', - '#7f7f7f', - '#bcbd22', - '#17becf', -]; - -let classTypesConfig: IClassType[] = [ - { - id: 1 + '', - label: 'Car', - name: 'Car', - color: '', - attrs: [ - { name: 'name', type: AttrType.TEXT, required: true, options: [] }, - { - name: 'color', - type: AttrType.DROPDOWN, - required: true, - options: [ - { value: '#d62728', label: '#d62728' }, - { value: '#9467bd', label: '#9467bd' }, - ], - }, - { - name: 'type', - type: AttrType.MULTI_SELECTION, - required: true, - options: [ - { value: 'Apple', label: 'Apple' }, - { value: 'Orange', label: 'Orange' }, - { value: 'Pear', label: 'Pear' }, - ], - }, - ], - }, - { - id: 2 + '', - label: 'Pedestrain', - name: 'Pedestrain', - color: '', - attrs: [ - { name: 'name', type: AttrType.TEXT, required: true, options: [] }, - { - name: 'type', - type: AttrType.RADIO, - required: true, - options: [ - { value: 'type1', label: 'type1' }, - { value: 'type2', label: 'type2' }, - { value: 'type3', label: 'type3' }, - ], - }, - ], - }, - { - id: 3 + '', - label: 'Bicycle', - name: 'Bicycle', - color: '', - attrs: [ - { name: 'name', type: AttrType.TEXT, required: true, options: [] }, - { - name: 'type', - required: true, - type: AttrType.DROPDOWN, - options: [ - { value: 'Apples', label: 'Apples' }, - { value: 'Nails', label: 'Nails' }, - { value: 'Bananas', label: 'Bananas' }, - { value: 'Helicopters', label: 'Helicopters' }, - ], - }, - ], - }, -]; - -classTypesConfig = classTypesConfig.map((e, index) => { - return { ...e, color: colors[index] }; -}); - -export { classTypesConfig, colors }; diff --git a/frontend/image-tool/src/business/chengdu/hook/useFlow.ts b/frontend/image-tool/src/business/chengdu/hook/useFlow.ts deleted file mode 100644 index 0161e88a..00000000 --- a/frontend/image-tool/src/business/chengdu/hook/useFlow.ts +++ /dev/null @@ -1,85 +0,0 @@ -import * as pageHandler from '../pages'; -import { setToken } from '../api/base'; -import { useInjectTool } from '../state'; -import Event from '../config/event'; -import * as _ from 'lodash'; -import { enableEscOnFullScreen } from '../utils'; -import useQuery from './useQuery'; -import useToken from './useToken'; - -export type IHandlerType = keyof typeof pageHandler; - -export default function UseFlow() { - let tool = useInjectTool(); - let editor = tool.editor; - let query = useQuery(); - let token = useToken(); - - // datasetId=30093&dataId=352734&type=readOnly - - let mode = getMode(query); - let handler = pageHandler[mode](); - // let handler = pageHandler.dev(); - - function init() { - iniQuery(); - - if (!token) { - editor.showMsg('error', 'Not logged in'); - console.log('Not logged in'); - return; - } - setToken(token); - - initFlowEvent(); - handleUnload(); - enableEscOnFullScreen(); - handler.init(); - } - - function handleUnload() { - if (!import.meta.env.DEV) { - window.addEventListener('beforeunload', (event: Event) => { - console.log('beforeunload'); - if (tool.needSave()) { - event.preventDefault(); - // @ts-ignore - event.returnValue = "You didn't save changes?"; - } - }); - } - } - - function initFlowEvent() { - // tool.editor.addEventListener(Event.FLOW_ACTION, (data: any) => { - // // console.log(data.data); - // handler.onAction(data.data); - // }); - } - - function iniQuery() { - let { state } = tool; - Object.assign(state.query, query || {}); - state.recordId = (query.recordId as string) || ''; - state.datasetId = (query.datasetId as string) || ''; - if (query.dataId as string) { - state.focus = { - dataId: (query.dataId as string) || '', - focusId: +(query.focus as string), - }; - } - } - - return { - init, - }; -} - -function getMode(query: Record): IHandlerType { - let mode = 'execute' as IHandlerType; - if (query.type === 'readOnly') { - mode = 'view'; - } - - return mode; -} diff --git a/frontend/image-tool/src/business/chengdu/hook/useQuery.ts b/frontend/image-tool/src/business/chengdu/hook/useQuery.ts deleted file mode 100644 index 47dc998f..00000000 --- a/frontend/image-tool/src/business/chengdu/hook/useQuery.ts +++ /dev/null @@ -1,7 +0,0 @@ -import queryString from 'query-string'; - -export default function useQuery() { - let queryStr = location.href.split('?').reverse(); - const query = queryString.parse(queryStr[0] || ''); - return query; -} diff --git a/frontend/image-tool/src/business/chengdu/hook/useToken.ts b/frontend/image-tool/src/business/chengdu/hook/useToken.ts deleted file mode 100644 index 21ad0371..00000000 --- a/frontend/image-tool/src/business/chengdu/hook/useToken.ts +++ /dev/null @@ -1,19 +0,0 @@ -import Cookies from 'js-cookie'; - -window.Cookies = Cookies; - -let hostname = document.location.hostname || document.location.host; -// let dot = hostname.indexOf('.'); -// let parentHost = isIp(hostname) ? hostname : hostname.substring(dot + 1); - -export default function useToken() { - let token = Cookies.get(`${hostname} token`); - token = token ? `Bearer ${token}` : ''; - return token; -} - -function isIp(str: string = '') { - return /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/.test( - str, - ); -} diff --git a/frontend/image-tool/src/business/chengdu/hook/useTool.ts b/frontend/image-tool/src/business/chengdu/hook/useTool.ts deleted file mode 100644 index 9e0d765c..00000000 --- a/frontend/image-tool/src/business/chengdu/hook/useTool.ts +++ /dev/null @@ -1,63 +0,0 @@ -import * as api from '../api'; -import { useInjectTool } from '../state'; - -export default function useTool() { - let tool = useInjectTool(); - let toolState = tool.state; - let editor = tool.editor; - - async function loadClasses() { - let config = await api.getDataSetClass(toolState.datasetId); - editor.setClassTypes(config); - } - - async function loadModels() { - let models = await api.getModelList(); - toolState.models = models; - } - - async function loadDateSetClassification() { - let classifications = await api.getDataSetClassification(toolState.datasetId); - toolState.classifications = classifications; - } - - async function loadDataFile() { - let { dataList } = toolState; - let classifications = await api.getDataFile(dataList[0].dataId); - } - - async function loadRecord() { - let { recordId } = toolState; - let { dataInfos } = await api.getInfoByRecordId(recordId); - - if (dataInfos.length === 0) { - // editor.showMsg('error', 'No Data'); - // return; - throw new Error('No Data'); - } - if (toolState?.focus?.dataId) { - toolState.dataList = dataInfos.filter( - (item) => item.dataId == toolState?.focus?.dataId, - ); - toolState.datasetId = dataInfos[0].datasetId + ''; - } else { - toolState.dataList = dataInfos; - toolState.datasetId = dataInfos[0].datasetId + ''; - } - } - - async function loadInfo() { - await loadRecord(); - await loadClasses(); - await loadModels(); - await loadDateSetClassification(); - await loadDataFile(); - } - return { - loadInfo, - loadRecord, - loadClasses, - loadModels, - loadDateSetClassification, - }; -} diff --git a/frontend/image-tool/src/business/chengdu/hook/useUI.ts b/frontend/image-tool/src/business/chengdu/hook/useUI.ts deleted file mode 100644 index 48fbe927..00000000 --- a/frontend/image-tool/src/business/chengdu/hook/useUI.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { useInjectTool } from '../state'; -import { OPType, StatusType } from 'editor'; -import { IBsUIType } from '../config/ui'; - -export default function useUI() { - let tool = useInjectTool(); - let editor = tool.editor; - let state = editor.state; - function has(name: IBsUIType | string) { - return state.modeConfig.ui[name]; - } - function canEdit() { - return state.modeConfig.op === OPType.EXECUTE || state.mode === 'all'; - } - function canAnnotate() { - return state.modeConfig.op === OPType.VERIFY || state.mode === 'all'; - } - - function canOperate() { - return state.status === StatusType.Default; - } - function isShowAttrs() { - return state.showAttrs; - } - function isShowSize() { - return state.showSize; - } - - return { - has, - canEdit, - canAnnotate, - canOperate, - isShowAttrs, - isShowSize, - }; -} diff --git a/frontend/image-tool/src/business/chengdu/pages/dev.ts b/frontend/image-tool/src/business/chengdu/pages/dev.ts deleted file mode 100644 index 0c557c6e..00000000 --- a/frontend/image-tool/src/business/chengdu/pages/dev.ts +++ /dev/null @@ -1,27 +0,0 @@ -import modes from '../config/mode'; -import * as THREE from 'three'; -import { IPageHandler, IAction } from '../type'; -import useTool from '../hook/useTool'; -import { useInjectTool } from '../state'; - -export function dev(): IPageHandler { - let tool = useInjectTool(); - let editor = tool.editor; - let { loadInfo } = useTool(); - - async function init() { - let { query } = tool.state; - if (!query.recordId) { - editor.showMsg('error', 'Invalid Query'); - return; - } - loadInfo(); - } - - function onAction(action: IAction) {} - - return { - init, - onAction, - }; -} diff --git a/frontend/image-tool/src/business/chengdu/pages/execute.ts b/frontend/image-tool/src/business/chengdu/pages/execute.ts deleted file mode 100644 index 00b570b8..00000000 --- a/frontend/image-tool/src/business/chengdu/pages/execute.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { IAction, IPageHandler } from '../type'; -import { useInjectTool } from '../state'; -import modes from '../config/mode'; -import useTool from '../hook/useTool'; -import BSError from '../common/BSError'; - -export function execute(): IPageHandler { - let tool = useInjectTool(); - - let { loadClasses, loadRecord, loadModels, loadDateSetClassification } = useTool(); - - // datasetId=30093&dataId=352734&type=readOnly - - async function init() { - if (!tool.state.query.recordId) { - tool.editor.showMsg('error', 'Invalid Query'); - return; - } - - // 设置模式 - // -- 这里根据设置的模式,然后设置对应模式下的 action - tool.editor.setMode(modes.execute); - tool.editor.showLoading(true); - try { - await loadRecord(); - if (tool.state.dataList.length === 0) return; - await Promise.all([loadDateSetClassification(), loadClasses(), loadModels()]); - // 自动加载资源 - // tool.dataResource.load(); - await tool.loadData(0, false); - } catch (error: any) { - tool.handleErr(new BSError('', 'Load Error', error)); - } - - tool.editor.showLoading(false); - tool.editor.tool?.setMode('edit'); - - if (tool.state.query.type === 'modelRun') { - tool.dataManager.pollDataModelResult(); - } - } - - function onAction(action: IAction) { - switch (action) { - case 'save': - tool.saveObject(); - break; - } - } - - return { - init, - onAction, - }; -} diff --git a/frontend/image-tool/src/business/chengdu/pages/index.ts b/frontend/image-tool/src/business/chengdu/pages/index.ts deleted file mode 100644 index 587e37bf..00000000 --- a/frontend/image-tool/src/business/chengdu/pages/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -// export * from './dev'; -export * from './execute'; -export * from './view'; diff --git a/frontend/image-tool/src/business/chengdu/pages/view.ts b/frontend/image-tool/src/business/chengdu/pages/view.ts deleted file mode 100644 index e79e805c..00000000 --- a/frontend/image-tool/src/business/chengdu/pages/view.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { IAction, IPageHandler, IDataMeta } from '../type'; -import { useInjectTool } from '../state'; -import modes from '../config/mode'; -import useTool from '../hook/useTool'; -import BSError from '../common/BSError'; - -export function view(): IPageHandler { - let tool = useInjectTool(); - - let { loadClasses, loadDateSetClassification } = useTool(); - - async function init() { - let { query } = tool.state; - if (!query.datasetId || !query.dataId) { - tool.editor.showMsg('error', 'Invalid Query'); - return; - } - - tool.editor.setMode(modes.view); - - tool.editor.showLoading(true); - try { - await Promise.all([loadDateSetClassification(), loadClasses(), loadDataInfo()]); - await tool.loadData(0, false); - } catch (error: any) { - tool.handleErr(new BSError('', 'Load Error', error)); - } - tool.editor.tool?.setMode('view'); - tool.editor.showLoading(false); - } - - async function loadDataInfo() { - let { query } = tool.state; - - let dataId = query.dataId; - if (query.dataType === 'frame') { - tool.state.isSeriesFrame = true; - await loadDataFromFrameSeries(dataId); - } else { - createSingleData(); - } - } - - function createSingleData() { - let { query } = tool.state; - - let dataId = query.dataId; - let data: IDataMeta = { - dataId: dataId, - datasetId: query.datasetId, - teamId: '', - pointsUrl: '', - queryTime: '', - loadState: '', - needSave: false, - classifications: [], - }; - - tool.state.dataList = [data]; - } - - function onAction(action: IAction) {} - - return { - init, - onAction, - }; -} diff --git a/frontend/image-tool/src/business/chengdu/registry.ts b/frontend/image-tool/src/business/chengdu/registry.ts deleted file mode 100644 index 22ce854d..00000000 --- a/frontend/image-tool/src/business/chengdu/registry.ts +++ /dev/null @@ -1,10 +0,0 @@ -// import { Editor } from 'pc-editor'; -import hotkeyConfig from './config/hotkey'; -// import * as Actions from './actions'; - -export function initRegistry(editor: Editor) { - editor.hotkeyManager.registryHotkey(hotkeyConfig); - Object.keys(Actions).forEach((name) => { - editor.actionManager.registryAction(name, (Actions as any)[name]); - }); -} diff --git a/frontend/image-tool/src/business/chengdu/state.ts b/frontend/image-tool/src/business/chengdu/state.ts deleted file mode 100644 index a98e3547..00000000 --- a/frontend/image-tool/src/business/chengdu/state.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { provide, inject, reactive } from 'vue'; -import Tool from './common/Tool'; -import { Editor } from 'editor/Editor'; -import { IToolState, IToolConfig, IModelClass } from './type'; -// import { initRegistry } from './registry'; - -import { useProvideEditor, useProvideEditorState } from 'editor/inject'; - -export function getDefaultConfig(): IToolConfig { - return { - FILTER_ALL: 'All', - }; -} -let withoutTaskId = '-1'; -let FILTER_ALL = 'All'; -export function getDefault(): IToolState { - return { - query: {}, - // flow - saving: false, - // - models: [], - // serial number - recordId: '', - // dataset - datasetId: '', - // - // data - dataList: [], - dataIndex: -1, - // classification config - classifications: [], - sources: [], - sourceFilters: [FILTER_ALL], - activeSourceData: withoutTaskId, - FILTER_ALL: 'All', - withoutTaskId: withoutTaskId, - // user - user: { - id: '', - nickname: '', - }, - // classificationForm: null, - showVerify: false, - modelConfig: { - confidence: [0.5, 1], - predict: true, - classes: {} as { [key: string]: IModelClass[] }, - model: '', - loading: false, - }, - }; -} - -// global state -export const toolContext = Symbol('pc-tool-image-tool'); -export function useProvideTool() { - let tool = new Tool(); - // @ts-ignore - window.tool = tool; - // @ts-ignore - tool.state = reactive(tool.state); - tool.editor.state = reactive(tool.editor.state); - - // initRegistry(tool.editor); - useProvideEditor(tool.editor); - useProvideEditorState(tool.editor.state); - provide(toolContext, tool); - - return tool; -} - -export function useInjectTool(): Tool { - return inject(toolContext) as Tool; -} diff --git a/frontend/image-tool/src/business/chengdu/type.ts b/frontend/image-tool/src/business/chengdu/type.ts deleted file mode 100644 index d1e0913b..00000000 --- a/frontend/image-tool/src/business/chengdu/type.ts +++ /dev/null @@ -1,246 +0,0 @@ -// import type { FormInstance } from 'ant-design-vue'; -export interface IUser { - id: string; - nickname: string; -} - -export interface IObjectV2 { - id?: string; - type?: ObjectType; - version?: number; - createdBy?: number; - createdAt?: string; - - trackId?: string; - trackName?: string; - classId?: string; - className?: string; - backId?: string; - frontId?: string; - classType?: string; - classValues?: any[]; - // classValues?: Record; - modelConfidence?: number; - modelClass?: string; - contour: { - [k: string]: any; - }; - meta?: { - [k: string]: any; - }; - // other - sourceId?: string; - sourceType?: string; -} - -export interface IModelConfig { - confidence: number[]; - predict: boolean; - classes: { [key: string]: IModelClass[] }; - model: string; - loading: boolean; -} -export interface IToolConfig { - FILTER_ALL: string; -} - -export enum SourceType { - TASK = 'TASK', - DATA_FLOW = 'DATA_FLOW', - MODEL = 'MODEL', -} - -export interface IResultSource { - name: string; - sourceId: string; - sourceType: SourceType; - modelId?: string; - modelName?: string; -} -export interface IToolState { - query: Record; - // flow - saving: boolean; - // - models: IModel[]; - // serial number - recordId: string; - // dataset - datasetId: string; - // - user: IUser; - // data - dataList: IDataMeta[]; - dataIndex: number; - // classification config - classifications: IClassification[]; - // classificationForm: FormInstance | null; - showVerify?: boolean; - // run model config - modelConfig: IModelConfig; - resultActive?: any; - seriesFrameId?: any; - resultFilter?: any; - sources: IResultSource[]; - sourceFilters: string[]; - activeSourceData: string; - FILTER_ALL: string; - withoutTaskId: string; - focus?: any; -} - -export interface IDataMeta { - datasetId: string; - // id - dataId: string; - // uuid - // id: string; - teamId?: string; - imageUrl: string; - queryTime: string; - // autoload - loadState: LoadStatus; - // model - model?: IModelResult; - // classification values - classifications: IClassification[]; - // save - needSave: boolean; - resultExist?: boolean; - dataConfig: IFileConfig; - validStatus: any; - annotationStatus: any; - isAnnotated: boolean; - sources?: IResultSource[]; -} - -export interface IFileConfig { - // dirName: string; - name: string; - size: number; - url: string; -} - -export type IAction = 'save'; - -export interface IPageHandler { - init: () => void; - onAction: (e: IAction) => void; -} - -export type LoadStatus = '' | 'loading' | 'complete' | 'error'; - -export interface IModelResult { - recordId: string; - id: string; - version: string; - state?: LoadStatus; -} -export type PointAttr = 'position' | 'color' | string; -export interface IDataResource { - time: number; - // position - image: HTMLImageElement | string; -} - -export interface IResourceLoader { - data: IDataMeta; - getResource: () => Promise; - onProgress?: (percent: number) => void; -} - -export enum ObjectType { - TYPE_3D = '3d', - TYPE_RECT = 'rect', - TYPE_BOX2D = 'box2d', -} -export interface IObject { - frontId?: string; - uuid?: string; - objType: string; - id: string; - classType: string; - attrs: Record; - // model - confidence?: number; - modelClass?: string; - modelRun?: string; - // - coordinate: THREE.Vector2[]; - color: string; -} - -export interface IResultFilter { - value?: string; - label: string; - type: '' | 'project' | 'model'; - options?: { value: string; label: string }[]; -} - -export interface IModel { - id: string; - name: string; - version: string; - classes: IModelClass[]; - code: string; -} -export interface IModelClass { - code: string; - name: string; - label: string; - value: string; - selected?: boolean; - subClasses?: IModelClass; - url: string; -} -export interface IClassificationAttr { - classificationId: string; - parent: string; - parentAttr: string; - parentValue: any; - id: string; - type: AttrType; - name: string; - label?: string; - required: boolean; - options: { value: any; label: string }[]; - value: any; -} - -export interface IClassification { - id: string; - name: string; - label?: string; - attrs: IClassificationAttr[]; -} - -export interface IModel { - id: string; - name: string; - version: string; - classes: IModelClass[]; - code: string; -} - -export enum AttrType { - RADIO = 'RADIO', - MULTI_SELECTION = 'MULTI_SELECTION', - DROPDOWN = 'DROPDOWN', - TEXT = 'TEXT', -} - -export interface Point { - x: number; - y: number; -} -export interface Box2D { - type: ObjectType; - uuid: string; - intId: number; - classType: string; - attrs: Record; - points: Point[]; -} -export type AnnotateObject = Box2D; - -export type IClassType = any; diff --git a/frontend/image-tool/src/business/chengdu/utils/classType.ts b/frontend/image-tool/src/business/chengdu/utils/classType.ts deleted file mode 100644 index f5107d51..00000000 --- a/frontend/image-tool/src/business/chengdu/utils/classType.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { IAttr } from 'editor'; -import { AttrType, IClassType } from '../type'; - -export function isClassAttrHasValue(attr: IAttr) { - if (attr.type === AttrType.MULTI_SELECTION) { - return Array.isArray(attr.value) && attr.value.length > 0; - } else { - return !!attr.value; - } -} - -export function isClassAttrVisible(attr: IAttr, attrMap: Record): boolean { - if (!attr.parent) return true; - let parentAttr = attrMap[attr.parent]; - let visible = - parentAttr.type !== AttrType.MULTI_SELECTION - ? parentAttr.value === attr.parentValue - : (parentAttr.value as any[]).indexOf(attr.parentValue) >= 0; - - return visible && isClassAttrVisible(parentAttr, attrMap); -} -export function copyClassAttrs(classType: IClassType, valueMap: Record = {}) { - let copyClassAttrs = JSON.parse(JSON.stringify(classType.attrs)) as IAttr[]; - copyClassAttrs.forEach((attr) => { - attr.value = attr.type === AttrType.MULTI_SELECTION ? [] : ''; - if (valueMap[attr.id]) { - if (attr.type === AttrType.MULTI_SELECTION && !Array.isArray(valueMap[attr.id])) { - valueMap[attr.id] = [valueMap[attr.id]]; - } - attr.value = valueMap[attr.id]; - } - }); - return copyClassAttrs; -} diff --git a/frontend/image-tool/src/business/chengdu/utils/classification.ts b/frontend/image-tool/src/business/chengdu/utils/classification.ts deleted file mode 100644 index b62afa81..00000000 --- a/frontend/image-tool/src/business/chengdu/utils/classification.ts +++ /dev/null @@ -1,308 +0,0 @@ -import { IClassType } from 'editor/type'; -import { AttrType, IClassification, IClassificationAttr } from '../api/typing'; - -export function traverseClassification2Arr(data: any[]) { - let classifications = [] as IClassification[]; - - data.forEach((e: any) => { - let attribute = e.attribute || e; - let classificationId = e.id + ''; - - let classification: IClassification = { - id: classificationId, - name: e.name, - label: e.name, - attrs: [], - }; - let options = attribute.options || []; - if (e.inputType) { - attribute.type = e.inputType; - } - let classificationAttr: IClassificationAttr = { - id: attribute.id, - key: attribute.name, - classificationId, - parent: '', - parentValue: '', - parentAttr: e.name, - type: attribute.type, - name: attribute.name, - label: attribute.name, - value: attribute.type === AttrType.MULTI_SELECTION ? [] : '', - required: attribute.required, - options: options.map((e: any) => { - return { value: e.name, label: e.name }; - }), - }; - - classification.attrs.push(classificationAttr); - options.forEach((option: any) => { - traverseOption(classification, option, classificationAttr.id, attribute.name); - }); - classifications.push(classification); - }); - - return classifications; - - function traverseOption( - classification: IClassification, - option: any, - parent: string, - parentAttr: string, - ) { - if (!option.attributes || option.attributes.length === 0) return; - - option.attributes.forEach((attr: any) => { - let name = attr.name; - let classificationAttr: IClassificationAttr = { - id: attr.id, - key: `${parent}[${option.name}]-${name}`, - classificationId: classification.id, - parent, - parentAttr, - parentValue: option.name, - type: attr.type, - name, - label: name, - value: attr.type === AttrType.MULTI_SELECTION ? [] : '', - required: attr.required, - options: attr.options.map((e: any) => { - return { value: e.name, label: e.name }; - }), - }; - classification.attrs.push(classificationAttr); - (attr.options || []).forEach((option: any) => { - traverseOption(classification, option, classificationAttr.id, name); - }); - }); - } -} - -export function copyClassification( - baseClassifications: IClassification[], - valueMap: Record, -) { - let classifications = [] as IClassification[]; - baseClassifications.forEach((classification) => { - let copyClassification = {} as IClassification; - copyClassification = JSON.parse(JSON.stringify(classification)); - - copyClassification.attrs.forEach((attr) => { - attr.value = attr.type === AttrType.MULTI_SELECTION ? [] : ''; - if (valueMap[attr.id]) { - // 处理成数组 - if (attr.type === AttrType.MULTI_SELECTION && !Array.isArray(valueMap[attr.id])) { - valueMap[attr.id] = [valueMap[attr.id]]; - } - attr.value = valueMap[attr.id]; - } - }); - classifications.push(copyClassification); - }); - return classifications; -} - -export function parseClassesFromBackend(data: any[]) { - let classTypes = [] as IClassType[]; - - // console.log(data); - data.forEach((config: any) => { - let classType: IClassType = { - id: config.id + '', - name: config.name || '', - // label: config.name + '-label', - label: config.name || '', - color: config.color || '#ff0000', - attrs: [], - toolType: config.toolType, - }; - - let attributes = config.attributes || []; - // 图片工具这边暂时没有 toolOptions | isStandard | isConstraints - // let toolOption = config.toolTypeOptions || {}; - // if (toolOption.isStandard) { - // classType.type = 'standard'; - // classType.size3D = new THREE.Vector3( - // toolOption.length || 0, - // toolOption.width || 0, - // toolOption.height || 0, - // ); - // } else if (toolOption.isConstraints) { - // let length, width, height; - // length = toolOption.length || []; - // width = toolOption.width || []; - // height = toolOption.height || []; - // classType.type = 'constraint'; - // classType.sizeMin = new THREE.Vector3(length[0] || 0, width[0] || 0, height[0] || 0); - // classType.sizeMax = new THREE.Vector3( - // length[1] || Infinity, - // width[1] || Infinity, - // height[1] || Infinity, - // ); - // } - - // if (toolOption.points) { - // classType.points = [toolOption.points, 0]; - // } - - attributes.forEach((config: any) => { - let options = (config.options || []).map((e: any) => { - // return { value: e.name, label: e.name + '-label' }; - return { value: e.name, label: e.name }; - }); - classType.attrs.push({ - id: config.id || config.name, - name: config.name, - // label: config.name + '-label', - label: config.name, - required: config.required, - type: config.type, - options: options, - } as any); - }); - - classTypes.push(classType); - }); - return classTypes; -} - -export function saveToClassificationValue(data: any[]) { - let values = {} as Record; - data.forEach((v) => { - // 忽略老数据 - if (Array.isArray(v)) return; - values[v.id] = v.value; - }); - return values; -} - -export function classificationToSave(classification: IClassification) { - let attrMap = {} as Record; - classification.attrs.forEach((attr) => { - attrMap[attr.id] = attr; - }); - let attrs = classification.attrs.filter((e) => isAttrVisible(e, attrMap) && isAttrHasValue(e)); - - // find leaf - attrs.forEach((e) => (e.leafFlag = true)); - attrs.forEach((e) => { - let parent = e.parent && attrMap[e.parent] ? attrMap[e.parent] : null; - if (parent) parent.leafFlag = false; - }); - let data = attrs.map((e) => { - const isParentMulti = e.parent && attrMap[e.parent]?.type === AttrType.MULTI_SELECTION; - return { - id: e.id, - pid: e.parent ? e.parent : null, - name: e.name, - value: e.value, - alias: e.label, - pvalue: isParentMulti ? e.parentValue : undefined, - type: e.type, - isLeaf: !!e.leafFlag, - }; - }); - return data; -} - -export function pathToClassificationValue(paths: string[][]) { - let values = {} as Record; - paths.forEach((path) => { - let id = ''; - path.forEach((p) => { - let index = p.indexOf(':'); - if (index < 0) return; - let k = p.substring(0, index) || ''; - let v = p.substring(index + 1) || ''; - id = id ? `${id}-${k}` : k; - - if (!values[id]) { - values[id] = v; - } else { - if (Array.isArray(values[id])) { - if (values[id].indexOf(v) < 0) values[id].push(v); - } else { - if (values[id] !== v) { - values[id] = [values[id], v]; - } - } - } - - id = `${id}[${v}]`; - }); - }); - // console.log(values); - return values; -} -// TODO 多选项,先勾选下面一个属性值再取消,无法存储多选项 -export function classificationToPath(classification: IClassification) { - let attrMap = {} as Record; - classification.attrs.forEach((attr) => { - attrMap[attr.id] = attr; - }); - let attrs = classification.attrs.filter((e) => isAttrVisible(e, attrMap) && isAttrHasValue(e)); - let attrIds = attrs.map((e) => e.id); - - let removeIdMap = {}; - attrIds.forEach((id) => { - for (let i = 0; i < attrIds.length; i++) { - let id1 = attrIds[i]; - if (id === id1) continue; - if (id1.startsWith(id)) { - removeIdMap[id] = true; - break; - } - } - }); - attrIds = attrIds.filter((e) => !removeIdMap[e]); - - let paths = [] as any[]; - attrIds.forEach((id) => { - // let path = []; - let attr = attrMap[id]; - if (attr.type === AttrType.MULTI_SELECTION) { - attr.value.forEach((v: any) => { - paths.push(createPath(attr, v)); - }); - } else { - paths.push(createPath(attr, attr.value)); - } - }); - - // console.log(attrIds); - // console.log(paths); - return paths; - - function createPath(attr: IClassificationAttr, value: any) { - let path = [`${attr.name}:${value}`]; - let parentAttr = attr; - while (parentAttr && parentAttr.parentValue && parentAttr.parentAttr) { - path.unshift(`${parentAttr.parentAttr}:${parentAttr.parentValue}`); - parentAttr = attrMap[parentAttr.parent]; - } - - return path; - } -} - -export function isAttrHasValue(attr: IClassificationAttr) { - if (attr.type === AttrType.MULTI_SELECTION) { - return Array.isArray(attr.value) && attr.value.length > 0; - } else { - return !!attr.value; - } -} - -export function isAttrVisible( - attr: IClassificationAttr, - attrMap: Record, -): boolean { - if (!attr.parent) return true; - let parentAttr = attrMap[attr.parent]; - let visible = - parentAttr.type !== AttrType.MULTI_SELECTION - ? parentAttr.value === attr.parentValue - : (parentAttr.value as any[])?.indexOf(attr.parentValue) >= 0; - - return visible && isAttrVisible(parentAttr, attrMap); -} diff --git a/frontend/image-tool/src/business/chengdu/utils/common.ts b/frontend/image-tool/src/business/chengdu/utils/common.ts deleted file mode 100644 index 2f8fe6c9..00000000 --- a/frontend/image-tool/src/business/chengdu/utils/common.ts +++ /dev/null @@ -1,25 +0,0 @@ -import UAParser from 'ua-parser-js'; - -export function rand(start: number, end: number) { - return (Math.random() * (end - start) + start) | 0; -} - -export function empty(value: any) { - return value === null || value === undefined || value === ''; -} -export function enableEscOnFullScreen() { - // @ts-ignore - if (navigator.keyboard && navigator.keyboard.lock) { - // @ts-ignore - navigator.keyboard.lock(['Escape']); - } -} - -// Is it a mac system -export function isMac() { - const parser = new UAParser(); - const osInfo = parser.getResult(); - const osName = (osInfo.os.name || '').toLowerCase(); - const isMac = osName.indexOf('mac') >= 0; - return isMac; -} diff --git a/frontend/image-tool/src/business/chengdu/utils/confirm.css b/frontend/image-tool/src/business/chengdu/utils/confirm.css deleted file mode 100644 index a25d0024..00000000 --- a/frontend/image-tool/src/business/chengdu/utils/confirm.css +++ /dev/null @@ -1,8 +0,0 @@ -.ModalConfirmCustom .ant-modal-content { - background: #393c45; - box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.15); - border-radius: 14px; -} -.ModalConfirmCustom .ant-modal-content .ant-btn-primary { - background: #60a9fe; -} diff --git a/frontend/image-tool/src/business/chengdu/utils/confirm.less b/frontend/image-tool/src/business/chengdu/utils/confirm.less deleted file mode 100644 index 8c864c2a..00000000 --- a/frontend/image-tool/src/business/chengdu/utils/confirm.less +++ /dev/null @@ -1,10 +0,0 @@ -.ModalConfirmCustom { - .ant-modal-content { - background: #393c45; - box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.15); - border-radius: 14px; - .ant-btn-primary { - background: #60a9fe; - } - } -} diff --git a/frontend/image-tool/src/business/chengdu/utils/confirm.ts b/frontend/image-tool/src/business/chengdu/utils/confirm.ts deleted file mode 100644 index 2e46511c..00000000 --- a/frontend/image-tool/src/business/chengdu/utils/confirm.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { createVNode } from 'vue'; -import { Modal } from 'ant-design-vue'; -import { ExclamationCircleFilled } from '@ant-design/icons-vue'; -import './confirm.less'; - -export const ModalConfirmCustom = (options: any) => { - const { title, content, okText, okButtonProps, cancelText, cancelButtonProps, onOk, onCancel } = - options; - - Modal.confirm({ - title: title ?? '', - icon: () => - createVNode(ExclamationCircleFilled, { - style: { - color: '#F8E792', - transform: 'rotate(180deg)', - }, - }), - centered: true, - content: content ?? '', - okText: okText ?? 'OK', - okButtonProps: okButtonProps ?? { - danger: true, - }, - cancelText: cancelText ?? 'Cancel', - cancelButtonProps: cancelButtonProps ?? { - type: 'default', - }, - onOk: async () => { - if (onOk) { - onOk(); - } - }, - onCancel: () => { - if (onCancel) { - onCancel(); - } - }, - class: 'ModalConfirmCustom', - }); -}; diff --git a/frontend/image-tool/src/business/chengdu/utils/error.ts b/frontend/image-tool/src/business/chengdu/utils/error.ts deleted file mode 100644 index a66093ae..00000000 --- a/frontend/image-tool/src/business/chengdu/utils/error.ts +++ /dev/null @@ -1,15 +0,0 @@ -import Tool from '../common/Tool'; -import BSError from '../common/BSError'; - -export function handleError(tool: Tool, err: BSError | Error) { - let { editor } = tool; - - if ((err as any).oriError) console.log('oriError', (err as any).oriError); - editor.showMsg('error', err.message); - - // if(err instanceof BSError){ - // editor.showMsg('error',err.message) - // }else{ - // editor.showMsg('error',err) - // } -} diff --git a/frontend/image-tool/src/business/chengdu/utils/index.ts b/frontend/image-tool/src/business/chengdu/utils/index.ts deleted file mode 100644 index 2bc51ab6..00000000 --- a/frontend/image-tool/src/business/chengdu/utils/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './common'; -export * from './classification'; -export * from './error'; -export * from './result'; -export * from './confirm'; -export * from './classType'; diff --git a/frontend/image-tool/src/business/chengdu/utils/result.ts b/frontend/image-tool/src/business/chengdu/utils/result.ts deleted file mode 100644 index ce40c5d6..00000000 --- a/frontend/image-tool/src/business/chengdu/utils/result.ts +++ /dev/null @@ -1,252 +0,0 @@ -import { IUserData, Editor, IClassType, IAttr, AnnotateType2ToolType } from 'editor/index'; -// @ts-ignore -import uuid from 'uuid/v4'; -import { empty } from './common'; -import { copyClassAttrs, isClassAttrHasValue, isClassAttrVisible } from './classType'; -import { AttrType, IObjectV2, SourceType } from '../type'; -type IObject = any; -type IAnnotateObject = any; - -// TODO 获取数据的转换 -export function convertObject2Annotate(objects: IObject[], editor: Editor) { - const annotates = [] as IAnnotateObject[]; - - const classMap = {} as Record; - editor.state.classTypes.forEach((e) => { - classMap[e.name] = e; - }); - - // 用 classIdMap 来映射,防止 name 重复 - const classIdMap = {}; - editor.state.classTypes.forEach((e) => { - classIdMap[e.id] = e; - }); - - objects.forEach((e: IObject) => { - const obj = e.classAttributes; - // console.log(obj); - - // 用 classId 查找唯一,直接使用 classType 可能会有重复 - let targetClassType: any = classIdMap[obj.classId]; - // console.log(targetClassType); - - const annotate: any = { - id: e.id, - color: targetClassType?.color ?? '#dedede', - coordinate: obj?.contour?.points ?? [], - interior: obj?.contour?.interior || [], - type: obj?.type?.toLocaleLowerCase(), - version: obj?.version, - userData: { - ...obj?.meta, - sourceId: e.sourceId || obj.sourceId || editor.state.withoutTaskId, - sourceType: e.sourceType || obj.sourceType || SourceType.DATA_FLOW, - attrs: arrayToObj(obj?.classValues), - modelClass: obj.modelClass, - confidence: obj.modelConfidence, - createdAt: obj.createdAt, - createdBy: obj.createdBy, - version: obj.version, - }, - intId: Number(obj.trackName), - uuid: obj.id || uuid(), - }; - - if (annotate.type == 'rectangle') { - const defaultPoint = { x: 0, y: 0 }; - const [p0 = defaultPoint, p1 = defaultPoint] = obj.contour?.points || obj.points || []; - annotate.coordinate = [p0, { x: p1.x, y: p0.y }, p1, { x: p0.x, y: p1.y }]; - } - annotates.push(annotate); - }); - // debugger; - - return annotates; -} - -// TODO 保存数据的转换 -export function convertAnnotate2Object(annotates: IAnnotateObject[], editor: Editor) { - const objects = [] as IObject[]; - - const classMap = {}; - editor.state.classTypes.forEach((e) => { - classMap[e.name] = e; - }); - // console.log('===>', classMap); - - // 用 classIdMap 来映射,防止 name 重复 - const classIdMap = {}; - editor.state.classTypes.forEach((e) => { - classIdMap[e.id] = e; - }); - // console.log('===>', classIdMap); - - annotates.forEach((obj: any) => { - const userData = { - ...obj.userData, - toolType: AnnotateType2ToolType[obj.type], - } as any; - - // 用 name + toolType 查找唯一,防止 name 重复 - let targetClassType: any; - Object.keys(classIdMap).forEach((item: any) => { - const tempObj = classIdMap?.[item]; - if (tempObj?.name == userData.classType && tempObj?.toolType == userData.toolType) { - targetClassType = tempObj; - } - }); - // console.log('>>>', userData); - // console.log(targetClassType); - - // updateVersion - let version = obj.userData.version || 0; - if (obj.userData.updateTime > obj.userData.lastTime) { - version++; - } - obj.userData.lastTime = obj.userData.updateTime; - obj.userData.version = version; - - // debugger; - const newInfo: any = { - backId: obj.id, - id: obj.uuid, - type: obj?.type?.toLocaleUpperCase(), - version: userData.version, - createdAt: userData.createdAt, - createdBy: userData.createdBy, - trackId: obj.intId, - sourceId: userData.sourceId || editor.state.withoutTaskId, - sourceType: userData.sourceType || SourceType.DATA_FLOW, - trackName: obj.intId, - classId: userData.classType ? targetClassType?.id : '', - classValues: objToArray(userData.attrs || [], targetClassType ?? {}), - modelConfidence: userData.confidence || undefined, - modelClass: userData.modelClass || undefined, - contour: { - points: obj.coordinate, - interior: obj.interior ?? undefined, - }, - meta: { - color: targetClassType?.color || obj.color, - classType: userData.classType, - sourceId: userData.sourceId, - sourceType: userData.sourceType, - version: userData.version, - lastTime: userData.lastTime, - updateTime: userData.updateTime, - }, - }; - if (obj.type == 'rectangle') { - newInfo.contour.points = [obj.coordinate[0], obj.coordinate[2]]; - } - objects.push(newInfo); - }); - return objects; -} - -export function convertModelRunResult(objects: any[]) { - const newObjects = objects.map((item) => { - return { - classAttributes: { - meta: {}, - contour: { - points: item.points, - }, - type: item.objType || item.type, - modelClass: item.modelClass, - modelConfidence: item.confidence, - }, - }; - }); - return newObjects; -} - -function objToArray(obj: Record = {}, baseClassType?: IClassType) { - // const attrMap = {} as Record; - const attrMap = {} as Record; - const attrs = baseClassType?.attrs || []; - - attrs.forEach((attr: any) => { - attrMap[attr.id] = attr; - }); - // console.log('attrMap', attrMap); - - const data = [] as any[]; - // console.log(obj); - - Object.keys(obj).forEach((key) => { - // console.log(key); - - let value = obj[key]; - if (empty(value)) return; - data.push({ - id: attrMap[key]?.id, - pid: null, - name: attrMap[key]?.name || '', - value: value, - alias: attrMap[key]?.label || '', - isLeaf: true, - }); - }); - return data; -} - -function arrayToObj(data: any[] = []) { - let values = {} as Record; - if (!Array.isArray(data)) return values; - - data.forEach((e) => { - // 忽略老数据 - if (Array.isArray(e)) return; - values[e.id] = e.value; - }); - return values; -} - -// 先处理第一层级的属性, TODO:多层属性 -export function classAttrToPath(obj: Record = {}) { - let paths = [] as any[]; - Object.keys(obj).forEach((key) => { - let value = obj[key]; - if (empty(value)) return; - if (Array.isArray(value)) { - value.forEach((e) => { - paths.push([`${key}:${e}`]); - }); - } else { - paths.push([`${key}:${value}`]); - } - }); - return paths; -} - -export function pathToClassAttr(paths: string[][]) { - let values = {} as Record; - // 兼容处理以前的键值对 - if (!paths.length) paths = []; - paths.forEach((path) => { - let id = ''; - path.forEach((p) => { - let index = p.indexOf(':'); - if (index < 0) return; - let k = p.substring(0, index) || ''; - let v = p.substring(index + 1) || ''; - id = id ? `${id}-${k}` : k; - - if (!values[id]) { - values[id] = v; - } else { - if (Array.isArray(values[id])) { - if (values[id].indexOf(v) < 0) values[id].push(v); - } else { - if (values[id] !== v) { - values[id] = [values[id], v]; - } - } - } - - id = `${id}[${v}]`; - }); - }); - return values; -} diff --git a/frontend/image-tool/src/businessNew/api/data.ts b/frontend/image-tool/src/businessNew/api/data.ts index 3cd65d33..70c6638e 100644 --- a/frontend/image-tool/src/businessNew/api/data.ts +++ b/frontend/image-tool/src/businessNew/api/data.ts @@ -1,3 +1,4 @@ +import { IFrame } from '@/package/image-editor'; import { ISaveFormat, ISaveResp } from '../types'; import { get, post } from './base'; import { Api, DataflowAnnotationParamsReq, DataflowAnnotationParamsRsp, IFileConfig } from './type'; @@ -42,3 +43,30 @@ export async function saveData(datasetId: string, dataInfos: Array) let data = await post(url, { datasetId, dataInfos }); return (data.data || []) as ISaveResp[]; } + +export async function getFrameSeriesData(datasetId: string, frameSeriesId: string) { + const url = `/api/data/getDataIdBySceneIds`; + const data = await get(url, { + datasetId, + sceneIds: frameSeriesId, + // sortFiled: 'ID', + // ascOrDesc: 'ASC', + }); + console.log(data); + const list = (data.data || {})[frameSeriesId] || []; + // (list as any[]).reverse(); + if (list.length === 0) throw ''; + + const dataList = [] as IFrame[]; + list.forEach((e: any) => { + dataList.push({ + id: e, + datasetId: datasetId, + needSave: false, + model: undefined, + sceneId: frameSeriesId, + } as IFrame); + }); + return dataList; + // return configs; +} diff --git a/frontend/image-tool/src/businessNew/components/Layout/index.vue b/frontend/image-tool/src/businessNew/components/Layout/index.vue index 1b189c81..812abad7 100644 --- a/frontend/image-tool/src/businessNew/components/Layout/index.vue +++ b/frontend/image-tool/src/businessNew/components/Layout/index.vue @@ -37,6 +37,7 @@ width: 50px; } .operation-wrap { + position: relative; width: 300px; padding: 4px; } diff --git a/frontend/image-tool/src/businessNew/components/Modal/HotkeyHelp/index.ts b/frontend/image-tool/src/businessNew/components/Modal/HotkeyHelp/index.ts index 4882df16..2d80cd8f 100644 --- a/frontend/image-tool/src/businessNew/components/Modal/HotkeyHelp/index.ts +++ b/frontend/image-tool/src/businessNew/components/Modal/HotkeyHelp/index.ts @@ -110,12 +110,12 @@ export const resultConfig: IKeyboardConfig[] = [ keys: ['B'], tags: Tags_Instance, }, - { - label: 'Show annotation sequence', - tips: '', - keys: ['D'], - tags: Tags_Instance, - }, + // { + // label: 'Show annotation sequence', + // tips: '', + // keys: ['D'], + // tags: Tags_Instance, + // }, ]; export const imageConfig: IKeyboardConfig[] = [ { diff --git a/frontend/image-tool/src/businessNew/components/Operation/Results/components/Item.vue b/frontend/image-tool/src/businessNew/components/Operation/Results/components/Item.vue index c437e0a7..f8d31618 100644 --- a/frontend/image-tool/src/businessNew/components/Operation/Results/components/Item.vue +++ b/frontend/image-tool/src/businessNew/components/Operation/Results/components/Item.vue @@ -42,7 +42,7 @@
-
{{ data.attrLabel }}
+
{{ data.sizeLabel }}
@@ -61,6 +61,7 @@ import { IAction, IObjectItem } from '../type'; import { useInjectEditor } from 'image-ui/context'; import { useResultsInject } from '../context'; + import { VNode, createVNode } from 'vue'; // ***************Props and Emits*************** const emit = defineEmits(['tool', 'group-tool']); @@ -69,6 +70,9 @@ select: Record; editable: boolean; }>(); + type IProp = { + attrs: any; + }; // ********************************************* const editor = useInjectEditor(); @@ -83,6 +87,58 @@ const invalid = (obj?.userData.limitState || '') !== ''; return invalid; } + + function AttrLabel(prop: IProp) { + const { attrs = '' } = prop; + const attrStrArr: (String | VNode)[] = []; + if (typeof attrs === 'string') { + attrStrArr.push(attrs); + } else { + const _attrs = Object.keys(attrs); + const attrMap = editor.attrMap; + _attrs.forEach((attrId, index) => { + const attr = attrMap.get(attrId); + const value = attrs ? attrs[attrId] : {}; + let valueStr = String(value.value || ''); + // if (attr.latexExpression) { + // attrStrArr.push( + // createVNode('span', { + // style: 'display: inline-block', + // innerHTML: editor.utils.toMMl(valueStr), + // }), + // ); + // if (index < _attrs.length - 1) { + // attrStrArr.push(' | '); + // } + // return; + // } else + if (attr && attr.options && valueStr) { + const valArr = valueStr.split(','); + valArr.forEach((str: string, index: number) => { + const obj = attr.options.find((e: any) => e.name === str); + if (obj) valArr[index] = editor.showNameOrAlias(obj); + }); + valueStr = String(valArr); + } + attrStrArr.push(valueStr); + if (index < _attrs.length - 1) { + attrStrArr.push(' | '); + } + }); + } + return createVNode( + 'div', + { + style: { + display: attrStrArr.length <= 0 ? 'none' : '', + 'word-wrap': 'break-word', + width: '100%', + }, + class: 'props', + }, + attrStrArr, + ); + } diff --git a/frontend/image-tool/src/editor/components/Modal/Message.ts b/frontend/image-tool/src/editor/components/Modal/Message.ts deleted file mode 100644 index c2caf1c5..00000000 --- a/frontend/image-tool/src/editor/components/Modal/Message.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Editor, MsgType } from 'editor'; -import { message } from 'ant-design-vue'; - -message.config({ - maxCount: 1, - duration: 2, -}); - -export default function injectMessage(editor: Editor) { - editor.showMsg = (type: MsgType, msg: string) => { - message[type](msg); - }; -} diff --git a/frontend/image-tool/src/editor/components/Modal/Warning.ts b/frontend/image-tool/src/editor/components/Modal/Warning.ts deleted file mode 100644 index e91b172d..00000000 --- a/frontend/image-tool/src/editor/components/Modal/Warning.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Editor, IConfirmOption, StatusType } from 'editor'; -import { Modal } from 'ant-design-vue'; -import { createVNode } from 'vue'; - -export default function injectWarning(editor: Editor) { - editor.showWarning = (config = {} as IConfirmOption) => { - let { title = '', subTitle = '' } = config; - editor.state.status = StatusType.Confirm; - return new Promise((resolve, reject) => { - Modal.warning({ - title: () => title, - closable: true, - content: () => - createVNode( - 'div', - { style: 'font-size:12px;color: rgb(161 161 161);' }, - subTitle, - ), - onOk() { - editor.state.status = StatusType.Default; - resolve(); - }, - onCancel() { - editor.state.status = StatusType.Default; - reject(); - }, - }); - }); - }; -} diff --git a/frontend/image-tool/src/editor/components/Modal/index.vue b/frontend/image-tool/src/editor/components/Modal/index.vue deleted file mode 100644 index bd856b5d..00000000 --- a/frontend/image-tool/src/editor/components/Modal/index.vue +++ /dev/null @@ -1,143 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/editor/components/Modal/sub/Annotation.vue b/frontend/image-tool/src/editor/components/Modal/sub/Annotation.vue deleted file mode 100644 index 85eb2d0c..00000000 --- a/frontend/image-tool/src/editor/components/Modal/sub/Annotation.vue +++ /dev/null @@ -1,109 +0,0 @@ - - - - - diff --git a/frontend/image-tool/src/editor/config/event.ts b/frontend/image-tool/src/editor/config/event.ts deleted file mode 100644 index 4277d5e0..00000000 --- a/frontend/image-tool/src/editor/config/event.ts +++ /dev/null @@ -1,26 +0,0 @@ -export const Event = { - SELECT: 'select', - ADD_OBJECT: 'add_object', - REMOVE_OBJECT: 'remove_object', - VISIBLE_CHANGE: 'visible_change', - USER_DATA_CHANGE: 'user_data_change', - DIMENSION_CHANGE: 'dimension_change', - DIMENSION_CHANGE_BEFORE: 'dimension_change_before', - DIMENSION_CHANGE_AFTER: 'dimension_change_after', - CONTAINER_TRANSFORM: 'container_transform', - CLEAR_DATA: 'clear_data', - SHOW_CLASS_INFO: 'show_class_info', - CLICK_LABEL: 'click_label', - LOAD_OBJECTS: 'load_objects', - IMAGE_LOADED: 'image_loaded', - ZOOM_CHANGE: 'zoom_change', - UNDO: 'undo', - REDO: 'redo', - RESET: 'reset', - EXECUTE: 'execute', - FILTER_CHANGE: 'filter_change', - FILTER_TOGGLE: 'filter_toggle', - IMAGE_CHANGE: 'image_change', - RESET_SELECT: 'reset_select', -}; -export default Event; diff --git a/frontend/image-tool/src/editor/config/hotkey.ts b/frontend/image-tool/src/editor/config/hotkey.ts deleted file mode 100644 index 8d173744..00000000 --- a/frontend/image-tool/src/editor/config/hotkey.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { IHotkeyConfig } from '../type'; -import { UITypeEnum } from '../../enum/UITypeEnum'; -import UAParser from 'ua-parser-js'; - -const parser = new UAParser(); -const osInfo = parser.getResult(); -const osName = (osInfo.os.name || '').toLowerCase(); -const isMac = osName.indexOf('mac') >= 0; -console.log('isMac:', isMac); - -const macConfig: IHotkeyConfig[] = [ - { key: 'Backspace', action: 'onDelete' }, - { key: '⌘ + s', action: 'onSave' }, - { key: '⌘ + z', action: 'undo' }, - { key: '⌘ + Shift + z', action: 'redo' }, - { key: '⌘ + up', action: 'translate', args: { direction: 'up', distance: 1 } }, - { key: '⌘ + down', action: 'translate', args: { direction: 'down', distance: 1 } }, - { key: '⌘ + left', action: 'translate', args: { direction: 'left', distance: 1 } }, - { key: '⌘ + right', action: 'translate', args: { direction: 'right', distance: 1 } }, - { key: '⌘ + Shift + up', action: 'translate', args: { direction: 'up', distance: 10 } }, - { key: '⌘ + Shift + down', action: 'translate', args: { direction: 'down', distance: 10 } }, - { key: '⌘ + Shift + left', action: 'translate', args: { direction: 'left', distance: 10 } }, - { key: '⌘ + Shift + right', action: 'translate', args: { direction: 'right', distance: 10 } }, - { key: '⌘ + x', action: 'clipPolygon', args: { firstisClip: true } }, - { key: '⌘ + Shift + x', action: 'cancelClip' }, -]; -const windowsConfig: IHotkeyConfig[] = [ - { key: 'Delete', action: 'onDelete' }, - { key: 'Ctrl + s', action: 'onSave' }, - { key: 'Ctrl + z', action: 'undo' }, - { key: 'Ctrl + Shift + z', action: 'redo' }, - { key: 'Ctrl + up', action: 'translate', args: { direction: 'up', distance: 1 } }, - { key: 'Ctrl + down', action: 'translate', args: { direction: 'down', distance: 1 } }, - { key: 'Ctrl + left', action: 'translate', args: { direction: 'left', distance: 1 } }, - { key: 'Ctrl + right', action: 'translate', args: { direction: 'right', distance: 1 } }, - { key: 'Ctrl + Shift + up', action: 'translate', args: { direction: 'up', distance: 10 } }, - { key: 'Ctrl + Shift + down', action: 'translate', args: { direction: 'down', distance: 10 } }, - { key: 'Ctrl + Shift + left', action: 'translate', args: { direction: 'left', distance: 10 } }, - { - key: 'Ctrl + Shift + right', - action: 'translate', - args: { direction: 'right', distance: 10 }, - }, - { key: 'Ctrl + x', action: 'clipPolygon', args: { firstisClip: true } }, - { key: 'Ctrl + Shift + x', action: 'cancelClip' }, -]; -const commonConfig: IHotkeyConfig[] = [ - // { key: 'Esc', action: 'KeyEscDown' }, - // { key: 'Enter', action: 'KeyEnterDown' }, - { key: 't', action: 'toggleClassView' }, - { key: 'x', action: 'clipPolygon', args: { firstisClip: false } }, - { key: 'PageUp', action: 'pageUp' }, - { key: 'PageDown', action: 'pageDown' }, - { key: '1', action: 'selectTool', args: UITypeEnum.annotation }, - { key: '2', action: 'selectTool', args: UITypeEnum.edit }, - { key: '3', action: 'selectTool', args: UITypeEnum.rectangle }, - { key: '4', action: 'selectTool', args: UITypeEnum.polygon }, - { key: '5', action: 'selectTool', args: UITypeEnum.polyline }, - { key: '6', action: 'selectTool', args: UITypeEnum.segmentation }, - { key: '7', action: 'selectTool', args: UITypeEnum.model }, - { key: '8', action: 'selectTool', args: UITypeEnum.interactive }, -]; -const hotkeyConfig: IHotkeyConfig[] = isMac - ? commonConfig.concat(macConfig) - : commonConfig.concat(windowsConfig); - -export const drawingConfig: IHotkeyConfig[] = [ - { key: 'Space', action: 'KeySpaceDown', upAction: 'KeySpaceUp' }, - { key: 'Esc', action: 'KeyEscDown' }, - { key: 'Enter', action: 'KeyEnterDown' }, - isMac ? { key: '⌘ + z', action: 'KeyBackDown' } : { key: 'Ctrl + z', action: 'KeyBackDown' }, - isMac - ? { key: '⌘ + Shift + z', action: 'KeyForwardDown' } - : { key: 'Ctrl + Shift + z', action: 'KeyForwardDown' }, - // isMac ? { key: 'Backspace', action: 'onDelete' } : { key: 'Delete', action: 'onDelete' }, -]; -export default hotkeyConfig; diff --git a/frontend/image-tool/src/editor/config/keyboard.ts b/frontend/image-tool/src/editor/config/keyboard.ts deleted file mode 100644 index 6f20359e..00000000 --- a/frontend/image-tool/src/editor/config/keyboard.ts +++ /dev/null @@ -1,200 +0,0 @@ -export const dataConfig = [ - { - textValue: 'Previous', - textHelp: '', - actionValue: ['Page Up'], - wrap: false, - }, - { - textValue: 'Next', - textHelp: '', - actionValue: ['Page Down'], - wrap: false, - }, -]; - -export const instanceConfig = [ - { - textValue: 'Save', - textHelp: '', - actionValue: ['Ctrl/⌘', 'S'], - wrap: false, - }, - { - textValue: 'Cancel', - textHelp: '', - actionValue: ['Esc'], - wrap: false, - }, - { - textValue: 'Delete instance/ point', - textHelp: '', - actionValue: ['Delete'], - wrap: false, - }, - { - textValue: 'Finish drawing', - textHelp: '', - actionValue: ['Enter'], - wrap: false, - }, - { - textValue: 'Show/hide tag pad', - textHelp: '', - actionValue: ['T'], - wrap: false, - }, - { - textValue: 'Move upper side out by 1px', - textHelp: '', - actionValue: ['Ctrl/⌘', '↑'], - wrap: true, - }, - { - textValue: 'Move bottom side out by 1px', - textHelp: '', - actionValue: ['Ctrl/⌘', '↓'], - wrap: true, - }, - { - textValue: 'Move left side out by 1px', - textHelp: '', - actionValue: ['Ctrl/⌘', '←'], - wrap: true, - }, - { - textValue: 'Move right side out by 1px', - textHelp: '', - actionValue: ['Ctrl/⌘', '→'], - wrap: true, - }, - { - textValue: 'Move upper side out by 10px', - textHelp: '', - actionValue: ['Ctrl/⌘', 'Shift', '↑'], - wrap: true, - }, - { - textValue: 'Move bottom side out by 10px', - textHelp: '', - actionValue: ['Ctrl/⌘', 'Shift', '↓'], - wrap: true, - }, - { - textValue: 'Move left side out by 10px', - textHelp: '', - actionValue: ['Ctrl/⌘', 'Shift', '←'], - wrap: true, - }, - { - textValue: 'Move right side out by 10px', - textHelp: '', - actionValue: ['Ctrl/⌘', 'Shift', '→'], - wrap: true, - }, - { - textValue: 'Undo', - textHelp: '', - actionValue: ['Ctrl/⌘', 'Z'], - wrap: false, - }, - { - textValue: 'Redo', - textHelp: '', - actionValue: ['Ctrl/⌘', 'Shift', 'Z'], - wrap: false, - }, - { - textValue: 'Crop1 ', - textHelp: 'Do not crop the first one', - actionValue: ['X'], - wrap: false, - }, - { - textValue: 'Crop2', - textHelp: 'Crop the first one', - actionValue: ['Ctrl', 'X'], - wrap: false, - }, - // { - // textValue: 'Cancel crop', - // textHelp: '', - // actionValue: ['Ctrl/⌘', 'Shift', 'X'], - // wrap: true, - // }, -]; - -export const toolConfig = [ - // { - // textValue: 'Annotation Tool', - // textHelp: '', - // actionValue: '1', - // wrap: false - // }, - { - textValue: 'Selection Tool', - textHelp: '', - actionValue: ['2'], - wrap: false, - }, - { - textValue: 'Rectangle Tool', - textHelp: '', - actionValue: ['3'], - wrap: false, - }, - { - textValue: 'Polygon Tool', - textHelp: '', - actionValue: ['4'], - wrap: false, - }, - { - textValue: 'Polyline Tool', - textHelp: '', - actionValue: ['5'], - wrap: false, - }, - // { - // textValue: 'Segmentation Tool', - // textHelp: '', - // actionValue: ['6'], - // wrap: false - // }, - { - textValue: 'Smart Tool', - textHelp: '', - actionValue: ['7'], - wrap: false, - }, - { - textValue: 'Interactive Tool', - textHelp: '', - actionValue: ['8'], - wrap: false, - }, -]; - -export const imageConfig = [ - { - textValue: 'Zoom in、Zoom Out', - textHelp: '', - actionValue: ['wheel'], - wrap: false, - }, - { - textValue: 'Drag', - textHelp: '', - actionValue: ['Space', 'leftClick'], - wrap: false, - }, -]; - -export const elseConfig = [ - { - textValue: 'Cancel window', - textHelp: '', - actionValue: ['Esc'], - wrap: false, - }, -]; diff --git a/frontend/image-tool/src/editor/config/mode.ts b/frontend/image-tool/src/editor/config/mode.ts deleted file mode 100644 index 0ca8b163..00000000 --- a/frontend/image-tool/src/editor/config/mode.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { IModeConfig, OPType } from './type'; -import type { IActionName } from '../ActionManager/type'; -import { AllActions } from '../ActionManager'; -import * as _ from 'lodash'; - -function toMap(arr: T[]) { - let map = {} as Record; - arr.forEach((e) => (map[e] = true)); - return map; -} - -export const UIType = { - // ****** left tool********** - edit: 'edit', - rectangle: 'rectangle', - polygon: 'polygon', - polyline: 'polyline', - model: 'model', - interactive: 'interactive', - setting: 'setting', - info: 'info', -}; - -export type IUIType = keyof typeof UIType; - -let allUI = Object.keys(UIType) as IUIType[]; - -// test mode -const all: IModeConfig = { - name: 'all', - op: OPType.EXECUTE, - ui: toMap(allUI), - actions: toMap(AllActions), -}; - -// test mode -const empty: IModeConfig = { - name: 'empty', - op: OPType.VIEW, - ui: toMap([] as IUIType[]), - actions: toMap([] as IActionName[]), -}; - -let modes = { - empty, - all, -}; - -export type IModeType = keyof typeof modes; - -export const ModeKeys = Object.keys(modes).filter((e) => e !== 'all') as IModeType[]; - -export default modes; diff --git a/frontend/image-tool/src/editor/config/type.ts b/frontend/image-tool/src/editor/config/type.ts deleted file mode 100644 index f4edb73c..00000000 --- a/frontend/image-tool/src/editor/config/type.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { IModeType, IUIType } from './mode'; - -export { IModeType, IUIType }; - -export enum OPType { - EXECUTE = 'execute', - VERIFY = 'verify', - VIEW = 'view', -} - -export interface IModeConfig { - name?: string; - op: OPType; - ui: Record; - actions: Record; -} - -export interface IBisectrixLineConf { - enable: boolean; - vertical: number; - horizontal: number; -} diff --git a/frontend/image-tool/src/editor/index.ts b/frontend/image-tool/src/editor/index.ts deleted file mode 100644 index ea3d8694..00000000 --- a/frontend/image-tool/src/editor/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Editor } from './Editor'; -import CmdManager from './CmdManager'; -import HotkeyManager from './HotkeyManager'; -import ActionManager from './ActionManager'; -import Event from './config/event'; - -import modes, { ModeKeys, UIType } from './config/mode'; -import { AllActions } from './ActionManager'; -import { define as defineAction } from './ActionManager/define'; - -export { - Editor, - CmdManager, - HotkeyManager, - ActionManager, - Event, - ModeKeys, - modes, - AllActions, - UIType, - defineAction, -}; -export * from './type'; diff --git a/frontend/image-tool/src/editor/inject.ts b/frontend/image-tool/src/editor/inject.ts deleted file mode 100644 index af40d37c..00000000 --- a/frontend/image-tool/src/editor/inject.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { provide, inject } from 'vue'; -import { IEditorState } from './state'; -import { Editor } from './index'; - -export const content = Symbol('editor'); - -export function useProvideEditor(editor: Editor) { - provide(content, editor); -} -export function useInjectEditor() { - return inject(content) as Editor; -} - -export const editorStatContent = Symbol('editor-state'); - -export function useProvideEditorState(editState: IEditorState) { - provide(editorStatContent, editState); -} -export function useInjectEditorState() { - return inject(editorStatContent) as IEditorState; -} - -export type IInjectBusiness = any; diff --git a/frontend/image-tool/src/editor/state.ts b/frontend/image-tool/src/editor/state.ts deleted file mode 100644 index 65aca910..00000000 --- a/frontend/image-tool/src/editor/state.ts +++ /dev/null @@ -1,139 +0,0 @@ -// import type { IActionName } from './ActionManager/type'; -// import type { IHotkeyConfig } from './HotkeyManager/type'; -import type { IModeConfig } from './config/type'; -// import * as THREE from 'three'; -import { IModeType } from './config/type'; -import Modes from './config/mode'; - -import { - StatusType, - IClassType, - IAnnotationInfo, - IUserInfo, - IAttr, - IAnnotationTag, - ValidStatus, - AnnotateStatus, -} from './type'; - -let i18n = { - info_title: '信息', - info_datainfo: '数据信息', - info_pointinfo: '点信息', - info_pointall: '真实', - info_pointvisible: '可见', - setting_display: '显示', - setting_imgview: '图片显示', - setting_rect: '矩形框', - setting_box: '立体框', - setting_projectbox: '映射立体框', - setting_projectpoint: '映射点', - setting_pointview: '点云显示', - setting_pointsize: '点大小', - setting_pointreset: '重置', - setting_resultview: '结果显示', - setting_showlabel: '显示标签(M)', - setting_showannotate: '显示批注(Shift+H)', - side_overhead: '俯视图', - side_side: '侧视图', - side_near: '后视图', - side_length: '长', - side_width: '宽', - side_height: '高', - imgMax_link: '关联结果', - mainInfo_result: '结果', - mainInfo_length: '长度', - mainInfo_width: '宽度', - mainInfo_height: '高度', - mainInfo_points: '点数', - mainInfo_position: '位置', - mainInfo_infinity: '正无穷', -}; - -export type I18N = typeof i18n; -export interface IClassEditStyle { - x: number; - y: number; - width: number; - height: number; -} -export interface IEditorState { - imageUrl: string; - withoutTaskId: string; - user: IUserInfo; - annotationTags: IAnnotationTag[]; - annotations: IAnnotationInfo[]; - mode: string; - modeConfig: IModeConfig; - status: StatusType; - activeItem: string; - // hotkeyConfig: IHotkeyConfig[]; - classTypes: IClassType[]; - workInfo: (IAttr & { value: any })[]; - // i18n: I18N; - showClassView: boolean; - classEditStyle: IClassEditStyle; - dataId: string; - dataName: string; - imageWidth: number; - imageHeight: number; - imageSize: number; - helpLineVisible: boolean; - showAttrs: boolean; - showSize: boolean; - showSizeTips: boolean; - allVisible: boolean; - showKeyboard: boolean; - showMask: boolean; - validStatus: ValidStatus; - annotationStatus: AnnotateStatus; - isAnnotated: boolean; - focusId?: number; -} - -const tags: IAnnotationTag[] = [ - { label: '漏标', value: 'result_empty', id: 'result_empty' }, - { label: '错标', value: 'result_error', id: 'result_error' }, - { label: '标签错误', value: 'lable_error', id: 'lable_error' }, - { label: '不贴合', value: 'not_fit', id: 'not_fit' }, - { label: '多标', value: 'more_error', id: 'more_error' }, - { label: '其他', value: 'other', id: 'other' }, -]; - -export function getDefaultState(): IEditorState { - const defaultState: IEditorState = { - imageUrl: '', - user: { - id: 'test-123123', - }, - withoutTaskId: '-1', - annotationTags: tags, - annotations: [], - mode: 'empty', - modeConfig: Modes.empty, - status: StatusType.Default, - activeItem: '', - // hotkeyConfig: [], - classTypes: [], - workInfo: [], - // i18n, - showClassView: false, - classEditStyle: { x: 0, y: 0, width: 0, height: 0 }, - dataId: '', - dataName: '', - imageWidth: 0, - imageHeight: 0, - imageSize: 0, - helpLineVisible: false, - showAttrs: false, - showSize: false, - showSizeTips: true, - allVisible: true, - showKeyboard: false, - showMask: false, - validStatus: ValidStatus.VALID, - annotationStatus: AnnotateStatus.NOT_ANNOTATED, - }; - - return defaultState; -} diff --git a/frontend/image-tool/src/editor/type.ts b/frontend/image-tool/src/editor/type.ts deleted file mode 100644 index c11467af..00000000 --- a/frontend/image-tool/src/editor/type.ts +++ /dev/null @@ -1,182 +0,0 @@ -import type { Vector3 } from 'three'; -// import { Vector2Of4, AnnotateType } from 'pc-render'; - -// export * from './CmdManager/type'; -export * from './ActionManager/type'; -export * from './HotkeyManager/type'; -export * from './config/type'; - -export type { IEditorState, I18N } from './state'; -export type { IModalOption, IConfirmOption, MsgType, ILoadingOption } from './Editor'; - -export interface IUserData { - id?: string; - trackId?: string; - refId?: string; - refType?: AnnotateType; - backId?: string; - isProjection?: boolean; - // model - confidence?: number; - modelClass?: string; - modelRun?: string; - project?: string; - classType?: string; - attrs?: Record; - // info - pointN?: number; - [key: string]: any; -} -export interface IUserInfo { - id: string; -} -export enum AttrType { - RADIO = 'RADIO', - MULTI_SELECTION = 'MULTI_SELECTION', - DROPDOWN = 'DROPDOWN', - TEXT = 'TEXT', -} -export interface IAttr { - id: string; - type: AttrType; - name: string; - label?: string; - required: boolean; - options: { value: any; label: string }[]; - - classId: string; - parent: string; - parentAttr: string; - parentValue: any; - key: string; - value: any; - leafFlag?: boolean; -} - -export enum ToolType { - BOUNDING_BOX = 'BOUNDING_BOX', - POLYGON = 'POLYGON', - POLYLINE = 'POLYLINE', - KEY_POINT = 'KEY_POINT', -} -export enum AnnotateType { - RECTANGLE = 'rectangle', - POLYGON = 'polygon', - POLYLINE = 'polyline', -} - -export enum AnnotateType2ToolType { - rectangle = ToolType.BOUNDING_BOX, - polygon = ToolType.POLYGON, - polyline = ToolType.POLYLINE, -} -export enum ToolType2AnnotatteType { - BOUNDING_BOX = AnnotateType.RECTANGLE, - POLYGON = AnnotateType.POLYGON, - POLYLINE = AnnotateType.POLYLINE, -} -export interface IClassType { - id: string; - label: string; - name: string; - color: string; - attrs: IAttr[]; - toolType: ToolType; -} - -export interface IImgViewConfig { - cameraInternal: { fx: number; fy: number; cx: number; cy: number }; - cameraExternal: number[]; - imgSize: [number, number]; - imgUrl: string; - name: string; -} - -export interface IConfig { - // prefix - imgViewPrefix: string; - singleViewPrefix: string; - // - showClassView: boolean; - showImgView: boolean; - showSingleImgView: boolean; - showSideView: boolean; - showOperationView: boolean; - // img view info - singleImgViewIndex: number; - imgRegionIndex: number; - // tool info - activeRect: boolean; - active3DBox: boolean; - active2DBox: boolean; - activeAnnotation: boolean; - activeTranslate: boolean; - activeTrack: boolean; - // project - projectPoint4: boolean; - projectPoint8: boolean; -} - -export interface IAnnotationInfo { - id: string; - msg: string; - position?: Vector3; - objectId?: string; -} - -export interface IRenderConfig { - type: string; - pointSize: number; - groundValue: number; - groundEnable: boolean; - trimMin: THREE.Vector3; - trimMax: THREE.Vector3; - // setting - renderRect: boolean; - // renderProjectRect: boolean; - renderBox: boolean; - renderProjectBox: boolean; - renderProjectPoint: boolean; - showLabel: boolean; - showAnnotation: boolean; -} - -export enum StatusType { - Default = '', - Create = 'Create', - Loading = 'Loading', - Modal = 'Modal', - Confirm = 'Confirm', -} - -export interface IAnnotationTag { - label: string; - value: string; - id: string; -} - -export interface IPoint { - x: number; - y: number; - angle?: number; - index?: number; -} - -export interface IDim { - width: number; - height: number; - scale: number; - x: number; - y: number; -} - -// 流转 -export enum ValidStatus { - VALID = 'VALID', - INVALID = 'INVALID', -} -export enum AnnotateStatus { - ANNOTATED = 'ANNOTATED', - NOT_ANNOTATED = 'NOT_ANNOTATED', - INVALID = 'INVALID', -} diff --git a/frontend/image-tool/src/package/image-editor/Editor.ts b/frontend/image-tool/src/package/image-editor/Editor.ts index c557f997..ac4ff22d 100644 --- a/frontend/image-tool/src/package/image-editor/Editor.ts +++ b/frontend/image-tool/src/package/image-editor/Editor.ts @@ -214,6 +214,11 @@ export default class Editor extends EventEmitter { lang(name: string, args?: Record) { return name; } + selectByTrackId(trackId: string) { + if (!trackId || !this.state.isSeriesFrame) return; + const objs = this.trackManager.getObjectByTrackId(trackId); + this.selectObject(objs); + } selectObject(object?: AnnotateObject | AnnotateObject[], force?: boolean) { const preSelection = this.selection; let selection: AnnotateObject[] = []; @@ -302,9 +307,11 @@ export default class Editor extends EventEmitter { this.emit(Event.FRAME_SWITCH, { from: beforeIndex, to: index }); } async loadFrame(index: number, showLoading: boolean = true, force: boolean = false) { + const currentTrack = this.state.currentTrack; await this.loadManager.loadFrame(index, showLoading, force); await this.mainView.renderFrame(); - // this.selectByTrackId(this.state.currentTrack); + this.selectByTrackId(this.state.currentTrack); + this.setCurrentTrack(currentTrack); this.emit(Event.FRAME_CHANGE, this.state.frameIndex); } diff --git a/frontend/image-tool/src/package/image-editor/common/ActionManager/action/common.ts b/frontend/image-tool/src/package/image-editor/common/ActionManager/action/common.ts index 5bc9cc8d..31baf7bf 100644 --- a/frontend/image-tool/src/package/image-editor/common/ActionManager/action/common.ts +++ b/frontend/image-tool/src/package/image-editor/common/ActionManager/action/common.ts @@ -69,3 +69,15 @@ export const adjustObject = define({ editor.cmdManager.execute('update-transform', { objects, transforms }); }, }); + +// 绘制结果时的尺寸信息的显隐控制 +export const toggleSizeInfo = define({ + valid() { + return true; + }, + canBlocked: () => false, + execute(editor: Editor) { + const { config } = editor.state; + config.showSizeTips = !config.showSizeTips; + }, +}); diff --git a/frontend/image-tool/src/package/image-editor/common/LoadManager.ts b/frontend/image-tool/src/package/image-editor/common/LoadManager.ts index 5ab26206..7483a762 100644 --- a/frontend/image-tool/src/package/image-editor/common/LoadManager.ts +++ b/frontend/image-tool/src/package/image-editor/common/LoadManager.ts @@ -1,4 +1,14 @@ -import { IDataResource, IFrame, IObjectSource, SourceType, __UNSERIES__ } from '..'; +import { + AnnotateModeEnum, + AnnotateObject, + IDataResource, + IFrame, + IObjectSource, + IUserData, + SourceType, + __UNSERIES__, + utils, +} from '..'; import Editor from '../Editor'; import { Event } from '../configs'; import { ResourceLoader } from './ResourceManager/ResourceLoader'; @@ -25,14 +35,60 @@ export default class LoadManager { // If it is a seriesFrame, all frames need to be loaded if (state.isSeriesFrame) { await this.loadFramesData(state.frames); - this.editor.updateTrack(); + const allObject: AnnotateObject[] = []; + sceneFrames.forEach((frame) => { + const frameObject = this.editor.dataManager.getFrameObject(frame.id) || []; + allObject.push(...frameObject); + }); + this.updateTrack(allObject); } await this.editor.loadFrame(0, false, true); this.editor.showLoading(false); this.editor.emit(Event.SCENE_LOADED); } + updateTrack(objects: AnnotateObject[]) { + const { defaultSourceId } = this.editor.state; + const globalTrack = {} as Record>; + // let frameTrack = {} as Record>>; + + const trackNames = objects + .filter((e) => e.userData.trackName) + .map((e) => parseInt(e.userData.trackName as any)) + .filter((e) => !isNaN(e)); + + let maxId = 0; + if (trackNames.length > 0) maxId = Math.max(...trackNames); + objects.forEach((obj) => { + const userData = obj.userData; + if (!userData.trackId) userData.trackId = utils.createTrackId(); + const trackId = userData.trackId as string; + + if (!globalTrack[trackId]) { + const classConfig = this.editor.getClassType(userData.classId || ''); + let trackName = userData.trackName; + if (!trackName) trackName = '' + maxId++; + globalTrack[trackId] = { + trackName: trackName, + trackId: userData.trackId, + classType: classConfig ? classConfig.name : '', + classId: classConfig ? classConfig.id : '', + sourceId: userData.sourceId || defaultSourceId, + annotationType: AnnotateModeEnum.INSTANCE, + // sourceType: obj.sourceType || SourceType.DATA_FLOW, + }; + } else { + Object.assign(obj, globalTrack[trackId]); + } + }); + + Object.keys(globalTrack).forEach((trackId) => { + this.editor.trackManager.addTrackObject(trackId, globalTrack[trackId]); + }); + + this.editor.idCount = maxId + 1; + } async loadFrame(index: number, showLoading: boolean = true, force: boolean = false) { const { isSeriesFrame, frameIndex, frames } = this.editor.state; if (index > frames.length - 1 || index < 0) return; diff --git a/frontend/image-tool/src/package/image-editor/common/TrackManager.ts b/frontend/image-tool/src/package/image-editor/common/TrackManager.ts index 3574d8fc..da16eb85 100644 --- a/frontend/image-tool/src/package/image-editor/common/TrackManager.ts +++ b/frontend/image-tool/src/package/image-editor/common/TrackManager.ts @@ -55,6 +55,10 @@ export default class TrackManager { updateTrackData(trackId: string, object: Partial) { const trackObject = this.getTrackObject(trackId); + if (!trackObject) { + console.error('[method updateTrackData error]'); + return; + } Object.assign(trackObject, object || {}); this.editor.emit(Event.TRACK_OBJECT_CHANGE, trackId); // this.editor.frameChange(frame); diff --git a/frontend/image-tool/src/package/image-editor/configs/hotkey.ts b/frontend/image-tool/src/package/image-editor/configs/hotkey.ts index e7d27586..65833c34 100644 --- a/frontend/image-tool/src/package/image-editor/configs/hotkey.ts +++ b/frontend/image-tool/src/package/image-editor/configs/hotkey.ts @@ -18,7 +18,7 @@ const toolHotKye: IHotkeyConfig[] = [ { key: '9', action: 'changeTool' }, { key: '0', action: 'changeTool' }, { key: 'q', action: 'selectTool' }, - { key: 'e', action: 'changeTool' }, + // { key: 'e', action: 'changeTool' }, ]; // LineTool export const lineToolHotKey: IHotkeyConfig[] = [ @@ -44,6 +44,7 @@ const displayControllerHotkey: IHotkeyConfig[] = [ { key: 't', action: 'toggleClassView' }, { key: 'm', action: 'toggleClassTitle' }, { key: 'y', action: 'toggleHelpLine' }, + { key: 'b', action: 'toggleSizeInfo' }, // { key: 'd', action: 'toggleShowPolygonArrow' }, ]; diff --git a/frontend/image-tool/src/package/image-editor/configs/tools/config.ts b/frontend/image-tool/src/package/image-editor/configs/tools/config.ts index 96626dad..fc1ec7b4 100644 --- a/frontend/image-tool/src/package/image-editor/configs/tools/config.ts +++ b/frontend/image-tool/src/package/image-editor/configs/tools/config.ts @@ -15,7 +15,7 @@ export const toolMap: Record = { [ToolName.polygon]: polygonTool, [ToolName.polyline]: lineTool, [ToolName['key-point']]: keyPointTool, - [ToolName.model]: modelTool, + // [ToolName.model]: modelTool, }; // fixed tools @@ -30,7 +30,7 @@ const tools_graph: IToolItemConfig[] = [ // segment const tools_segment: IToolItemConfig[] = []; // model -const tools_model: IToolItemConfig[] = [toolMap[ToolName.model]]; +const tools_model: IToolItemConfig[] = []; // segment model const tools_model_seg: IToolItemConfig[] = []; // instance tools diff --git a/frontend/image-tool/src/package/image-editor/types/enum.ts b/frontend/image-tool/src/package/image-editor/types/enum.ts index 9c289467..e5ba222c 100644 --- a/frontend/image-tool/src/package/image-editor/types/enum.ts +++ b/frontend/image-tool/src/package/image-editor/types/enum.ts @@ -23,7 +23,7 @@ export enum ToolName { polyline = 'polyline', // polyline tool, ToolType.POLYLINE 'key-point' = 'key-point', // key-point tool, ToolType.KEY_POINT // model - model = 'model', + // model = 'model', } export enum AnnotateModeEnum { INSTANCE = 'INSTANCE',