@labelbee/lb-components 1.6.0 → 1.7.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.js +1 -1
- package/dist/components/attributeList/index.js +1 -1
- package/dist/components/pointCloudView/PointCloud2DView.js +1 -1
- package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
- package/dist/components/pointCloudView/PointCloudBackView.js +1 -1
- package/dist/components/pointCloudView/PointCloudContext.js +1 -1
- package/dist/components/pointCloudView/PointCloudInfos.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/PointCloudSideView.js +1 -1
- package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
- package/dist/components/pointCloudView/hooks/useAttribute.js +1 -0
- package/dist/components/pointCloudView/hooks/useHistory.js +1 -0
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/usePolygon.js +1 -1
- package/dist/components/pointCloudView/hooks/useSingleBox.js +1 -1
- package/dist/components/pointCloudView/hooks/useStatus.js +1 -1
- package/dist/components/videoPlayer/components/controller/index.js +1 -1
- package/dist/constant/index.js +1 -1
- package/dist/constant/styleString.js +1 -1
- package/dist/hooks/annotation.js +1 -1
- package/dist/store/Actions.js +1 -1
- package/dist/store/annotation/actionCreators.js +1 -1
- package/dist/store/annotation/map.js +1 -1
- package/dist/store/annotation/reducer.js +1 -1
- package/dist/types/components/attributeList/index.d.ts +3 -2
- package/dist/types/components/pointCloudView/PointCloud2DView.d.ts +2 -5
- package/dist/types/components/pointCloudView/PointCloud3DView.d.ts +3 -3
- package/dist/types/components/pointCloudView/PointCloudBackView.d.ts +2 -2
- package/dist/types/components/pointCloudView/PointCloudContext.d.ts +2 -1
- package/dist/types/components/pointCloudView/PointCloudListener.d.ts +3 -3
- package/dist/types/components/pointCloudView/PointCloudSideView.d.ts +3 -3
- package/dist/types/components/pointCloudView/PointCloudTopView.d.ts +3 -3
- package/dist/types/components/pointCloudView/hooks/useAttribute.d.ts +7 -0
- package/dist/types/components/pointCloudView/hooks/useHistory.d.ts +18 -0
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +7 -3
- package/dist/types/components/pointCloudView/hooks/usePolygon.d.ts +1 -0
- package/dist/types/constant/index.d.ts +3 -1
- package/dist/types/constant/styleString.d.ts +1 -1
- package/dist/types/hooks/annotation.d.ts +4 -2
- package/dist/types/store/Actions.d.ts +1 -0
- package/dist/types/store/annotation/actionCreators.d.ts +3 -2
- package/dist/types/store/annotation/map.d.ts +12 -0
- package/dist/types/store/annotation/types.d.ts +9 -1
- package/dist/types/views/MainView/sidebar/PointCloudToolSidebar/components/batchUpdateModal/index.d.ts +13 -0
- package/dist/types/views/MainView/sidebar/PointCloudToolSidebar/index.d.ts +4 -1
- package/dist/types/views/MainView/toolFooter/FooterTips/ToolHotKey/index.d.ts +16 -1
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/batchUpdateModal/index.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/dist/views/MainView/toolFooter/FooterTips/ToolHotKey/index.js +1 -1
- package/dist/views/MainView/toolFooter/FooterTips/index.js +1 -1
- package/dist/views/MainView/toolFooter/index.js +1 -1
- package/dist/views/MainView/toolHeader/headerOption/index.js +1 -1
- package/es/App.js +1 -1
- package/es/App.js.map +1 -1
- package/es/components/attributeList/index.js +1 -1
- package/es/components/attributeList/index.js.map +1 -1
- package/es/components/pointCloudView/PointCloud2DView.js +1 -1
- package/es/components/pointCloudView/PointCloud2DView.js.map +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js.map +1 -1
- package/es/components/pointCloudView/PointCloudBackView.js +1 -1
- package/es/components/pointCloudView/PointCloudBackView.js.map +1 -1
- package/es/components/pointCloudView/PointCloudContext.js +1 -1
- package/es/components/pointCloudView/PointCloudContext.js.map +1 -1
- package/es/components/pointCloudView/PointCloudInfos.js +1 -1
- package/es/components/pointCloudView/PointCloudInfos.js.map +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js.map +1 -1
- package/es/components/pointCloudView/PointCloudSideView.js +1 -1
- package/es/components/pointCloudView/PointCloudSideView.js.map +1 -1
- package/es/components/pointCloudView/PointCloudTopView.js +1 -1
- package/es/components/pointCloudView/PointCloudTopView.js.map +1 -1
- package/es/components/pointCloudView/hooks/useAttribute.js +1 -0
- package/es/components/pointCloudView/hooks/useAttribute.js.map +1 -0
- package/es/components/pointCloudView/hooks/useHistory.js +1 -0
- package/es/components/pointCloudView/hooks/useHistory.js.map +1 -0
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js.map +1 -1
- package/es/components/pointCloudView/hooks/usePolygon.js +1 -1
- package/es/components/pointCloudView/hooks/usePolygon.js.map +1 -1
- package/es/components/pointCloudView/hooks/useSingleBox.js +1 -1
- package/es/components/pointCloudView/hooks/useSingleBox.js.map +1 -1
- package/es/components/pointCloudView/hooks/useStatus.js +1 -1
- package/es/components/pointCloudView/hooks/useStatus.js.map +1 -1
- package/es/constant/index.js +1 -1
- package/es/constant/index.js.map +1 -1
- package/es/constant/styleString.js +1 -1
- package/es/constant/styleString.js.map +1 -1
- package/es/hooks/annotation.js +1 -1
- package/es/hooks/annotation.js.map +1 -1
- package/es/store/Actions.js +1 -1
- package/es/store/Actions.js.map +1 -1
- package/es/store/annotation/actionCreators.js +1 -1
- package/es/store/annotation/actionCreators.js.map +1 -1
- package/es/store/annotation/map.js +1 -1
- package/es/store/annotation/map.js.map +1 -1
- package/es/store/annotation/reducer.js +1 -1
- package/es/store/annotation/reducer.js.map +1 -1
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/batchUpdateModal/index.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/batchUpdateModal/index.js.map +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js.map +1 -1
- package/es/views/MainView/toolFooter/FooterTips/ToolHotKey/index.js +1 -1
- package/es/views/MainView/toolFooter/FooterTips/ToolHotKey/index.js.map +1 -1
- package/es/views/MainView/toolFooter/FooterTips/index.js +1 -1
- package/es/views/MainView/toolFooter/FooterTips/index.js.map +1 -1
- package/es/views/MainView/toolFooter/index.js +1 -1
- package/es/views/MainView/toolFooter/index.js.map +1 -1
- package/es/views/MainView/toolHeader/headerOption/index.js +1 -1
- package/es/views/MainView/toolHeader/headerOption/index.js.map +1 -1
- package/package.json +4 -4
package/es/App.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import x from"./views/MainView/index.js";import{i18n as o}from"@labelbee/lb-utils";import I,{useState as y,useEffect as v}from"react";import{connect as A}from"react-redux";import{store as n}from"./index.js";import{LabelBeeContext as E}from"./store/ctx.js";import{ANNOTATION_ACTIONS as N}from"./store/Actions.js";import{InitTaskData as F,UpdateInjectFunc as D,loadImgList as U}from"./store/annotation/actionCreators.js";import{LoadFileAndFileData as P}from"./store/annotation/reducer.js";import{ConfigProvider as z}from"antd/es";import M from"antd/es/locale/zh_CN";import R from"antd/es/locale/en_US";var V=Object.defineProperty,C=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,O=(e,t,a)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,$=(e,t)=>{for(var a in t||(t={}))B.call(t,a)&&O(e,a,t[a]);if(C)for(var a of C(t))G.call(t,a)&&O(e,a,t[a]);return e};const k=e=>{const[t,a]=y(0),{imgList:s,step:j=1,stepList:l,onSubmit:c,onSave:p,onPageChange:m,onStepChange:f,initialIndex:g=0,toolInstance:S,setToolInstance:L,getFileData:d,pageSize:u=10,loadFileList:r,defaultLang:h="cn",skipBeforePageTurning:T,beforeRotate:_}=e;v(()=>{n.dispatch(F({onSubmit:c,stepList:l,step:j,getFileData:d,pageSize:u,loadFileList:r,onSave:p,onPageChange:m,onStepChange:f,skipBeforePageTurning:T,beforeRotate:_})),b(),o.changeLanguage(h);const i=()=>{a(w=>w+1)};return o.on("languageChanged",i),()=>{o.off("languageChanged",i)}},[]),v(()=>{n.dispatch(D({onSubmit:c,stepList:l,getFileData:d,pageSize:u,loadFileList:r,onSave:p,onPageChange:m,onStepChange:f,beforeRotate:_})),o.changeLanguage(h)},[c,l,d,u,r,p,m,f,h,_]),v(()=>{L==null||L(S)},[S]);const b=()=>{r?U(n.dispatch,n.getState,g,!0).then(i=>{i&&n.dispatch(P(g))}):s&&s.length>0&&(n.dispatch({type:N.UPDATE_IMG_LIST,payload:{imgList:s}}),n.dispatch(P(g)))};return I.createElement("div",null,I.createElement(z,{locale:o.language==="en"?R:M},I.createElement(x,$({},e))))},q=e=>({toolInstance:e.annotation.toolInstance});var H=A(q,null,null,{context:E})(k);export{H as default};
|
package/es/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.js","sources":["../src/App.tsx"],"sourcesContent":["import MainView from '@/views/MainView';\nimport { i18n } from '@labelbee/lb-utils';\nimport React, { useEffect } from 'react';\nimport { connect } from 'react-redux';\nimport { store } from '.';\nimport { LabelBeeContext } from '@/store/ctx';\nimport { AppState } from './store';\nimport { ANNOTATION_ACTIONS } from './store/Actions';\nimport { InitTaskData, loadImgList, UpdateInjectFunc } from './store/annotation/actionCreators';\nimport { LoadFileAndFileData } from './store/annotation/reducer';\nimport { ToolInstance } from './store/annotation/types';\nimport {\n GetFileData,\n IFileItem,\n LoadFileList,\n OnPageChange,\n OnSave,\n OnStepChange,\n OnSubmit,\n} from './types/data';\nimport { Header, RenderFooter, Sider } from './types/main';\nimport { IStepInfo } from './types/step';\n\ninterface IAnnotationStyle {\n strokeColor: string;\n fillColor: string;\n textColor: string;\n toolColor: any;\n}\n\nexport interface AppProps {\n exportData?: (data: any[]) => void;\n goBack?: () => void;\n imgList?: IFileItem[];\n config: string;\n stepList: IStepInfo[];\n step: number;\n onSubmit?: OnSubmit;\n onSave?: OnSave;\n onPageChange?: OnPageChange;\n onStepChange?: OnStepChange;\n getFileData?: GetFileData;\n pageSize: number;\n loadFileList?: LoadFileList;\n headerName?: string;\n initialIndex?: number;\n className?: string;\n toolInstance: ToolInstance;\n header?: Header;\n footer?: RenderFooter;\n sider?: Sider;\n style?: {\n layout?: { [key: string]: any };\n header?: { [key: string]: any };\n sider?: { [key: string]: any };\n footer?: { [key: string]: any };\n };\n setToolInstance?: (tool: ToolInstance) => void;\n mode?: 'light' | 'dark'; // 临时需求应用于 toolFooter 的操作\n showTips?: boolean; // 是否展示 tips\n tips?: string; // Tips 具体内容\n defaultLang: 'en' | 'cn'; // 国际化设置\n leftSider?: () => React.ReactNode | React.ReactNode;\n\n // data Correction\n skipBeforePageTurning?: (pageTurning: Function) => void;\n beforeRotate?: () => boolean;\n\n drawLayerSlot?: (props: {\n zoom: number;\n currentPos: { x: number; y: number };\n }) => React.ReactNode;\n\n // 标注信息扩展的功能\n dataInjectionAtCreation: (annotationData: any) => {};\n // 渲染增强\n renderEnhance: {\n staticRender?: (canvas: HTMLCanvasElement, data: any, style: IAnnotationStyle) => void;\n selectedRender?: (canvas: HTMLCanvasElement, data: any, style: IAnnotationStyle) => void;\n creatingRender?: (canvas: HTMLCanvasElement, data: any, style: IAnnotationStyle) => void;\n };\n customRenderStyle?: (data: any) => IAnnotationStyle;\n}\n\nconst App: React.FC<AppProps> = (props) => {\n const {\n imgList,\n step = 1,\n stepList,\n onSubmit,\n onSave,\n onPageChange,\n onStepChange,\n initialIndex = 0,\n toolInstance,\n setToolInstance,\n getFileData,\n pageSize = 10,\n loadFileList,\n defaultLang = 'cn',\n skipBeforePageTurning,\n beforeRotate,\n } = props;\n\n useEffect(() => {\n store.dispatch(\n InitTaskData({\n onSubmit,\n stepList,\n step,\n getFileData,\n pageSize,\n loadFileList,\n onSave,\n onPageChange,\n onStepChange,\n skipBeforePageTurning,\n beforeRotate,\n }),\n );\n\n initImgList();\n // 初始化国际化语言\n i18n.changeLanguage(defaultLang);\n }, []);\n\n useEffect(() => {\n store.dispatch(\n UpdateInjectFunc({\n onSubmit,\n stepList,\n getFileData,\n pageSize,\n loadFileList,\n onSave,\n onPageChange,\n onStepChange,\n beforeRotate,\n }),\n );\n\n i18n.changeLanguage(defaultLang);\n }, [\n onSubmit,\n stepList,\n getFileData,\n pageSize,\n loadFileList,\n onSave,\n onPageChange,\n onStepChange,\n defaultLang,\n beforeRotate,\n ]);\n\n useEffect(() => {\n setToolInstance?.(toolInstance);\n }, [toolInstance]);\n\n // 初始化imgList 优先以loadFileList方式加载数据\n const initImgList = () => {\n if (loadFileList) {\n loadImgList(store.dispatch, store.getState, initialIndex, true).then((isSuccess) => {\n if (isSuccess) {\n store.dispatch(LoadFileAndFileData(initialIndex));\n }\n });\n } else if (imgList && imgList.length > 0) {\n store.dispatch({\n type: ANNOTATION_ACTIONS.UPDATE_IMG_LIST,\n payload: {\n imgList,\n },\n });\n store.dispatch(LoadFileAndFileData(initialIndex));\n }\n };\n\n return (\n <div>\n <MainView {...props} />\n </div>\n );\n};\n\nconst mapStateToProps = (state: AppState) => ({\n toolInstance: state.annotation.toolInstance,\n});\n\nexport default connect(mapStateToProps, null, null, { context: LabelBeeContext })(App);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"App.js","sources":["../src/App.tsx"],"sourcesContent":["import MainView from '@/views/MainView';\nimport { i18n } from '@labelbee/lb-utils';\nimport React, { useEffect, useState } from 'react';\nimport { connect } from 'react-redux';\nimport { store } from '.';\nimport { LabelBeeContext } from '@/store/ctx';\nimport { AppState } from './store';\nimport { ANNOTATION_ACTIONS } from './store/Actions';\nimport { InitTaskData, loadImgList, UpdateInjectFunc } from './store/annotation/actionCreators';\nimport { LoadFileAndFileData } from './store/annotation/reducer';\nimport { ToolInstance } from './store/annotation/types';\nimport {\n GetFileData,\n IFileItem,\n LoadFileList,\n OnPageChange,\n OnSave,\n OnStepChange,\n OnSubmit,\n} from './types/data';\nimport { Header, RenderFooter, Sider } from './types/main';\nimport { IStepInfo } from './types/step';\nimport { ConfigProvider } from 'antd/es';\nimport zhCN from 'antd/es/locale/zh_CN';\nimport enUS from 'antd/es/locale/en_US';\n\ninterface IAnnotationStyle {\n strokeColor: string;\n fillColor: string;\n textColor: string;\n toolColor: any;\n}\n\nexport interface AppProps {\n exportData?: (data: any[]) => void;\n goBack?: () => void;\n imgList?: IFileItem[];\n config: string;\n stepList: IStepInfo[];\n step: number;\n onSubmit?: OnSubmit;\n onSave?: OnSave;\n onPageChange?: OnPageChange;\n onStepChange?: OnStepChange;\n getFileData?: GetFileData;\n pageSize: number;\n loadFileList?: LoadFileList;\n headerName?: string;\n initialIndex?: number;\n className?: string;\n toolInstance: ToolInstance;\n header?: Header;\n footer?: RenderFooter;\n sider?: Sider;\n style?: {\n layout?: { [key: string]: any };\n header?: { [key: string]: any };\n sider?: { [key: string]: any };\n footer?: { [key: string]: any };\n };\n setToolInstance?: (tool: ToolInstance) => void;\n mode?: 'light' | 'dark'; // 临时需求应用于 toolFooter 的操作\n showTips?: boolean; // 是否展示 tips\n tips?: string; // Tips 具体内容\n defaultLang: 'en' | 'cn'; // 国际化设置\n leftSider?: () => React.ReactNode | React.ReactNode;\n\n // data Correction\n skipBeforePageTurning?: (pageTurning: Function) => void;\n beforeRotate?: () => boolean;\n\n drawLayerSlot?: (props: {\n zoom: number;\n currentPos: { x: number; y: number };\n }) => React.ReactNode;\n\n // 标注信息扩展的功能\n dataInjectionAtCreation: (annotationData: any) => {};\n // 渲染增强\n renderEnhance: {\n staticRender?: (canvas: HTMLCanvasElement, data: any, style: IAnnotationStyle) => void;\n selectedRender?: (canvas: HTMLCanvasElement, data: any, style: IAnnotationStyle) => void;\n creatingRender?: (canvas: HTMLCanvasElement, data: any, style: IAnnotationStyle) => void;\n };\n customRenderStyle?: (data: any) => IAnnotationStyle;\n}\n\nconst App: React.FC<AppProps> = (props) => {\n const [_, forceRender] = useState(0);\n const {\n imgList,\n step = 1,\n stepList,\n onSubmit,\n onSave,\n onPageChange,\n onStepChange,\n initialIndex = 0,\n toolInstance,\n setToolInstance,\n getFileData,\n pageSize = 10,\n loadFileList,\n defaultLang = 'cn',\n skipBeforePageTurning,\n beforeRotate,\n } = props;\n\n useEffect(() => {\n store.dispatch(\n InitTaskData({\n onSubmit,\n stepList,\n step,\n getFileData,\n pageSize,\n loadFileList,\n onSave,\n onPageChange,\n onStepChange,\n skipBeforePageTurning,\n beforeRotate,\n }),\n );\n\n initImgList();\n // 初始化国际化语言\n i18n.changeLanguage(defaultLang);\n\n const i18nLanguageChangedFunc = () => {\n forceRender((v) => v + 1);\n };\n\n i18n.on('languageChanged', i18nLanguageChangedFunc);\n return () => {\n i18n.off('languageChanged', i18nLanguageChangedFunc);\n };\n }, []);\n\n useEffect(() => {\n store.dispatch(\n UpdateInjectFunc({\n onSubmit,\n stepList,\n getFileData,\n pageSize,\n loadFileList,\n onSave,\n onPageChange,\n onStepChange,\n beforeRotate,\n }),\n );\n\n i18n.changeLanguage(defaultLang);\n }, [\n onSubmit,\n stepList,\n getFileData,\n pageSize,\n loadFileList,\n onSave,\n onPageChange,\n onStepChange,\n defaultLang,\n beforeRotate,\n ]);\n\n useEffect(() => {\n setToolInstance?.(toolInstance);\n }, [toolInstance]);\n\n // 初始化imgList 优先以loadFileList方式加载数据\n const initImgList = () => {\n if (loadFileList) {\n loadImgList(store.dispatch, store.getState, initialIndex, true).then((isSuccess) => {\n if (isSuccess) {\n store.dispatch(LoadFileAndFileData(initialIndex));\n }\n });\n } else if (imgList && imgList.length > 0) {\n store.dispatch({\n type: ANNOTATION_ACTIONS.UPDATE_IMG_LIST,\n payload: {\n imgList,\n },\n });\n store.dispatch(LoadFileAndFileData(initialIndex));\n }\n };\n\n return (\n <div>\n <ConfigProvider locale={i18n.language === 'en' ? enUS : zhCN}>\n <MainView {...props} />\n </ConfigProvider>\n </div>\n );\n};\n\nconst mapStateToProps = (state: AppState) => ({\n toolInstance: state.annotation.toolInstance,\n});\n\nexport default connect(mapStateToProps, null, null, { context: LabelBeeContext })(App);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,GAAA,GAA0B,CAAC,KAAU,KAAA;AACzC,EAAM,MAAA,CAAC,CAAG,EAAA,WAAA,CAAA,GAAe,QAAS,CAAA,CAAA,CAAA,CAAA;AAClC,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,IAAO,GAAA,CAAA;AAAA,IACP,QAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA,IACA,YAAA;AAAA,IACA,YAAe,GAAA,CAAA;AAAA,IACf,YAAA;AAAA,IACA,eAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAW,GAAA,EAAA;AAAA,IACX,YAAA;AAAA,IACA,WAAc,GAAA,IAAA;AAAA,IACd,qBAAA;AAAA,IACA,YAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,KAAA,CAAM,SACJ,YAAa,CAAA;AAAA,MACX,QAAA;AAAA,MACA,QAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA;AAAA,MACA,YAAA;AAAA,MACA,MAAA;AAAA,MACA,YAAA;AAAA,MACA,YAAA;AAAA,MACA,qBAAA;AAAA,MACA,YAAA;AAAA,KAAA,CAAA,CAAA,CAAA;AAIJ,IAAA,WAAA,EAAA,CAAA;AAEA,IAAA,IAAA,CAAK,cAAe,CAAA,WAAA,CAAA,CAAA;AAEpB,IAAA,MAAM,0BAA0B,MAAM;AACpC,MAAY,WAAA,CAAA,CAAC,MAAM,CAAI,GAAA,CAAA,CAAA,CAAA;AAAA,KAAA,CAAA;AAGzB,IAAA,IAAA,CAAK,GAAG,iBAAmB,EAAA,uBAAA,CAAA,C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,KAAA,CAAM,QAAS,CAAA;AAAA,QACb,MAAM,kBAAmB,CAAA,eAAA;AAAA,QACzB,OAAS,EAAA;AAAA,UACP,OAAA;AAAA,SAAA;AAAA,OAAA,CAAA,CAAA;AAGJ,MAAA,KAAA,CAAM,SAAS,mBAAoB,CAAA,YAAA,CAAA,CAAA,CAAA;AAAA,KAAA;AAAA,GAAA,CAAA;AAIvC,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAD,IACE,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAD,EAAA;AAAA,IAAgB,MAAQ,EAAA,IAAA,CAAK,QAAa,KAAA,IAAA,GAAO,IAAO,GAAA,IAAA;AAAA,GACtD,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAD,cAAc,CAAA,EAAA,EAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAMtB,MAAM,eAAA,GAAkB,CAAC,KAAqB,MAAA;AAAA,EAC5C,YAAA,EAAc,MAAM,UAAW,CAAA,YAAA;AAAA,CAAA,CAAA,CAAA;AAGjC,YAAe,QAAQ,eAAiB,EAAA,IAAA,EAAM,IAAM,EAAA,CAAE,SAAS,eAAmB,CAAA,CAAA,CAAA,GAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{COLORS_ARRAY as
|
|
1
|
+
import{COLORS_ARRAY as n,NULL_COLOR as g}from"../../data/Style.js";import{ColorTag as R}from"../colorTag/index.js";import{Radio as f}from"antd/es";import l from"react";const c=[g].concat(n),v=l.forwardRef((e,d)=>{const s=l.useRef(),b=e.list||[];let o=[...c];e.forbidDefault===!0&&(o=o.slice(1));let i="sensebee-radio-group";return e.noHeightLimit&&(i="sensebee-radio-group-no-limit-height"),l.createElement("div",{className:i,style:e.style},l.createElement(f.Group,{name:"radiogroup",defaultValue:e==null?void 0:e.selectedAttribute,value:e==null?void 0:e.selectedAttribute,onChange:t=>e.attributeChanged(t.target.value),ref:d},b.map((t,r)=>{var u;let a=(u=e==null?void 0:e.num)!=null?u:r;e.forbidDefault===!0&&typeof a=="number"&&a++,typeof a=="number"&&a<=9&&a>=0||(a="-");let m=r>8&&!e.forbidDefault?n[(r-1)%n.length]:o[r%o.length];return(t==null?void 0:t.color)&&(m=t.color),l.createElement(f,{value:t.value,ref:s,key:r},l.createElement("span",{className:"sensebee-radio-label",title:t.label},!(e==null?void 0:e.forbidColor)&&l.createElement(R,{color:m,style:{marginRight:"8px"}}),t.label),l.createElement("span",{className:"sensebee-radio-num"},a))})))});export{c as ATTRIBUTE_COLORS,v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/attributeList/index.tsx"],"sourcesContent":["import { COLORS_ARRAY, NULL_COLOR } from '@/data/Style';\nimport { ColorTag } from '@/components/colorTag';\nimport { Radio } from 'antd/es';\nimport React from 'react';\n\nexport const ATTRIBUTE_COLORS = [NULL_COLOR].concat(COLORS_ARRAY);\n\ninterface IProps {\n list: Array<{\n label: string;\n value: string;\n color?: string;\n }>;\n selectedAttribute
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/attributeList/index.tsx"],"sourcesContent":["import { COLORS_ARRAY, NULL_COLOR } from '@/data/Style';\nimport { ColorTag } from '@/components/colorTag';\nimport { Radio } from 'antd/es';\nimport React from 'react';\n\nexport const ATTRIBUTE_COLORS = [NULL_COLOR].concat(COLORS_ARRAY);\n\ninterface IProps {\n list: Array<{\n label: string;\n value: string;\n color?: string;\n }>;\n selectedAttribute?: string;\n attributeChanged: (v: string) => void;\n forbidDefault?: boolean;\n forbidColor?: boolean;\n noHeightLimit?: boolean;\n num?: number | string;\n style?: React.CSSProperties;\n}\n\nconst AttributeList = React.forwardRef((props: IProps, ref) => {\n const radioRef = React.useRef<any>();\n\n const list = props.list || [];\n\n let NEW_ATTRIBUTE_COLORS = [...ATTRIBUTE_COLORS];\n\n // 去除默认的颜色\n if (props.forbidDefault === true) {\n NEW_ATTRIBUTE_COLORS = NEW_ATTRIBUTE_COLORS.slice(1);\n }\n\n let className = 'sensebee-radio-group';\n if (props.noHeightLimit) {\n className = 'sensebee-radio-group-no-limit-height';\n }\n\n return (\n <div className={className} style={props.style}>\n <Radio.Group\n name='radiogroup'\n defaultValue={props?.selectedAttribute}\n value={props?.selectedAttribute}\n onChange={(e) => props.attributeChanged(e.target.value)}\n ref={ref as any}\n >\n {list.map((i: any, index: number) => {\n let hotKey: number | string = props?.num ?? index;\n\n if (props.forbidDefault === true && typeof hotKey === 'number') {\n // 禁止 default 将从 1 开始\n hotKey++;\n }\n\n // 超出范围无法展示\n if (!(typeof hotKey === 'number' && hotKey <= 9 && hotKey >= 0)) {\n hotKey = '-';\n }\n\n let color =\n index > 8 && !props.forbidDefault\n ? COLORS_ARRAY[(index - 1) % COLORS_ARRAY.length]\n : NEW_ATTRIBUTE_COLORS[index % NEW_ATTRIBUTE_COLORS.length];\n\n if (i?.color) {\n color = i.color;\n }\n\n return (\n <Radio value={i.value} ref={radioRef} key={index}>\n <span className='sensebee-radio-label' title={i.label}>\n {!props?.forbidColor && <ColorTag color={color} style={{ marginRight: '8px' }} />}\n {i.label}\n </span>\n <span className='sensebee-radio-num'>{hotKey}</span>\n </Radio>\n );\n })}\n </Radio.Group>\n </div>\n );\n});\n\nexport default AttributeList;\n"],"names":[],"mappings":";;;;;AAKa,MAAA,gBAAA,GAAmB,CAAC,UAAA,CAAA,CAAY,MAAO,CAAA,YAAA,EAAA;AAiBpD,MAAM,aAAgB,GAAA,KAAA,CAAM,UAAW,CAAA,CAAC,OAAe,GAAQ,KAAA;AAC7D,EAAA,MAAM,WAAW,KAAM,CAAA,MAAA,EAAA,CAAA;AAEvB,EAAM,MAAA,IAAA,GAAO,MAAM,IAAQ,IAAA,EAAA,CAAA;AAE3B,EAAI,IAAA,oBAAA,GAAuB,CAAC,GAAG,gBAAA,CAAA,CAAA;AAG/B,EAAI,IAAA,KAAA,CAAM,kBAAkB,IAAM,EAAA;AAChC,I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,KAAM,CAAA,aAAA,GAChB,YAAc,CAAA,CAAA,KAAA,GAAQ,CAAK,IAAA,YAAA,CAAa,MACxC,CAAA,GAAA,oBAAA,CAAqB,QAAQ,oBAAqB,CAAA,MAAA,CAAA,CAAA;AAExD,IAAA,IAAI,uBAAG,KAAO,EAAA;AACZ,MAAA,KAAA,GAAQ,CAAE,CAAA,KAAA,CAAA;AAAA,KAAA;AAGZ,IAAA,2CACG,KAAD,EAAA;AAAA,MAAO,OAAO,CAAE,CAAA,KAAA;AAAA,MAAO,GAAK,EAAA,QAAA;AAAA,MAAU,GAAK,EAAA,KAAA;AAAA,KAAA,sCACxC,MAAD,EAAA;AAAA,MAAM,SAAU,EAAA,sBAAA;AAAA,MAAuB,OAAO,CAAE,CAAA,KAAA;AAAA,KAAA,EAC7C,EAAC,KAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAO,WAAe,CAAA,oBAAA,KAAA,CAAA,aAAA,CAAC,QAAD,EAAA;AAAA,MAAU,KAAA;AAAA,MAAc,KAAA,EAAO,CAAE,WAAa,EAAA,KAAA,CAAA;AAAA,KACrE,CAAA,EAAA,CAAA,CAAE,KAEL,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,MAAD,EAAA;AAAA,MAAM,SAAU,EAAA,oBAAA;AAAA,KAAsB,EAAA,MAAA,CAAA,CAAA,CAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as
|
|
1
|
+
import{getClassName as j}from"../../utils/dom.js";import i,{useState as h,useContext as M,useRef as E,useEffect as P,useCallback as F}from"react";import{PointCloudContainer as $}from"./PointCloudLayout.js";import q from"../AnnotationView/index.js";import{PointCloudContext as G}from"./PointCloudContext.js";import{connect as H}from"react-redux";import{LeftOutlined as J,RightOutlined as K}from"@ant-design/icons";import Q from"../../hooks/useSize.js";import{useSingleBox as U}from"./hooks/useSingleBox.js";import{useTranslation as W}from"react-i18next";import{LabelBeeContext as X}from"../../store/ctx.js";import{a2MapStateToProps as Y}from"../../store/annotation/map.js";import{toolStyleConverter as Z}from"@labelbee/lb-utils";var D=Object.defineProperty,tt=Object.defineProperties,ot=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,et=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable,V=(t,o,e)=>o in t?D(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,k=(t,o)=>{for(var e in o||(o={}))et.call(o,e)&&V(t,e,o[e]);if(S)for(var e of S(o))nt.call(o,e)&&V(t,e,o[e]);return t},N=(t,o)=>tt(t,ot(o));const it=({onNext:t,onPrev:o,imgLength:e,imgIndex:d})=>i.createElement("div",null,i.createElement(J,{onClick:o}),i.createElement("span",null," ",d+1," / ",e," "),i.createElement(K,{onClick:t})),lt=({currentData:t,config:o})=>{var e,d,b,C,L;const[u,A]=h([]),{pointCloudBoxList:w,topViewInstance:x}=M(G),[s,c]=h(0),y=E(null),f=E(),{selectedBox:g}=U(),B=Q(y),{t:R}=W(),a=(e=t==null?void 0:t.mappingImgList)==null?void 0:e[s];P(()=>{c(0)},[t]),P(()=>{if(x&&a){const{pointCloudInstance:n}=x,l={fill:"transparent",color:"green"},m=w.reduce((r,p)=>{var I;const z=n.pointCloudLidar2image(p,a.calib),T=(I=Z.getColorFromConfig({attribute:p.attribute},N(k({},o),{attributeConfigurable:!0}),{}))==null?void 0:I.stroke;return[...r,...z.map(O=>({type:O.type,annotation:N(k({id:p.id,pointList:O.pointList},l),{stroke:T})}))]},[]);A(m)}},[w,a]);const v=!t||!(t==null?void 0:t.mappingImgList)||!(((d=t==null?void 0:t.mappingImgList)==null?void 0:d.length)>0),_=F(()=>{var n,l;const m=(n=f.current)==null?void 0:n.toolInstance;if(!g||!m)return;const r=u.find(p=>p.annotation.id===g.info.id);((l=r==null?void 0:r.annotation.pointList)==null?void 0:l.length)>0&&m.focusPositionByPointList(r==null?void 0:r.annotation.pointList)},[g,f.current,u,s]);return P(()=>{_()},[_]),i.createElement($,{className:j("point-cloud-2d-container"),title:R("2DView"),toolbar:v?void 0:i.createElement(it,{imgIndex:s,imgLength:(C=(b=t.mappingImgList)==null?void 0:b.length)!=null?C:0,onNext:()=>{var n;!t||!(t==null?void 0:t.mappingImgList)||s>=((n=t==null?void 0:t.mappingImgList)==null?void 0:n.length)-1||c(l=>l+1)},onPrev:()=>{s<=0||c(n=>n-1)}}),style:{display:v?"none":"flex"}},i.createElement("div",{className:j("point-cloud-2d-image"),ref:y},i.createElement(q,{src:(L=a==null?void 0:a.url)!=null?L:"",annotations:u,size:B,ref:f,globalStyle:{display:v?"none":"block"},afterImgOnLoad:_})))};var rt=H(Y,null,null,{context:X})(lt);export{rt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PointCloud2DView.js","sources":["../../../src/components/pointCloudView/PointCloud2DView.tsx"],"sourcesContent":["import { getClassName } from '@/utils/dom';\nimport React, { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport AnnotationView from '@/components/AnnotationView';\nimport { PointCloudContext } from './PointCloudContext';\nimport { AppState } from '@/store';\nimport { connect } from 'react-redux';\nimport { IFileItem } from '@/types/data';\nimport { LeftOutlined, RightOutlined } from '@ant-design/icons';\nimport useSize from '@/hooks/useSize';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { ViewOperation } from '@labelbee/lb-annotation';\nimport { useTranslation } from 'react-i18next';\nimport { LabelBeeContext } from '@/store/ctx';\n\ninterface IProps {\n imgInfo: IFileItem;\n}\n\nconst Toolbar = ({\n onNext,\n onPrev,\n imgLength,\n imgIndex,\n}: {\n onNext: () => void;\n onPrev: () => void;\n imgLength: number;\n imgIndex: number;\n}) => {\n return (\n <div>\n <LeftOutlined onClick={onPrev} />\n <span>\n {' '}\n {imgIndex + 1} / {imgLength}{' '}\n </span>\n\n <RightOutlined onClick={onNext} />\n </div>\n );\n};\n\n// TODO, It will be deleted when the exported type of lb-annotation is work.\ninterface IAnnotationDataTemporarily {\n type: string;\n annotation: any;\n}\n\nconst PointCloud2DView = ({ imgInfo }: IProps) => {\n const [annotations2d, setAnnotations2d] = useState<IAnnotationDataTemporarily[]>([]);\n const { pointCloudBoxList, topViewInstance } = useContext(PointCloudContext);\n const [mappingIndex, setMappingIndex] = useState(0);\n const ref = useRef(null);\n const viewRef = useRef<{ toolInstance: ViewOperation }>();\n const { selectedBox } = useSingleBox();\n const size = useSize(ref);\n const { t } = useTranslation();\n\n const mappingData = imgInfo?.mappingImgList?.[mappingIndex];\n\n useEffect(() => {\n setMappingIndex(0);\n }, [imgInfo]);\n\n useEffect(() => {\n if (topViewInstance && mappingData) {\n const { pointCloudInstance } = topViewInstance;\n const defaultViewStyle = {\n fill: 'transparent',\n color: 'green',\n };\n const newAnnotations2d: IAnnotationDataTemporarily[] = pointCloudBoxList.reduce(\n (acc: IAnnotationDataTemporarily[], pointCloudBox) => {\n const viewDataPointList = pointCloudInstance.pointCloudLidar2image(\n pointCloudBox,\n mappingData.calib,\n );\n return [\n ...acc,\n ...viewDataPointList.map((v: any) => {\n return {\n type: v.type,\n annotation: {\n id: pointCloudBox.id,\n pointList: v.pointList,\n ...defaultViewStyle,\n },\n };\n }),\n ];\n },\n [],\n );\n\n setAnnotations2d(newAnnotations2d);\n }\n }, [pointCloudBoxList, mappingData]);\n\n const hiddenData = !imgInfo || !imgInfo?.mappingImgList || !(imgInfo?.mappingImgList?.length > 0);\n\n const afterImgOnLoad = useCallback(() => {\n const toolInstance = viewRef.current?.toolInstance;\n\n if (!selectedBox || !toolInstance) {\n return;\n }\n const selected2data = annotations2d.find((v) => v.annotation.id === selectedBox.info.id);\n\n if (selected2data?.annotation.pointList?.length > 0) {\n toolInstance.focusPositionByPointList(selected2data?.annotation.pointList);\n }\n }, [selectedBox, viewRef.current, annotations2d, mappingIndex]);\n\n /**\n * If the status is updated, it needs to\n */\n useEffect(() => {\n afterImgOnLoad();\n }, [afterImgOnLoad]);\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-2d-container')}\n title={t('2DView')}\n toolbar={\n hiddenData ? undefined : (\n <Toolbar\n imgIndex={mappingIndex}\n imgLength={imgInfo.mappingImgList?.length ?? 0}\n onNext={() => {\n if (!imgInfo || !imgInfo?.mappingImgList) {\n return;\n }\n\n if (mappingIndex >= imgInfo?.mappingImgList?.length - 1) {\n return;\n }\n setMappingIndex((v) => v + 1);\n }}\n onPrev={() => {\n if (mappingIndex <= 0) {\n return;\n }\n setMappingIndex((v) => v - 1);\n }}\n />\n )\n }\n style={{ display: hiddenData ? 'none' : 'flex' }}\n >\n <div className={getClassName('point-cloud-2d-image')} ref={ref}>\n <AnnotationView\n src={mappingData?.url ?? ''}\n annotations={annotations2d}\n size={size}\n ref={viewRef}\n globalStyle={{ display: hiddenData ? 'none' : 'block' }}\n afterImgOnLoad={afterImgOnLoad}\n />\n </div>\n </PointCloudContainer>\n );\n};\n\nconst mapStateToProps = (state: AppState) => {\n const { imgList, imgIndex } = state.annotation;\n\n return {\n imgInfo: imgList[imgIndex],\n };\n};\n\nexport default connect(mapStateToProps, null, null, { context: LabelBeeContext })(PointCloud2DView);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,UAAU,CAAC;AAAA,EACf,MAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,CAMI,KAAA;AACJ,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAD,IACE,kBAAA,KAAA,CAAA,aAAA,CAAC,YAAD,EAAA;AAAA,IAAc,OAAS,EAAA,MAAA;AAAA,GACvB,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,MAAD,EAAA,IAAA,EACG,GACA,EAAA,QAAA,GAAW,GAAE,KAAI,EAAA,SAAA,EAAW,GAG/B,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAD,EAAA;AAAA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QAAA,CAAA,GAAa,KAAM,CAAA,UAAA,CAAA;AAEpC,EAAO,OAAA;AAAA,IACL,SAAS,OAAQ,CAAA,QAAA,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAIrB,yBAAe,QAAQ,eAAiB,EAAA,IAAA,EAAM,IAAM,EAAA,CAAE,SAAS,eAAmB,CAAA,CAAA,CAAA,gBAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"PointCloud2DView.js","sources":["../../../src/components/pointCloudView/PointCloud2DView.tsx"],"sourcesContent":["import { getClassName } from '@/utils/dom';\nimport React, { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport AnnotationView from '@/components/AnnotationView';\nimport { PointCloudContext } from './PointCloudContext';\nimport { connect } from 'react-redux';\nimport { LeftOutlined, RightOutlined } from '@ant-design/icons';\nimport useSize from '@/hooks/useSize';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { ViewOperation } from '@labelbee/lb-annotation';\nimport { useTranslation } from 'react-i18next';\nimport { LabelBeeContext } from '@/store/ctx';\nimport { a2MapStateToProps, IA2MapStateProps } from '@/store/annotation/map';\nimport { toolStyleConverter } from '@labelbee/lb-utils';\n\nconst Toolbar = ({\n onNext,\n onPrev,\n imgLength,\n imgIndex,\n}: {\n onNext: () => void;\n onPrev: () => void;\n imgLength: number;\n imgIndex: number;\n}) => {\n return (\n <div>\n <LeftOutlined onClick={onPrev} />\n <span>\n {' '}\n {imgIndex + 1} / {imgLength}{' '}\n </span>\n\n <RightOutlined onClick={onNext} />\n </div>\n );\n};\n\n// TODO, It will be deleted when the exported type of lb-annotation is work.\ninterface IAnnotationDataTemporarily {\n type: string;\n annotation: any;\n}\n\nconst PointCloud2DView = ({ currentData, config }: IA2MapStateProps) => {\n const [annotations2d, setAnnotations2d] = useState<IAnnotationDataTemporarily[]>([]);\n const { pointCloudBoxList, topViewInstance } = useContext(PointCloudContext);\n const [mappingIndex, setMappingIndex] = useState(0);\n const ref = useRef(null);\n const viewRef = useRef<{ toolInstance: ViewOperation }>();\n const { selectedBox } = useSingleBox();\n const size = useSize(ref);\n const { t } = useTranslation();\n\n const mappingData = currentData?.mappingImgList?.[mappingIndex];\n\n useEffect(() => {\n setMappingIndex(0);\n }, [currentData]);\n\n useEffect(() => {\n if (topViewInstance && mappingData) {\n const { pointCloudInstance } = topViewInstance;\n const defaultViewStyle = {\n fill: 'transparent',\n color: 'green',\n };\n\n const newAnnotations2d: IAnnotationDataTemporarily[] = pointCloudBoxList.reduce(\n (acc: IAnnotationDataTemporarily[], pointCloudBox) => {\n const viewDataPointList = pointCloudInstance.pointCloudLidar2image(\n pointCloudBox,\n mappingData.calib,\n );\n\n const stroke = toolStyleConverter.getColorFromConfig(\n { attribute: pointCloudBox.attribute },\n {\n ...config,\n attributeConfigurable: true,\n },\n {},\n )?.stroke;\n\n return [\n ...acc,\n ...viewDataPointList.map((v: any) => {\n return {\n type: v.type,\n annotation: {\n id: pointCloudBox.id,\n pointList: v.pointList,\n ...defaultViewStyle,\n stroke,\n },\n };\n }),\n ];\n },\n [],\n );\n\n setAnnotations2d(newAnnotations2d);\n }\n }, [pointCloudBoxList, mappingData]);\n\n const hiddenData =\n !currentData || !currentData?.mappingImgList || !(currentData?.mappingImgList?.length > 0);\n\n const afterImgOnLoad = useCallback(() => {\n const toolInstance = viewRef.current?.toolInstance;\n\n if (!selectedBox || !toolInstance) {\n return;\n }\n const selected2data = annotations2d.find((v) => v.annotation.id === selectedBox.info.id);\n\n if (selected2data?.annotation.pointList?.length > 0) {\n toolInstance.focusPositionByPointList(selected2data?.annotation.pointList);\n }\n }, [selectedBox, viewRef.current, annotations2d, mappingIndex]);\n\n /**\n * If the status is updated, it needs to\n */\n useEffect(() => {\n afterImgOnLoad();\n }, [afterImgOnLoad]);\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-2d-container')}\n title={t('2DView')}\n toolbar={\n hiddenData ? undefined : (\n <Toolbar\n imgIndex={mappingIndex}\n imgLength={currentData.mappingImgList?.length ?? 0}\n onNext={() => {\n if (!currentData || !currentData?.mappingImgList) {\n return;\n }\n\n if (mappingIndex >= currentData?.mappingImgList?.length - 1) {\n return;\n }\n setMappingIndex((v) => v + 1);\n }}\n onPrev={() => {\n if (mappingIndex <= 0) {\n return;\n }\n setMappingIndex((v) => v - 1);\n }}\n />\n )\n }\n style={{ display: hiddenData ? 'none' : 'flex' }}\n >\n <div className={getClassName('point-cloud-2d-image')} ref={ref}>\n <AnnotationView\n src={mappingData?.url ?? ''}\n annotations={annotations2d}\n size={size}\n ref={viewRef}\n globalStyle={{ display: hiddenData ? 'none' : 'block' }}\n afterImgOnLoad={afterImgOnLoad}\n />\n </div>\n </PointCloudContainer>\n );\n};\n\nexport default connect(a2MapStateToProps, null, null, { context: LabelBeeContext })(\n PointCloud2DView,\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,UAAU,CAAC;AAAA,EACf,MAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,CAMI,KAAA;AACJ,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAD,IACE,kBAAA,KAAA,CAAA,aAAA,CAAC,YAAD,EAAA;AAAA,IAAc,OAAS,EAAA,MAAA;AAAA,GACvB,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,MAAD,EAAA,IAAA,EACG,GACA,EAAA,QAAA,GAAW,GAAE,KAAI,EAAA,SAAA,EAAW,GAG/B,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAD,EAAA;AAAA,IAAe,OAAS,EAAA,MAAA;AAAA,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAW9B,MAAM,gBAAmB,GAAA,CAAC,CAAE,WAAA,EAAa,MAA+B,CAAA,KAAA;AA7CxE,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,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A,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAOV,yBAAe,QAAQ,iBAAmB,EAAA,IAAA,EAAM,IAAM,EAAA,CAAE,SAAS,eAC/D,CAAA,CAAA,CAAA,gBAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as
|
|
1
|
+
import{getClassName as c}from"../../utils/dom.js";import{PointCloud as D}from"@labelbee/lb-annotation";import{PointCloudUtils as I,toolStyleConverter as L,EPerspectiveView as E}from"@labelbee/lb-utils";import y from"classnames";import t,{useContext as d,useState as T,useRef as N,useEffect as v,useMemo as R}from"react";import{PointCloudContainer as k}from"./PointCloudLayout.js";import{PointCloudContext as A}from"./PointCloudContext.js";import{a2MapStateToProps as z}from"../../store/annotation/map.js";import{connect as F}from"react-redux";import{jsonParser as M}from"../../utils/index.js";import{useSingleBox as U}from"./hooks/useSingleBox.js";import{Switch as q}from"antd";import G from"../../hooks/useSize.js";import{usePointCloudViews as H}from"./hooks/usePointCloudViews.js";import{useTranslation as J}from"react-i18next";import{LabelBeeContext as K}from"../../store/ctx.js";var Q=Object.defineProperty,W=Object.defineProperties,X=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,_=(e,o,r)=>o in e?Q(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,$=(e,o)=>{for(var r in o||(o={}))Y.call(o,r)&&_(e,r,o[r]);if(x)for(var r of x(o))Z.call(o,r)&&_(e,r,o[r]);return e},ee=(e,o)=>W(e,X(o));const te="LABELBEE-POINTCLOUD",f=t.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{}}),l=({perspectiveView:e})=>{const{isActive:o,setTarget3DView:r}=d(f),n=p=>y({[c("point-cloud-3d-view",p)]:!0,active:o});return t.createElement("span",{onClick:()=>{r(E[e])},className:n(e.toLocaleLowerCase())})},oe=()=>{const{reset3DView:e}=d(f);return t.createElement("div",{className:c("point-cloud-3d-sidebar")},t.createElement(l,{perspectiveView:"Top"}),t.createElement(l,{perspectiveView:"Front"}),t.createElement(l,{perspectiveView:"Left"}),t.createElement(l,{perspectiveView:"Back"}),t.createElement(l,{perspectiveView:"Right"}),t.createElement(l,{perspectiveView:"LFT"}),t.createElement(l,{perspectiveView:"RBT"}),t.createElement("span",{onClick:()=>{e()},className:c("point-cloud-3d-view","reset")}))},re=({currentData:e,config:o})=>{var r;const n=d(A),[p,b]=T(!0),u=N(null),{initPointCloud3d:C}=H(),h=G(u),{t:w}=J();v(()=>{!n.mainViewInstance||C==null||C()},[h]);const{selectedBox:a}=U(),P=s=>{var i;const m=a==null?void 0:a.info;m&&((i=n.mainViewInstance)==null||i.updateCameraByBox(m,s))},j=()=>{var s;(s=n.mainViewInstance)==null||s.resetCamera()};v(()=>{var s;if(u.current&&(e==null?void 0:e.url)){let i=n.mainViewInstance;if(i||(i=new D({container:u.current,backgroundColor:"#4c4c4c",config:o})),e.result){const m=I.getBoxParamsFromResultList(e.result);m.forEach(g=>{var V;const B=(V=L.getColorFromConfig({attribute:g.attribute},ee($({},o),{attributeConfigurable:!0}),{}))==null?void 0:V.hex;i==null||i.generateBox(g,B)}),n.setPointCloudResult(m),n.setPointCloudValid((s=M(e.result))==null?void 0:s.valid)}n.setMainViewInstance(i)}},[e]),v(()=>{a&&P(E.Top)},[a]);const O=R(()=>({reset3DView:j,setTarget3DView:P,isActive:!!a}),[a]),S=t.createElement("div",null,t.createElement("span",{style:{marginRight:8}},w("ShowArrows")),t.createElement(q,{size:"small",checked:p,onChange:s=>{var i;b(s),(i=n.mainViewInstance)==null||i.setShowDirection(s)}}));return t.createElement(k,{className:c("point-cloud-3d-container"),title:w("3DView"),toolbar:S,style:{height:e.mappingImgList&&((r=e.mappingImgList)==null?void 0:r.length)>0?"55%":"100%"}},t.createElement("div",{className:c("point-cloud-3d-content")},t.createElement(f.Provider,{value:O},t.createElement(oe,null)),t.createElement("div",{className:c("point-cloud-3d-view"),id:te,ref:u})))};var ie=F(z,null,null,{context:K})(re);export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PointCloud3DView.js","sources":["../../../src/components/pointCloudView/PointCloud3DView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-13 19:31:36\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-06-27 19:43:25\n */\n\nimport { getClassName } from '@/utils/dom';\nimport { PointCloud } from '@labelbee/lb-annotation';\nimport { EPerspectiveView, IPointCloudBox, PointCloudUtils } from '@labelbee/lb-utils';\nimport classNames from 'classnames';\nimport React, { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport { PointCloudContext } from './PointCloudContext';\nimport { aMapStateToProps, IAnnotationStateProps } from '@/store/annotation/map';\nimport { connect } from 'react-redux';\nimport { jsonParser } from '@/utils';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { Switch } from 'antd';\nimport useSize from '@/hooks/useSize';\nimport { usePointCloudViews } from './hooks/usePointCloudViews';\nimport { useTranslation } from 'react-i18next';\nimport { LabelBeeContext } from '@/store/ctx';\n\nconst pointCloudID = 'LABELBEE-POINTCLOUD';\nconst PointCloud3DContext = React.createContext<{\n isActive: boolean;\n setTarget3DView: (perspectiveView: EPerspectiveView) => void;\n reset3DView: () => void;\n}>({\n isActive: false,\n setTarget3DView: () => {},\n reset3DView: () => {},\n});\n\nconst PointCloudViewIcon = ({\n perspectiveView,\n}: {\n perspectiveView: keyof typeof EPerspectiveView;\n}) => {\n const { isActive, setTarget3DView } = useContext(PointCloud3DContext);\n\n const getTarget3DViewClassName = (position: string) => {\n return classNames({\n [getClassName('point-cloud-3d-view', position)]: true,\n active: isActive,\n });\n };\n\n return (\n <span\n onClick={() => {\n setTarget3DView(EPerspectiveView[perspectiveView]);\n }}\n className={getTarget3DViewClassName(perspectiveView.toLocaleLowerCase())}\n />\n );\n};\n\nconst PointCloud3DSideBar = () => {\n const { reset3DView } = useContext(PointCloud3DContext);\n return (\n <div className={getClassName('point-cloud-3d-sidebar')}>\n <PointCloudViewIcon perspectiveView='Top' />\n <PointCloudViewIcon perspectiveView='Front' />\n <PointCloudViewIcon perspectiveView='Left' />\n <PointCloudViewIcon perspectiveView='Back' />\n <PointCloudViewIcon perspectiveView='Right' />\n <PointCloudViewIcon perspectiveView='LFT' />\n <PointCloudViewIcon perspectiveView='RBT' />\n <span\n onClick={() => {\n reset3DView();\n }}\n className={getClassName('point-cloud-3d-view', 'reset')}\n />\n </div>\n );\n};\n\nconst PointCloud3D: React.FC<IAnnotationStateProps> = ({ currentData }) => {\n const ptCtx = useContext(PointCloudContext);\n const [showDirection, setShowDirection] = useState(true);\n const ref = useRef<HTMLDivElement>(null);\n const { initPointCloud3d } = usePointCloudViews();\n const size = useSize(ref);\n const { t } = useTranslation();\n\n useEffect(() => {\n if (!ptCtx.mainViewInstance) {\n return;\n }\n initPointCloud3d?.();\n }, [size]);\n const { selectedBox } = useSingleBox();\n\n const setTarget3DView = (perspectiveView: EPerspectiveView) => {\n const box = selectedBox?.info;\n\n if (box) {\n ptCtx.mainViewInstance?.updateCameraByBox(box, perspectiveView);\n }\n };\n\n const reset3DView = () => {\n ptCtx.mainViewInstance?.resetCamera();\n };\n\n useEffect(() => {\n if (ref.current && currentData?.url) {\n let pointCloud = ptCtx.mainViewInstance;\n if (!pointCloud) {\n pointCloud = new PointCloud({\n container: ref.current,\n backgroundColor: '#4c4c4c',\n });\n }\n\n if (currentData.result) {\n const boxParamsList = PointCloudUtils.getBoxParamsFromResultList(currentData.result);\n\n // Add Init Box\n boxParamsList.forEach((v: IPointCloudBox) => {\n pointCloud?.generateBox(v);\n });\n\n ptCtx.setPointCloudResult(boxParamsList);\n ptCtx.setPointCloudValid(jsonParser(currentData.result)?.valid);\n }\n\n ptCtx.setMainViewInstance(pointCloud);\n }\n }, [currentData]);\n\n /**\n * Observe selectedID and reset camera to target top-view\n */\n useEffect(() => {\n if (selectedBox) {\n setTarget3DView(EPerspectiveView.Top);\n }\n }, [selectedBox]);\n\n const ptCloud3DCtx = useMemo(() => {\n return { reset3DView, setTarget3DView, isActive: !!selectedBox };\n }, [selectedBox]);\n\n const PointCloud3DTitle = (\n <div>\n <span style={{ marginRight: 8 }}>{t('ShowArrows')}</span>\n <Switch\n size='small'\n checked={showDirection}\n onChange={(showDirection) => {\n setShowDirection(showDirection);\n ptCtx.mainViewInstance?.setShowDirection(showDirection);\n }}\n />\n </div>\n );\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-3d-container')}\n title={t('3DView')}\n toolbar={PointCloud3DTitle}\n style={{\n height:\n currentData.mappingImgList && currentData.mappingImgList?.length > 0 ? '55%' : '100%',\n }}\n >\n <div className={getClassName('point-cloud-3d-content')}>\n <PointCloud3DContext.Provider value={ptCloud3DCtx}>\n <PointCloud3DSideBar />\n </PointCloud3DContext.Provider>\n <div className={getClassName('point-cloud-3d-view')} id={pointCloudID} ref={ref} />\n </div>\n </PointCloudContainer>\n );\n};\n\nexport default connect(aMapStateToProps, null, null, { context: LabelBeeContext })(PointCloud3D);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAM,YAAe,GAAA,qBAAA,CAAA;AACrB,MAAM,mBAAA,GAAsB,MAAM,aAI/B,CAAA;AAAA,EACD,QAAU,EAAA,KAAA;AAAA,EACV,iBAAiB,MAAM;AAAA,GAAA;AAAA,EACvB,aAAa,MAAM;AAAA,GAAA;AAAA,CAAA,CAAA,CAAA;AAGrB,MAAM,qBAAqB,CAAC;AAAA,EAC1B,eAAA;AAAA,CAGI,KAAA;AACJ,EAAM,MAAA,CAAE,QAAU,EAAA,eAAA,CAAA,GAAoB,UAAW,CAAA,mBAAA,CAAA,CAAA;AAEjD,EAAM,MAAA,wBAAA,GAA2B,CAAC,QAAqB,KAAA;AACrD,IAAA,OAAO,UAAW,CAAA;AAAA,MACf,CAAA,YAAA,CAAa,uB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AA,CAAA;AAAA,GAC3B,kBAAA,KAAA,CAAA,aAAA,CAAC,oBAAoB,QAArB,EAAA;AAAA,IAA8B,KAAO,EAAA,YAAA;AAAA,GAAA,kBAClC,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAD,IAEF,CAAA,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAD,EAAA;AAAA,IAAK,WAAW,YAAa,CAAA,qBAAA,CAAA;AAAA,IAAwB,EAAI,EAAA,YAAA;AAAA,IAAc,GAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAM/E,uBAAe,QAAQ,gBAAkB,EAAA,IAAA,EAAM,IAAM,EAAA,CAAE,SAAS,eAAmB,CAAA,CAAA,CAAA,YAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"PointCloud3DView.js","sources":["../../../src/components/pointCloudView/PointCloud3DView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-13 19:31:36\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-06-27 19:43:25\n */\n\nimport { getClassName } from '@/utils/dom';\nimport { PointCloud } from '@labelbee/lb-annotation';\nimport {\n EPerspectiveView,\n IPointCloudBox,\n PointCloudUtils,\n toolStyleConverter,\n} from '@labelbee/lb-utils';\nimport classNames from 'classnames';\nimport React, { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport { PointCloudContext } from './PointCloudContext';\nimport { a2MapStateToProps, IA2MapStateProps } from '@/store/annotation/map';\nimport { connect } from 'react-redux';\nimport { jsonParser } from '@/utils';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { Switch } from 'antd';\nimport useSize from '@/hooks/useSize';\nimport { usePointCloudViews } from './hooks/usePointCloudViews';\nimport { useTranslation } from 'react-i18next';\nimport { LabelBeeContext } from '@/store/ctx';\n\nconst pointCloudID = 'LABELBEE-POINTCLOUD';\nconst PointCloud3DContext = React.createContext<{\n isActive: boolean;\n setTarget3DView: (perspectiveView: EPerspectiveView) => void;\n reset3DView: () => void;\n}>({\n isActive: false,\n setTarget3DView: () => {},\n reset3DView: () => {},\n});\n\nconst PointCloudViewIcon = ({\n perspectiveView,\n}: {\n perspectiveView: keyof typeof EPerspectiveView;\n}) => {\n const { isActive, setTarget3DView } = useContext(PointCloud3DContext);\n\n const getTarget3DViewClassName = (position: string) => {\n return classNames({\n [getClassName('point-cloud-3d-view', position)]: true,\n active: isActive,\n });\n };\n\n return (\n <span\n onClick={() => {\n setTarget3DView(EPerspectiveView[perspectiveView]);\n }}\n className={getTarget3DViewClassName(perspectiveView.toLocaleLowerCase())}\n />\n );\n};\n\nconst PointCloud3DSideBar = () => {\n const { reset3DView } = useContext(PointCloud3DContext);\n return (\n <div className={getClassName('point-cloud-3d-sidebar')}>\n <PointCloudViewIcon perspectiveView='Top' />\n <PointCloudViewIcon perspectiveView='Front' />\n <PointCloudViewIcon perspectiveView='Left' />\n <PointCloudViewIcon perspectiveView='Back' />\n <PointCloudViewIcon perspectiveView='Right' />\n <PointCloudViewIcon perspectiveView='LFT' />\n <PointCloudViewIcon perspectiveView='RBT' />\n <span\n onClick={() => {\n reset3DView();\n }}\n className={getClassName('point-cloud-3d-view', 'reset')}\n />\n </div>\n );\n};\n\nconst PointCloud3D: React.FC<IA2MapStateProps> = ({ currentData, config }) => {\n const ptCtx = useContext(PointCloudContext);\n const [showDirection, setShowDirection] = useState(true);\n const ref = useRef<HTMLDivElement>(null);\n const { initPointCloud3d } = usePointCloudViews();\n const size = useSize(ref);\n const { t } = useTranslation();\n\n useEffect(() => {\n if (!ptCtx.mainViewInstance) {\n return;\n }\n initPointCloud3d?.();\n }, [size]);\n const { selectedBox } = useSingleBox();\n\n const setTarget3DView = (perspectiveView: EPerspectiveView) => {\n const box = selectedBox?.info;\n\n if (box) {\n ptCtx.mainViewInstance?.updateCameraByBox(box, perspectiveView);\n }\n };\n\n const reset3DView = () => {\n ptCtx.mainViewInstance?.resetCamera();\n };\n\n useEffect(() => {\n if (ref.current && currentData?.url) {\n let pointCloud = ptCtx.mainViewInstance;\n if (!pointCloud) {\n pointCloud = new PointCloud({\n container: ref.current,\n backgroundColor: '#4c4c4c',\n config,\n });\n }\n\n if (currentData.result) {\n const boxParamsList = PointCloudUtils.getBoxParamsFromResultList(currentData.result);\n\n // Add Init Box\n boxParamsList.forEach((v: IPointCloudBox) => {\n const hex = toolStyleConverter.getColorFromConfig(\n { attribute: v.attribute },\n { ...config, attributeConfigurable: true },\n {},\n )?.hex;\n\n pointCloud?.generateBox(v, hex);\n });\n\n ptCtx.setPointCloudResult(boxParamsList);\n ptCtx.setPointCloudValid(jsonParser(currentData.result)?.valid);\n }\n\n ptCtx.setMainViewInstance(pointCloud);\n }\n }, [currentData]);\n\n /**\n * Observe selectedID and reset camera to target top-view\n */\n useEffect(() => {\n if (selectedBox) {\n setTarget3DView(EPerspectiveView.Top);\n }\n }, [selectedBox]);\n\n const ptCloud3DCtx = useMemo(() => {\n return { reset3DView, setTarget3DView, isActive: !!selectedBox };\n }, [selectedBox]);\n\n const PointCloud3DTitle = (\n <div>\n <span style={{ marginRight: 8 }}>{t('ShowArrows')}</span>\n <Switch\n size='small'\n checked={showDirection}\n onChange={(showDirection) => {\n setShowDirection(showDirection);\n ptCtx.mainViewInstance?.setShowDirection(showDirection);\n }}\n />\n </div>\n );\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-3d-container')}\n title={t('3DView')}\n toolbar={PointCloud3DTitle}\n style={{\n height:\n currentData.mappingImgList && currentData.mappingImgList?.length > 0 ? '55%' : '100%',\n }}\n >\n <div className={getClassName('point-cloud-3d-content')}>\n <PointCloud3DContext.Provider value={ptCloud3DCtx}>\n <PointCloud3DSideBar />\n </PointCloud3DContext.Provider>\n <div className={getClassName('point-cloud-3d-view')} id={pointCloudID} ref={ref} />\n </div>\n </PointCloudContainer>\n );\n};\n\nexport default connect(a2MapStateToProps, null, null, { context: L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CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAM/E,uBAAe,QAAQ,iBAAmB,EAAA,IAAA,EAAM,IAAM,EAAA,CAAE,SAAS,eAAmB,CAAA,CAAA,CAAA,YAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudAnnotation as
|
|
1
|
+
import{PointCloudAnnotation as M,MathUtils as f}from"@labelbee/lb-annotation";import{getClassName as x}from"../../utils/dom.js";import{PointCloudContainer as X}from"./PointCloudLayout.js";import u,{useRef as A,useEffect as C}from"react";import{PointCloudContext as D}from"./PointCloudContext.js";import{useSingleBox as T}from"./hooks/useSingleBox.js";import{EPerspectiveView as W}from"@labelbee/lb-utils";import{SizeInfoForView as H}from"./PointCloudInfos.js";import{connect as Y}from"react-redux";import{a2MapStateToProps as F}from"../../store/annotation/map.js";import{synchronizeTopView as R,synchronizeSideView as U}from"./hooks/usePointCloudViews.js";import Z from"../../hooks/useSize.js";import q from"./components/EmptyPage/index.js";import{useTranslation as G}from"react-i18next";import{LabelBeeContext as J}from"../../store/ctx.js";var K=Object.defineProperty,Q=Object.defineProperties,$=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable,_=(o,t,e)=>t in o?K(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,oe=(o,t)=>{for(var e in t||(t={}))ee.call(t,e)&&_(o,e,t[e]);if(O)for(var e of O(t))te.call(t,e)&&_(o,e,t[e]);return o},ne=(o,t)=>Q(o,$(t));const ie=(o,t,e=1)=>{const{width:i,height:n}=t,c={x:o.x+i*e/2,y:o.y+n*e/2},d={x:t.width/2,y:t.height/2};return{offsetX:(d.x-c.x)/e,offsetY:-(d.y-c.y)/e}},I=(o,t,e,i,n)=>{const{offsetX:c,offsetY:d}=ie(o,e,t);if(n.camera.zoom=t,o){const g=Math.cos(i.rotation),s=Math.sin(i.rotation),l=c*g,a=c*s,{x:p,y:m,z:P}=n.initCameraPosition;n.camera.position.set(p+a,m-l,P+d)}n.camera.updateProjectionMatrix(),n.render()},re=({currentData:o,config:t})=>{const e=u.useContext(D),i=A(null),n=Z(i),{updateSelectedBox:c,selectedBox:d}=T(),{t:g}=G();return C(()=>{if(i.current){const s={width:i.current.clientWidth,height:i.current.clientHeight},l=new M({container:i.current,size:s,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0},config:t});e.setBackViewInstance(l)}},[]),C(()=>{if(!n||!e.backViewInstance)return;const{pointCloud2dOperation:s,pointCloudInstance:l}=e.backViewInstance;s.singleOn("renderZoom",(a,p)=>{!e.selectedPointCloudBox||I(p,a,n,e.selectedPointCloudBox,l)}),s.singleOn("dragMove",({currentPos:a,zoom:p})=>{!e.selectedPointCloudBox||I(a,p,n,e.selectedPointCloudBox,l)}),s.singleOn("updatePolygonByDrag",({newPolygon:a,originPolygon:p})=>{if(!e.selectedPointCloudBox||!e.mainViewInstance||!o.url)return;const[m,P,y]=a.pointList,[v,V,B]=p.pointList,w=f.getLineCenterPoint([m,y]),h=f.getLineCenterPoint([v,B]),b={x:{x:w.x-h.x,y:w.y-h.y}.x,y:0,z:w.y-h.y},L=f.getLineLength(m,P),j=f.getLineLength(v,V),S=L-j,E=f.getLineLength(P,y),k=f.getLineLength(V,B),z=E-k;let{newBoxParams:r}=l.getNewBoxByBackUpdate(b,z,S,e.selectedPointCloudBox);if(e.mainViewInstance){const{count:N}=e.mainViewInstance.getSensesPointZAxisInPolygon(e.mainViewInstance.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=ne(oe({},r),{count:N})}R(r,a,e.topViewInstance,e.mainViewInstance),U(r,a,e.sideViewInstance,o.url),e.mainViewInstance.highlightOriginPointCloud(r),c(r)})},[e,n]),C(()=>{var s;(s=e==null?void 0:e.backViewInstance)==null||s.initSize(n)},[n]),u.createElement(X,{className:x("point-cloud-container","back-view"),title:g("BackView"),toolbar:u.createElement(H,{perspectiveView:W.Back})},u.createElement("div",{className:x("point-cloud-container","bottom-view-content")},u.createElement("div",{className:x("point-cloud-container","core-instance"),ref:i}),!d&&u.createElement(q,null)))};var se=Y(F,null,null,{context:J})(re);export{se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PointCloudBackView.js","sources":["../../../src/components/pointCloudView/PointCloudBackView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-22 11:08:31\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-07-08 11:08:02\n */\nimport { PointCloud, MathUtils, PointCloudAnnotation } from '@labelbee/lb-annotation';\nimport { getClassName } from '@/utils/dom';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport React, { useEffect, useRef } from 'react';\nimport { PointCloudContext } from './PointCloudContext';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { EPerspectiveView, IPointCloudBox, IPolygonPoint } from '@labelbee/lb-utils';\nimport { SizeInfoForView } from './PointCloudInfos';\nimport { connect } from 'react-redux';\nimport { aMapStateToProps, IAnnotationStateProps } from '@/store/annotation/map';\nimport { synchronizeSideView, synchronizeTopView } from './hooks/usePointCloudViews';\nimport useSize from '@/hooks/useSize';\nimport EmptyPage from './components/EmptyPage';\nimport { useTranslation } from 'react-i18next';\nimport { LabelBeeContext } from '@/store/ctx';\n\n/**\n * 统一一下,将其拓展为 二维转换为 三维坐标的转换\n * Get the offset from canvas2d-coordinate to world coordinate\n * @param currentPos\n * @param size\n * @param zoom\n * @returns\n */\nconst TransferCanvas2WorldOffset = (\n currentPos: { x: number; y: number },\n size: { width: number; height: number },\n zoom = 1,\n) => {\n const { width: w, height: h } = size;\n\n const canvasCenterPoint = {\n x: currentPos.x + (w * zoom) / 2,\n y: currentPos.y + (h * zoom) / 2,\n };\n\n const worldCenterPoint = {\n x: size.width / 2,\n y: size.height / 2,\n };\n\n return {\n offsetX: (worldCenterPoint.x - canvasCenterPoint.x) / zoom,\n offsetY: -(worldCenterPoint.y - canvasCenterPoint.y) / zoom,\n };\n};\nconst updateBackViewByCanvas2D = (\n currentPos: { x: number; y: number },\n zoom: number,\n size: { width: number; height: number },\n selectedPointCloudBox: IPointCloudBox,\n backPointCloud: PointCloud,\n) => {\n const { offsetX, offsetY } = TransferCanvas2WorldOffset(currentPos, size, zoom);\n backPointCloud.camera.zoom = zoom;\n if (currentPos) {\n const cos = Math.cos(selectedPointCloudBox.rotation);\n const sin = Math.sin(selectedPointCloudBox.rotation);\n const offsetXX = offsetX * cos;\n const offsetXY = offsetX * sin;\n const { x, y, z } = backPointCloud.initCameraPosition;\n backPointCloud.camera.position.set(x + offsetXY, y - offsetXX, z + offsetY);\n }\n backPointCloud.camera.updateProjectionMatrix();\n backPointCloud.render();\n};\n\nconst PointCloudSideView = ({ currentData }: IAnnotationStateProps) => {\n const ptCtx = React.useContext(PointCloudContext);\n const ref = useRef<HTMLDivElement>(null);\n const size = useSize(ref);\n const { updateSelectedBox, selectedBox } = useSingleBox();\n const { t } = useTranslation();\n\n useEffect(() => {\n if (ref.current) {\n const size = {\n width: ref.current.clientWidth,\n height: ref.current.clientHeight,\n };\n\n const pointCloudAnnotation = new PointCloudAnnotation({\n container: ref.current,\n size,\n polygonOperationProps: { showDirectionLine: false, forbidAddNew: true },\n });\n ptCtx.setBackViewInstance(pointCloudAnnotation);\n }\n }, []);\n\n useEffect(() => {\n // By the way as an initialization judgment\n if (!size || !ptCtx.backViewInstance) {\n return;\n }\n\n const {\n pointCloud2dOperation: backPointCloudPolygonOperation,\n pointCloudInstance: backPointCloud,\n } = ptCtx.backViewInstance;\n\n /**\n * Synchronized 3d point cloud view displacement operations\n *\n * Change Orthographic Camera size\n */\n backPointCloudPolygonOperation.singleOn('renderZoom', (zoom: number, currentPos: any) => {\n if (!ptCtx.selectedPointCloudBox) {\n return;\n }\n updateBackViewByCanvas2D(currentPos, zoom, size, ptCtx.selectedPointCloudBox, backPointCloud);\n });\n\n // Synchronized 3d point cloud view displacement operations\n backPointCloudPolygonOperation.singleOn('dragMove', ({ currentPos, zoom }: any) => {\n if (!ptCtx.selectedPointCloudBox) {\n return;\n }\n updateBackViewByCanvas2D(currentPos, zoom, size, ptCtx.selectedPointCloudBox, backPointCloud);\n });\n\n backPointCloudPolygonOperation.singleOn(\n 'updatePolygonByDrag',\n ({ newPolygon, originPolygon }: any) => {\n if (!ptCtx.selectedPointCloudBox || !ptCtx.mainViewInstance || !currentData.url) {\n return;\n }\n\n // Notice. The sort of polygon is important.\n const [point1, point2, point3] = newPolygon.pointList;\n const [op1, op2, op3] = originPolygon.pointList;\n\n // 2D centerPoint => 3D x & z\n const newCenterPoint = MathUtils.getLineCenterPoint([point1, point3]);\n const oldCenterPoint = MathUtils.getLineCenterPoint([op1, op3]);\n\n const offset = {\n x: newCenterPoint.x - oldCenterPoint.x,\n y: newCenterPoint.y - oldCenterPoint.y,\n };\n\n const offsetCenterPoint = {\n x: offset.x,\n y: 0, // Not be used.\n z: newCenterPoint.y - oldCenterPoint.y,\n };\n\n // 2D height => 3D depth\n const height = MathUtils.getLineLength(point1, point2);\n const oldHeight = MathUtils.getLineLength(op1, op2);\n const offsetHeight = height - oldHeight; // 3D depth\n\n // 2D width => 3D width\n const width = MathUtils.getLineLength(point2, point3);\n const oldWidth = MathUtils.getLineLength(op2, op3);\n const offsetWidth = width - oldWidth; // 3D width\n\n let { newBoxParams } = backPointCloud.getNewBoxByBackUpdate(\n offsetCenterPoint,\n offsetWidth,\n offsetHeight,\n ptCtx.selectedPointCloudBox,\n );\n\n // Update count\n if (ptCtx.mainViewInstance) {\n const { count } = ptCtx.mainViewInstance.getSensesPointZAxisInPolygon(\n ptCtx.mainViewInstance.getCuboidFromPointCloudBox(newBoxParams)\n .polygonPointList as IPolygonPoint[],\n [\n newBoxParams.center.z - newBoxParams.depth / 2,\n newBoxParams.center.z + newBoxParams.depth / 2,\n ],\n );\n\n newBoxParams = {\n ...newBoxParams,\n count,\n };\n }\n\n synchronizeTopView(newBoxParams, newPolygon, ptCtx.topViewInstance, ptCtx.mainViewInstance);\n synchronizeSideView(newBoxParams, newPolygon, ptCtx.sideViewInstance, currentData.url);\n ptCtx.mainViewInstance.highlightOriginPointCloud(newBoxParams);\n updateSelectedBox(newBoxParams);\n },\n );\n }, [ptCtx, size]);\n\n useEffect(() => {\n // Update Size\n ptCtx?.backViewInstance?.initSize(size);\n }, [size]);\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-container', 'back-view')}\n title={t('BackView')}\n toolbar={<SizeInfoForView perspectiveView={EPerspectiveView.Back} />}\n >\n <div className={getClassName('point-cloud-container', 'bottom-view-content')}>\n <div className={getClassName('point-cloud-container', 'core-instance')} ref={ref} />\n {!selectedBox && <EmptyPage />}\n </div>\n </PointCloudContainer>\n );\n};\n\nexport default connect(aMapStateToProps, null, null, { context: LabelBeeContext })(\n PointCloudSideView,\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,0BAA6B,GAAA,CACjC,UACA,EAAA,IAAA,EACA,OAAO,CACJ,KAAA;AACH,EAAA,MAAM,CAAE,KAAA,EAAO,CAAG,EAAA,MAAA,EAAQ,CAAM,CAAA,GAAA,IAAA,CAAA;AAEhC,EAAA,MAAM,iBAAoB,GAAA;AAAA,IACxB,CAAG,EAAA,UAAA,CAAW,CAAK,GAAA,CAAA,GAAI,IAAQ,GAAA,CAAA;AAAA,IAC/B,CAAG,EAAA,UAAA,CAAW,CAAK,GAAA,CAAA,GAAI,IAAQ,GAAA,CAAA;AAAA,GAAA,CAAA;AAGjC,EAAA,MAAM,gBAAmB,GAAA;AAAA,IACvB,CAAA,EAAG,KAAK,KAAQ,GAAA,CAAA;AAAA,IAChB,CAAA,EAAG,KAAK,MAAS,GAAA,CAAA;AAAA,GAAA,CAAA;AAGnB,EAAO,OAAA;AAAA,IACL,OAAU,EAAA,CAAA,gBAAA,CAAiB,CAAI,GAAA,iBAAA,CAAk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View/PointCloudBackView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-22 11:08:31\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-07-08 11:08:02\n */\nimport { PointCloud, MathUtils, PointCloudAnnotation } from '@labelbee/lb-annotation';\nimport { getClassName } from '@/utils/dom';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport React, { useEffect, useRef } from 'react';\nimport { PointCloudContext } from './PointCloudContext';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { EPerspectiveView, IPointCloudBox, IPolygonPoint } from '@labelbee/lb-utils';\nimport { SizeInfoForView } from './PointCloudInfos';\nimport { connect } from 'react-redux';\nimport { a2MapStateToProps, IA2MapStateProps } from '@/store/annotation/map';\nimport { synchronizeSideView, synchronizeTopView } from './hooks/usePointCloudViews';\nimport useSize from '@/hooks/useSize';\nimport EmptyPage from './components/EmptyPage';\nimport { useTranslation } from 'react-i18next';\nimport { LabelBeeContext } from '@/store/ctx';\n\n/**\n * 统一一下,将其拓展为 二维转换为 三维坐标的转换\n * Get the offset from canvas2d-coordinate to world coordinate\n * @param currentPos\n * @param size\n * @param zoom\n * @returns\n */\nconst TransferCanvas2WorldOffset = (\n currentPos: { x: number; y: number },\n size: { width: number; height: number },\n zoom = 1,\n) => {\n const { width: w, height: h } = size;\n\n const canvasCenterPoint = {\n x: currentPos.x + (w * zoom) / 2,\n y: currentPos.y + (h * zoom) / 2,\n };\n\n const worldCenterPoint = {\n x: size.width / 2,\n y: size.height / 2,\n };\n\n return {\n offsetX: (worldCenterPoint.x - canvasCenterPoint.x) / zoom,\n offsetY: -(worldCenterPoint.y - canvasCenterPoint.y) / zoom,\n };\n};\nconst updateBackViewByCanvas2D = (\n currentPos: { x: number; y: number },\n zoom: number,\n size: { width: number; height: number },\n selectedPointCloudBox: IPointCloudBox,\n backPointCloud: PointCloud,\n) => {\n const { offsetX, offsetY } = TransferCanvas2WorldOffset(currentPos, size, zoom);\n backPointCloud.camera.zoom = zoom;\n if (currentPos) {\n const cos = Math.cos(selectedPointCloudBox.rotation);\n const sin = Math.sin(selectedPointCloudBox.rotation);\n const offsetXX = offsetX * cos;\n const offsetXY = offsetX * sin;\n const { x, y, z } = backPointCloud.initCameraPosition;\n backPointCloud.camera.position.set(x + offsetXY, y - offsetXX, z + offsetY);\n }\n backPointCloud.camera.updateProjectionMatrix();\n backPointCloud.render();\n};\n\nconst PointCloudSideView = ({ currentData, config }: IA2MapStateProps) => {\n const ptCtx = React.useContext(PointCloudContext);\n const ref = useRef<HTMLDivElement>(null);\n const size = useSize(ref);\n const { updateSelectedBox, selectedBox } = useSingleBox();\n const { t } = useTranslation();\n\n useEffect(() => {\n if (ref.current) {\n const size = {\n width: ref.current.clientWidth,\n height: ref.current.clientHeight,\n };\n\n const pointCloudAnnotation = new PointCloudAnnotation({\n container: ref.current,\n size,\n polygonOperationProps: { showDirectionLine: false, forbidAddNew: true },\n config,\n });\n ptCtx.setBackViewInstance(pointCloudAnnotation);\n }\n }, []);\n\n useEffect(() => {\n // By the way as an initialization judgment\n if (!size || !ptCtx.backViewInstance) {\n return;\n }\n\n const {\n pointCloud2dOperation: backPointCloudPolygonOperation,\n pointCloudInstance: backPointCloud,\n } = ptCtx.backViewInstance;\n\n /**\n * Synchronized 3d point cloud view displacement operations\n *\n * Change Orthographic Camera size\n */\n backPointCloudPolygonOperation.singleOn('renderZoom', (zoom: number, currentPos: any) => {\n if (!ptCtx.selectedPointCloudBox) {\n return;\n }\n updateBackViewByCanvas2D(currentPos, zoom, size, ptCtx.selectedPointCloudBox, backPointCloud);\n });\n\n // Synchronized 3d point cloud view displacement operations\n backPointCloudPolygonOperation.singleOn('dragMove', ({ currentPos, zoom }: any) => {\n if (!ptCtx.selectedPointCloudBox) {\n return;\n }\n updateBackViewByCanvas2D(currentPos, zoom, size, ptCtx.selectedPointCloudBox, backPointCloud);\n });\n\n backPointCloudPolygonOperation.singleOn(\n 'updatePolygonByDrag',\n ({ newPolygon, originPolygon }: any) => {\n if (!ptCtx.selectedPointCloudBox || !ptCtx.mainViewInstance || !currentData.url) {\n return;\n }\n\n // Notice. The sort of polygon is important.\n const [point1, point2, point3] = newPolygon.pointList;\n const [op1, op2, op3] = originPolygon.pointList;\n\n // 2D centerPoint => 3D x & z\n const newCenterPoint = MathUtils.getLineCenterPoint([point1, point3]);\n const oldCenterPoint = MathUtils.getLineCenterPoint([op1, op3]);\n\n const offset = {\n x: newCenterPoint.x - oldCenterPoint.x,\n y: newCenterPoint.y - oldCenterPoint.y,\n };\n\n const offsetCenterPoint = {\n x: offset.x,\n y: 0, // Not be used.\n z: newCenterPoint.y - oldCenterPoint.y,\n };\n\n // 2D height => 3D depth\n const height = MathUtils.getLineLength(point1, point2);\n const oldHeight = MathUtils.getLineLength(op1, op2);\n const offsetHeight = height - oldHeight; // 3D depth\n\n // 2D width => 3D width\n const width = MathUtils.getLineLength(point2, point3);\n const oldWidth = MathUtils.getLineLength(op2, op3);\n const offsetWidth = width - oldWidth; // 3D width\n\n let { newBoxParams } = backPointCloud.getNewBoxByBackUpdate(\n offsetCenterPoint,\n offsetWidth,\n offsetHeight,\n ptCtx.selectedPointCloudBox,\n );\n\n // Update count\n if (ptCtx.mainViewInstance) {\n const { count } = ptCtx.mainViewInstance.getSensesPointZAxisInPolygon(\n ptCtx.mainViewInstance.getCuboidFromPointCloudBox(newBoxParams)\n .polygonPointList as IPolygonPoint[],\n [\n newBoxParams.center.z - newBoxParams.depth / 2,\n newBoxParams.center.z + newBoxParams.depth / 2,\n ],\n );\n\n newBoxParams = {\n ...newBoxParams,\n count,\n };\n }\n\n synchronizeTopView(newBoxParams, newPolygon, ptCtx.topViewInstance, ptCtx.mainViewInstance);\n synchronizeSideView(newBoxParams, newPolygon, ptCtx.sideViewInstance, currentData.url);\n ptCtx.mainViewInstance.highlightOriginPointCloud(newBoxParams);\n updateSelectedBox(newBoxParams);\n },\n );\n }, [ptCtx, size]);\n\n useEffect(() => {\n // Update Size\n ptCtx?.backViewInstance?.initSize(size);\n }, [size]);\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-container', 'back-view')}\n title={t('BackView')}\n toolbar={<SizeInfoForView perspectiveView={EPerspectiveView.Back} />}\n >\n <div className={getClassName('point-cloud-container', 'bottom-view-content')}>\n <div className={getClassName('point-cloud-container', 'core-instance')} ref={ref} />\n {!selectedBox && <EmptyPage />}\n </div>\n </PointCloudContainer>\n );\n};\n\nexport default connect(a2MapStateToProps, null, null, { context: LabelBeeContext })(\n PointCloudSideView,\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,0BAA6B,GAAA,CACjC,UACA,EAAA,IAAA,EACA,OAAO,CACJ,KAAA;AACH,EAAA,MAAM,CAAE,KAAA,EAAO,CAAG,EAAA,MAAA,EAAQ,CAAM,CAAA,GAAA,IAAA,CAAA;AAEhC,EAAA,MAAM,iBAAoB,GAAA;AAAA,IACxB,CAAG,EAAA,UAAA,CAAW,CAAK,GAAA,CAAA,GAAI,IAAQ,GAAA,CAAA;AAAA,IAC/B,CAAG,EAAA,UAAA,CAAW,CAAK,GAAA,CAAA,GAAI,IAAQ,GAAA,CAAA;AAAA,GAAA,CAAA;AAGjC,EAAA,MAAM,gBAAmB,GAAA;AAAA,IACvB,CAAA,EAAG,KAAK,KAAQ,GAAA,CAAA;AAAA,IAChB,CAAA,EAAG,KAAK,MAAS,GAAA,CAAA;AAAA,GAAA,CAAA;AAGnB,EAAO,OAAA;AAAA,IACL,OAAU,EAAA,CAAA,gBAAA,CAAiB,CAAI,GAAA,iBAAA,CAAkB,CAAK,IAAA,IAAA;AAAA,IACtD,OAAS,EAAA,EAAmB,gBAAA,CAAA,CAAA,GAAI,kBAAkB,CAAK,CAAA,GAAA,IAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAG3D,MAAM,2BAA2B,CAC/B,UAAA,EACA,IACA,EAAA,IAAA,EACA,uBACA,cACG,KAAA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AA;AAAA,GAAA,EAGrB,CAAC,KAAO,EAAA,IAAA,CAAA,CAAA,CAAA;AAEX,EAAA,SAAA,CAAU,MAAM;AApMlB,IAAA,IAAA,EAAA,CAAA;AAsMI,IAAO,CAAA,EAAA,GAAA,KAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,gBAAA,KAAP,mBAAyB,QAAS,CAAA,IAAA,CAAA,CAAA;AAAA,GAAA,EACjC,CAAC,IAAA,CAAA,CAAA,CAAA;AAEJ,EAAA,2CACG,mBAAD,EAAA;AAAA,IACE,SAAA,EAAW,aAAa,uBAAyB,EAAA,WAAA,CAAA;AAAA,IACjD,OAAO,CAAE,CAAA,UAAA,CAAA;AAAA,IACT,OAAA,sCAAU,eAAD,EAAA;AAAA,MAAiB,iBAAiB,gBAAiB,CAAA,IAAA;AAAA,KAAA,CAAA;AAAA,GAAA,sCAE3D,KAAD,EAAA;AAAA,IAAK,SAAA,EAAW,aAAa,uBAAyB,EAAA,qBAAA,CAAA;AAAA,GAAA,sCACnD,KAAD,EAAA;AAAA,IAAK,SAAA,EAAW,aAAa,uBAAyB,EAAA,eAAA,CAAA;AAAA,IAAkB,GAAA;AAAA,GACvE,CAAA,EAAA,CAAC,WAAe,oBAAA,KAAA,CAAA,aAAA,CAAC,SAAD,EAAA,IAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAMzB,yBAAe,QAAQ,iBAAmB,EAAA,IAAA,EAAM,IAAM,EAAA,CAAE,SAAS,eAC/D,CAAA,CAAA,CAAA,kBAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{ActionsHistory as C}from"@labelbee/lb-annotation";import f,{useState as t,useRef as M,useMemo as m}from"react";const p=f.createContext({pointCloudBoxList:[],polygonList:[],selectedID:"",selectedIDs:[],valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>{},setPolygonList:()=>{},zoom:1,setZoom:()=>{},history:new C}),z=({children:P})=>{const[n,c]=t([]),[l,x]=t([]),[o,i]=t([]),[a,y]=t(!0),[d,S]=t(1),[r,B]=t(),[u,A]=t(),[I,g]=t(),[w,v]=t(),L=M(new C).current,V=m(()=>o.length===1?o[0]:"",[o]),b=m(()=>{const D=n.find(e=>e.id===V),R=e=>{c(n.concat(e))},h=e=>{y(e!==!1)},s=e=>{e===void 0&&i([]),typeof e=="string"&&i([e]),Array.isArray(e)&&i(Array.from(new Set(e)))};return{selectedID:V,pointCloudBoxList:n,selectedIDs:o,setPointCloudResult:c,setSelectedIDs:s,addPointCloudBox:R,valid:a,selectedPointCloudBox:D,setPointCloudValid:h,addSelectedID:e=>{o.includes(e)?s(o.filter(k=>k!==e)):s([...o,e])},selectedAllBoxes:()=>{s(n.map(e=>e.id))},topViewInstance:r,setTopViewInstance:B,sideViewInstance:u,setSideViewInstance:A,backViewInstance:I,setBackViewInstance:g,mainViewInstance:w,setMainViewInstance:v,polygonList:l,setPolygonList:x,zoom:d,setZoom:S,history:L}},[a,o,n,l,r,u,I,w,d]);return f.createElement(p.Provider,{value:b},P)};export{p as PointCloudContext,z as PointCloudProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PointCloudContext.js","sources":["../../../src/components/pointCloudView/PointCloudContext.tsx"],"sourcesContent":["import { IPointCloudBox, IPointCloudBoxList, IPolygonData } from '@labelbee/lb-utils';\nimport { PointCloud, PointCloudAnnotation } from '@labelbee/lb-annotation';\nimport React, { useMemo, useState } from 'react';\n\ninterface IPointCloudContextInstances {\n topViewInstance?: PointCloudAnnotation;\n sideViewInstance?: PointCloudAnnotation;\n backViewInstance?: PointCloudAnnotation;\n mainViewInstance?: PointCloud;\n setTopViewInstance: (instance: PointCloudAnnotation) => void;\n setSideViewInstance: (instance: PointCloudAnnotation) => void;\n setBackViewInstance: (instance: PointCloudAnnotation) => void;\n setMainViewInstance: (instance: PointCloud) => void;\n}\n\nexport interface IPointCloudContext extends IPointCloudContextInstances {\n pointCloudBoxList: IPointCloudBoxList;\n selectedIDs: string[];\n setSelectedIDs: (ids?: string[] | string) => void;\n valid: boolean;\n setPointCloudResult: (resultList: IPointCloudBoxList) => void;\n selectedPointCloudBox?: IPointCloudBox;\n setPointCloudValid: (valid?: boolean) => void;\n addSelectedID: (selectedID: string) => void;\n selectedAllBoxes: () => void;\n selectedID: string;\n addPointCloudBox: (boxParams: IPointCloudBox) => void;\n\n polygonList: IPolygonData[];\n setPolygonList: (polygonList: IPolygonData[]) => void;\n\n zoom: number;\n setZoom: (zoom: number) => void;\n}\n\nexport const PointCloudContext = React.createContext<IPointCloudContext>({\n pointCloudBoxList: [],\n polygonList: [],\n selectedID: '',\n selectedIDs: [],\n valid: true,\n setSelectedIDs: () => {},\n setPointCloudResult: () => {},\n setPointCloudValid: () => {},\n setTopViewInstance: () => {},\n setSideViewInstance: () => {},\n setBackViewInstance: () => {},\n setMainViewInstance: () => {},\n addSelectedID: () => {},\n selectedAllBoxes: () => {},\n addPointCloudBox: () => {},\n setPolygonList: () => {},\n\n zoom: 1,\n setZoom: () => {},\n});\n\nexport const PointCloudProvider: React.FC<{}> = ({ children }) => {\n const [pointCloudBoxList, setPointCloudResult] = useState<IPointCloudBoxList>([]);\n const [polygonList, setPolygonList] = useState<IPolygonData[]>([]);\n const [selectedIDs, setSelectedIDsState] = useState<string[]>([]);\n const [valid, setValid] = useState<boolean>(true);\n const [zoom, setZoom] = useState<number>(1);\n const [topViewInstance, setTopViewInstance] = useState<PointCloudAnnotation>();\n const [sideViewInstance, setSideViewInstance] = useState<PointCloudAnnotation>();\n const [backViewInstance, setBackViewInstance] = useState<PointCloudAnnotation>();\n const [mainViewInstance, setMainViewInstance] = useState<PointCloud>();\n\n const selectedID = useMemo(() => {\n return selectedIDs.length === 1 ? selectedIDs[0] : '';\n }, [selectedIDs]);\n\n const ptCtx = useMemo(() => {\n const selectedPointCloudBox = pointCloudBoxList.find((v) => v.id === selectedID);\n\n const addPointCloudBox = (box: IPointCloudBox) => {\n setPointCloudResult(pointCloudBoxList.concat(box));\n };\n\n const setPointCloudValid = (valid?: boolean) => {\n setValid(valid === false ? false : true);\n };\n\n const setSelectedIDs = (selectedIDs?: string[] | string) => {\n if (selectedIDs === undefined) {\n setSelectedIDsState([]);\n }\n\n if (typeof selectedIDs === 'string') {\n setSelectedIDsState([selectedIDs]);\n }\n\n if (Array.isArray(selectedIDs)) {\n setSelectedIDsState(Array.from(new Set(selectedIDs)));\n }\n };\n\n /**\n * If selectedID existed, remove selectedID from selectedIDs\n * If selectedID not existed, add selectedID to selectedIDs\n * @param selectedID\n */\n const addSelectedID = (selectedID: string) => {\n if (selectedIDs.includes(selectedID)) {\n setSelectedIDs(selectedIDs.filter((i) => i !== selectedID));\n } else {\n setSelectedIDs([...selectedIDs, selectedID]);\n }\n };\n\n const selectedAllBoxes = () => {\n setSelectedIDs(pointCloudBoxList.map((i) => i.id));\n };\n\n return {\n selectedID,\n pointCloudBoxList,\n selectedIDs,\n setPointCloudResult,\n setSelectedIDs,\n addPointCloudBox,\n valid,\n selectedPointCloudBox,\n setPointCloudValid,\n addSelectedID,\n selectedAllBoxes,\n topViewInstance,\n setTopViewInstance,\n sideViewInstance,\n setSideViewInstance,\n backViewInstance,\n setBackViewInstance,\n mainViewInstance,\n setMainViewInstance,\n polygonList,\n setPolygonList,\n zoom,\n setZoom,\n };\n }, [\n valid,\n selectedIDs,\n pointCloudBoxList,\n polygonList,\n topViewInstance,\n sideViewInstance,\n backViewInstance,\n mainViewInstance,\n zoom,\n ]);\n\n return <PointCloudContext.Provider value={ptCtx}>{children}</PointCloudContext.Provider>;\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PointCloudContext.js","sources":["../../../src/components/pointCloudView/PointCloudContext.tsx"],"sourcesContent":["import { IPointCloudBox, IPointCloudBoxList, IPolygonData } from '@labelbee/lb-utils';\nimport { PointCloud, PointCloudAnnotation, ActionsHistory } from '@labelbee/lb-annotation';\nimport React, { useMemo, useRef, useState } from 'react';\n\ninterface IPointCloudContextInstances {\n topViewInstance?: PointCloudAnnotation;\n sideViewInstance?: PointCloudAnnotation;\n backViewInstance?: PointCloudAnnotation;\n mainViewInstance?: PointCloud;\n setTopViewInstance: (instance: PointCloudAnnotation) => void;\n setSideViewInstance: (instance: PointCloudAnnotation) => void;\n setBackViewInstance: (instance: PointCloudAnnotation) => void;\n setMainViewInstance: (instance: PointCloud) => void;\n}\n\nexport interface IPointCloudContext extends IPointCloudContextInstances {\n pointCloudBoxList: IPointCloudBoxList;\n selectedIDs: string[];\n setSelectedIDs: (ids?: string[] | string) => void;\n valid: boolean;\n setPointCloudResult: (resultList: IPointCloudBoxList) => void;\n selectedPointCloudBox?: IPointCloudBox;\n setPointCloudValid: (valid?: boolean) => void;\n addSelectedID: (selectedID: string) => void;\n selectedAllBoxes: () => void;\n selectedID: string;\n addPointCloudBox: (boxParams: IPointCloudBox) => void;\n\n polygonList: IPolygonData[];\n setPolygonList: (polygonList: IPolygonData[]) => void;\n\n zoom: number;\n setZoom: (zoom: number) => void;\n\n history: ActionsHistory; // Operation History\n}\n\nexport const PointCloudContext = React.createContext<IPointCloudContext>({\n pointCloudBoxList: [],\n polygonList: [],\n selectedID: '',\n selectedIDs: [],\n valid: true,\n setSelectedIDs: () => {},\n setPointCloudResult: () => {},\n setPointCloudValid: () => {},\n setTopViewInstance: () => {},\n setSideViewInstance: () => {},\n setBackViewInstance: () => {},\n setMainViewInstance: () => {},\n addSelectedID: () => {},\n selectedAllBoxes: () => {},\n addPointCloudBox: () => {},\n setPolygonList: () => {},\n\n zoom: 1,\n setZoom: () => {},\n history: new ActionsHistory(),\n});\n\nexport const PointCloudProvider: React.FC<{}> = ({ children }) => {\n const [pointCloudBoxList, setPointCloudResult] = useState<IPointCloudBoxList>([]);\n const [polygonList, setPolygonList] = useState<IPolygonData[]>([]);\n const [selectedIDs, setSelectedIDsState] = useState<string[]>([]);\n const [valid, setValid] = useState<boolean>(true);\n const [zoom, setZoom] = useState<number>(1);\n const [topViewInstance, setTopViewInstance] = useState<PointCloudAnnotation>();\n const [sideViewInstance, setSideViewInstance] = useState<PointCloudAnnotation>();\n const [backViewInstance, setBackViewInstance] = useState<PointCloudAnnotation>();\n const [mainViewInstance, setMainViewInstance] = useState<PointCloud>();\n const history = useRef(new ActionsHistory()).current;\n\n const selectedID = useMemo(() => {\n return selectedIDs.length === 1 ? selectedIDs[0] : '';\n }, [selectedIDs]);\n\n const ptCtx = useMemo(() => {\n const selectedPointCloudBox = pointCloudBoxList.find((v) => v.id === selectedID);\n\n const addPointCloudBox = (box: IPointCloudBox) => {\n setPointCloudResult(pointCloudBoxList.concat(box));\n };\n\n const setPointCloudValid = (valid?: boolean) => {\n setValid(valid === false ? false : true);\n };\n\n const setSelectedIDs = (selectedIDs?: string[] | string) => {\n if (selectedIDs === undefined) {\n setSelectedIDsState([]);\n }\n\n if (typeof selectedIDs === 'string') {\n setSelectedIDsState([selectedIDs]);\n }\n\n if (Array.isArray(selectedIDs)) {\n setSelectedIDsState(Array.from(new Set(selectedIDs)));\n }\n };\n\n /**\n * If selectedID existed, remove selectedID from selectedIDs\n * If selectedID not existed, add selectedID to selectedIDs\n * @param selectedID\n */\n const addSelectedID = (selectedID: string) => {\n if (selectedIDs.includes(selectedID)) {\n setSelectedIDs(selectedIDs.filter((i) => i !== selectedID));\n } else {\n setSelectedIDs([...selectedIDs, selectedID]);\n }\n };\n\n const selectedAllBoxes = () => {\n setSelectedIDs(pointCloudBoxList.map((i) => i.id));\n };\n\n return {\n selectedID,\n pointCloudBoxList,\n selectedIDs,\n setPointCloudResult,\n setSelectedIDs,\n addPointCloudBox,\n valid,\n selectedPointCloudBox,\n setPointCloudValid,\n addSelectedID,\n selectedAllBoxes,\n topViewInstance,\n setTopViewInstance,\n sideViewInstance,\n setSideViewInstance,\n backViewInstance,\n setBackViewInstance,\n mainViewInstance,\n setMainViewInstance,\n polygonList,\n setPolygonList,\n zoom,\n setZoom,\n history,\n };\n }, [\n valid,\n selectedIDs,\n pointCloudBoxList,\n polygonList,\n topViewInstance,\n sideViewInstance,\n backViewInstance,\n mainViewInstance,\n zoom,\n ]);\n\n return <PointCloudContext.Provider value={ptCtx}>{children}</PointCloudContext.Provider>;\n};\n"],"names":[],"mappings":";;;AAqCa,MAAA,iBAAA,GAAoB,MAAM,aAAkC,CAAA;AAAA,EACvE,iBAAmB,EAAA,EAAA;AAAA,EACnB,WAAa,EAAA,EAAA;AAAA,EACb,UAAY,EAAA,EAAA;AAAA,EACZ,WAAa,EAAA,EAAA;AAAA,EACb,KAAO,EAAA,IAAA;AAAA,EACP,gBAAgB,MAAM;AAAA,GAAA;AAAA,EACtB,qBAAqB,MAAM;AAAA,GAAA;AAAA,EAC3B,oBAAoB,MAAM;AAAA,GAAA;AAAA,EAC1B,oBAAoB,MAAM;AAAA,GAAA;AAAA,EAC1B,qBAAqB,MAAM;AAAA,GAAA;AAAA,EAC3B,qBAAqB,MAAM;AAAA,GAAA;AAAA,EAC3B,qBAAqB,MAAM;AAAA,GAAA;AAAA,EAC3B,eAAe,MAAM;AAAA,GAAA;AAAA,EACrB,kBAAkB,MAAM;AAAA,GAAA;AAAA,EACxB,kBAAkB,MAAM;AAAA,GAAA;AAAA,EACxB,gBAAgB,MAAM;AAAA,GAAA;AAAA,EAEtB,IAAM,EAAA,CAAA;AAAA,EACN,SAAS,MAAM;AAAA,GAAA;AAAA,EACf,SAAS,IAAI,cAAA,EAAA;AAAA,CAAA,EAAA;AAGF,MAAA,kBAAA,GAAmC,CAAC,CAAE,QAAe,CAAA,KAAA;AAChE,EAAM,MAAA,CAAC,iBAAmB,EAAA,mBAAA,CAAA,GAAuB,QAA6B,CAAA,EAAA,CAAA,CAAA;AAC9E,EAAM,MAAA,CAAC,WAAa,EAAA,cAAA,CAAA,GAAkB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AAA;AAAA,MACA,kBAAA;AAAA,MACA,gBAAA;AAAA,MACA,mBAAA;AAAA,MACA,gBAAA;AAAA,MACA,mBAAA;AAAA,MACA,gBAAA;AAAA,MACA,mBAAA;AAAA,MACA,WAAA;AAAA,MACA,cAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,KAAA,CAAA;AAAA,GAED,EAAA;AAAA,IACD,KAAA;AAAA,IACA,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA,IAAA;AAAA,GAAA,CAAA,CAAA;AAGF,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,kBAAkB,QAAnB,EAAA;AAAA,IAA4B,KAAO,EAAA,KAAA;AAAA,GAAQ,EAAA,QAAA,CAAA,CAAA;AAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudUtils as
|
|
1
|
+
import{PointCloudUtils as m,EPerspectiveView as v}from"@labelbee/lb-utils";import o,{useState as C,useEffect as y}from"react";import{PointCloudContext as b}from"./PointCloudContext.js";import{UnitUtils as B}from"@labelbee/lb-annotation";import{useSingleBox as I}from"./hooks/useSingleBox.js";import{useTranslation as h}from"react-i18next";const r=2,E=({perspectiveView:l})=>{const{pointCloudBoxList:e,selectedID:s}=o.useContext(b),i=e.find(a=>a.id===s),f=h(),{t}=f;if(s&&i){const{length:a,width:n,height:u}=m.transferBox2Kitti(i),x=l===v.Back?[{label:t("Width"),value:n},{label:t("Height"),value:u}]:[{label:t("Length"),value:a},{label:t("Height"),value:u}];return o.createElement(o.Fragment,null,x.map((c,d)=>o.createElement("span",{key:d,style:{marginRight:d===0?16:0,fontSize:12}},`${c.label}: ${c.value.toFixed(r)}`)))}return null},w=()=>{const l=o.useContext(b),{selectedBox:e}=I(),[s,i]=C([]),f=h(),{t,i18n:a}=f;return y(()=>{var n;if(!e)return;const{length:u,width:x,height:c,rotation_y:d}=m.transferBox2Kitti(e.info);let g=[{label:t("Length"),value:u.toFixed(r)},{label:t("Width"),value:x.toFixed(r)},{label:t("Height"),value:c.toFixed(r)},{label:t("Rotation_y"),value:B.rad2deg(d).toFixed(r)}];(n=l.mainViewInstance)==null||n.filterPointsByBox(e.info).then(p=>{if(!p){i(g);return}g.push({label:t("PointCount"),value:`${p.num}`}),i(g)})},[e,a.language]),e?o.createElement("div",{style:{position:"absolute",color:"white",backgroundColor:"rgba(153, 153, 153, 0.3)",right:8,top:8,fontSize:12,padding:8,zIndex:20}},s.map(n=>o.createElement("div",{key:n.label},`${n.label}: ${n.value}`))):null},P=()=>{const l=o.useContext(b),{t:e}=h();return l.valid===!1?o.createElement("div",{style:{position:"absolute",backgroundColor:"rgb(242, 101, 73)",color:"white",opacity:.7,left:0,top:0,fontSize:30,padding:"8px 16px",zIndex:20,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"}},e("Invalid")):null};export{w as BoxInfos,P as PointCloudValidity,E as SizeInfoForView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PointCloudInfos.js","sources":["../../../src/components/pointCloudView/PointCloudInfos.tsx"],"sourcesContent":["/**\n * @author Glenfiddish <edwinlee0927@hotmail.com>\n * @file Display selected box's infos\n * @createdate 2022-07-13\n */\n\nimport { EPerspectiveView, PointCloudUtils } from '@labelbee/lb-utils';\nimport React, { useEffect, useState } from 'react';\nimport { PointCloudContext } from './PointCloudContext';\nimport { UnitUtils } from '@labelbee/lb-annotation';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { useTranslation } from 'react-i18next';\n\nconst DECIMAL_PLACES = 2;\n\n/**\n * Display size info for views\n * @param param0\n * @returns\n */\nexport const SizeInfoForView = ({ perspectiveView }: { perspectiveView: EPerspectiveView }) => {\n const { pointCloudBoxList, selectedID } = React.useContext(PointCloudContext);\n const box = pointCloudBoxList.find((i) => i.id === selectedID);\n const trans = useTranslation();\n const { t } = trans;\n\n if (selectedID && box) {\n const { length, width, height } = PointCloudUtils.transferBox2Kitti(box);\n const infos =\n perspectiveView === EPerspectiveView.Back\n ? [\n {\n label: t('Width'),\n value: width,\n },\n {\n label: t('Height'),\n value: height,\n },\n ]\n : [\n {\n label: t('Length'),\n value: length,\n },\n {\n label: t('Height'),\n value: height,\n },\n ];\n\n return (\n <>\n {infos.map((info, index) => (\n <span key={index} style={{ marginRight: index === 0 ? 16 : 0, fontSize: 12 }}>{`${\n info.label\n }: ${info.value.toFixed(DECIMAL_PLACES)}`}</span>\n ))}\n </>\n );\n }\n return null;\n};\n\n/**\n * Display selected box's infos\n */\nexport const BoxInfos = () => {\n const ptCtx = React.useContext(PointCloudContext);\n const { selectedBox } = useSingleBox();\n const [infos, setInfos] = useState<Array<{ label: string; value: string }>>([]);\n const trans = useTranslation();\n const { t, i18n } = trans;\n\n useEffect(() => {\n if (!selectedBox) {\n return;\n }\n\n const { length, width, height, rotation_y } = PointCloudUtils.transferBox2Kitti(\n selectedBox.info,\n );\n\n let infos = [\n {\n label: t('Length'),\n value: length.toFixed(DECIMAL_PLACES),\n },\n {\n label: t('Width'),\n value: width.toFixed(DECIMAL_PLACES),\n },\n {\n label: t('Height'),\n value: height.toFixed(DECIMAL_PLACES),\n },\n {\n label: t('Rotation_y'),\n value: UnitUtils.rad2deg(rotation_y).toFixed(DECIMAL_PLACES),\n },\n ];\n\n // Get Point Count.\n ptCtx.mainViewInstance?.filterPointsByBox(selectedBox.info).then((data) => {\n if (!data) {\n setInfos(infos);\n return;\n }\n\n infos.push({\n label: t('PointCount'),\n value: `${data.num}`,\n });\n setInfos(infos);\n });\n }, [selectedBox, i18n.language]);\n\n if (selectedBox) {\n return (\n <div\n style={{\n position: 'absolute',\n color: 'white',\n backgroundColor: 'rgba(153, 153, 153, 0.3)',\n right: 8,\n top: 8,\n fontSize: 12,\n padding: 8,\n zIndex: 20,\n }}\n >\n {infos.map((i) => (\n <div key={i.label}>{`${i.label}: ${i.value}`}</div>\n ))}\n </div>\n );\n }\n\n return null;\n};\n\nexport const PointCloudValidity = () => {\n const ptCtx = React.useContext(PointCloudContext);\n const { t } = useTranslation();\n\n if (ptCtx.valid === false) {\n return (\n <div\n style={{\n position: 'absolute',\n backgroundColor: 'rgb(242, 101, 73)',\n color: 'white',\n left: 0,\n top: 0,\n fontSize:
|
|
1
|
+
{"version":3,"file":"PointCloudInfos.js","sources":["../../../src/components/pointCloudView/PointCloudInfos.tsx"],"sourcesContent":["/**\n * @author Glenfiddish <edwinlee0927@hotmail.com>\n * @file Display selected box's infos\n * @createdate 2022-07-13\n */\n\nimport { EPerspectiveView, PointCloudUtils } from '@labelbee/lb-utils';\nimport React, { useEffect, useState } from 'react';\nimport { PointCloudContext } from './PointCloudContext';\nimport { UnitUtils } from '@labelbee/lb-annotation';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { useTranslation } from 'react-i18next';\n\nconst DECIMAL_PLACES = 2;\n\n/**\n * Display size info for views\n * @param param0\n * @returns\n */\nexport const SizeInfoForView = ({ perspectiveView }: { perspectiveView: EPerspectiveView }) => {\n const { pointCloudBoxList, selectedID } = React.useContext(PointCloudContext);\n const box = pointCloudBoxList.find((i) => i.id === selectedID);\n const trans = useTranslation();\n const { t } = trans;\n\n if (selectedID && box) {\n const { length, width, height } = PointCloudUtils.transferBox2Kitti(box);\n const infos =\n perspectiveView === EPerspectiveView.Back\n ? [\n {\n label: t('Width'),\n value: width,\n },\n {\n label: t('Height'),\n value: height,\n },\n ]\n : [\n {\n label: t('Length'),\n value: length,\n },\n {\n label: t('Height'),\n value: height,\n },\n ];\n\n return (\n <>\n {infos.map((info, index) => (\n <span key={index} style={{ marginRight: index === 0 ? 16 : 0, fontSize: 12 }}>{`${\n info.label\n }: ${info.value.toFixed(DECIMAL_PLACES)}`}</span>\n ))}\n </>\n );\n }\n return null;\n};\n\n/**\n * Display selected box's infos\n */\nexport const BoxInfos = () => {\n const ptCtx = React.useContext(PointCloudContext);\n const { selectedBox } = useSingleBox();\n const [infos, setInfos] = useState<Array<{ label: string; value: string }>>([]);\n const trans = useTranslation();\n const { t, i18n } = trans;\n\n useEffect(() => {\n if (!selectedBox) {\n return;\n }\n\n const { length, width, height, rotation_y } = PointCloudUtils.transferBox2Kitti(\n selectedBox.info,\n );\n\n let infos = [\n {\n label: t('Length'),\n value: length.toFixed(DECIMAL_PLACES),\n },\n {\n label: t('Width'),\n value: width.toFixed(DECIMAL_PLACES),\n },\n {\n label: t('Height'),\n value: height.toFixed(DECIMAL_PLACES),\n },\n {\n label: t('Rotation_y'),\n value: UnitUtils.rad2deg(rotation_y).toFixed(DECIMAL_PLACES),\n },\n ];\n\n // Get Point Count.\n ptCtx.mainViewInstance?.filterPointsByBox(selectedBox.info).then((data) => {\n if (!data) {\n setInfos(infos);\n return;\n }\n\n infos.push({\n label: t('PointCount'),\n value: `${data.num}`,\n });\n setInfos(infos);\n });\n }, [selectedBox, i18n.language]);\n\n if (selectedBox) {\n return (\n <div\n style={{\n position: 'absolute',\n color: 'white',\n backgroundColor: 'rgba(153, 153, 153, 0.3)',\n right: 8,\n top: 8,\n fontSize: 12,\n padding: 8,\n zIndex: 20,\n }}\n >\n {infos.map((i) => (\n <div key={i.label}>{`${i.label}: ${i.value}`}</div>\n ))}\n </div>\n );\n }\n\n return null;\n};\n\nexport const PointCloudValidity = () => {\n const ptCtx = React.useContext(PointCloudContext);\n const { t } = useTranslation();\n\n if (ptCtx.valid === false) {\n return (\n <div\n style={{\n position: 'absolute',\n backgroundColor: 'rgb(242, 101, 73)',\n color: 'white',\n opacity: 0.7,\n left: 0,\n top: 0,\n fontSize: 30,\n padding: '8px 16px',\n zIndex: 20,\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n }}\n >\n {t('Invalid')}\n </div>\n );\n }\n return null;\n};\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,cAAiB,GAAA,CAAA,CAAA;AAOV,MAAA,eAAA,GAAkB,CA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A,IAAA,CAAA;AAAA,EAAA;AAGF,MAAM,qBAAqB,MAAM;AACtC,EAAM,MAAA,KAAA,GAAQ,MAAM,UAAW,CAAA,iBAAA,CAAA,CAAA;AAC/B,EAAA,MAAM,CAAE,CAAM,CAAA,GAAA,cAAA,EAAA,CAAA;AAEd,EAAI,IAAA,KAAA,CAAM,UAAU,KAAO,EAAA;AACzB,IAAA,2CACG,KAAD,EAAA;AAAA,MACE,KAAO,EAAA;AAAA,QACL,QAAU,EAAA,UAAA;AAAA,QACV,eAAiB,EAAA,mBAAA;AAAA,QACjB,KAAO,EAAA,OAAA;AAAA,QACP,OAAS,EAAA,GAAA;AAAA,QACT,IAAM,EAAA,CAAA;AAAA,QACN,GAAK,EAAA,CAAA;AAAA,QACL,QAAU,EAAA,EAAA;AAAA,QACV,OAAS,EAAA,UAAA;AAAA,QACT,MAAQ,EAAA,EAAA;AAAA,QACR,KAAO,EAAA,MAAA;AAAA,QACP,MAAQ,EAAA,MAAA;AAAA,QACR,OAAS,EAAA,MAAA;AAAA,QACT,cAAgB,EAAA,QAAA;AAAA,QAChB,UAAY,EAAA,QAAA;AAAA,OAAA;AAAA,KAAA,EAGb,CAAE,CAAA,SAAA,CAAA,CAAA,CAAA;AAAA,GAAA;AAIT,EAAO,OAAA,IAAA,CAAA;AAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
1
|
+
import{PointCloudContext as D}from"./PointCloudContext.js";import{useRotate as N}from"./hooks/useRotate.js";import{useBoxes as T}from"./hooks/useBoxes.js";import{useSingleBox as K}from"./hooks/useSingleBox.js";import{useContext as H,useEffect as d}from"react";import{AttributeUtils as z,cTool as $}from"@labelbee/lb-annotation";import{message as b}from"antd";import{connect as q}from"react-redux";import{a2MapStateToProps as G}from"../../store/annotation/map.js";import{useCustomToolInstance as M}from"../../hooks/annotation.js";import{useStatus as U}from"./hooks/useStatus.js";import{jsonParser as W}from"../../utils/index.js";import{usePointCloudViews as Y}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as F}from"../../store/ctx.js";import{useHistory as J}from"./hooks/useHistory.js";import{useAttribute as Q}from"./hooks/useAttribute.js";var X=Object.defineProperty,Z=Object.defineProperties,ee=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,te=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,g=(s,r,e)=>r in s?X(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e,re=(s,r)=>{for(var e in r||(r={}))te.call(r,e)&&g(s,e,r[e]);if(k)for(var e of k(r))oe.call(r,e)&&g(s,e,r[e]);return s},se=(s,r)=>Z(s,ee(r));const{EPolygonPattern:p}=$,ne=({currentData:s,config:r})=>{const e=H(D),{changeSelectedBoxValid:_,selectNextBox:h,selectPrevBox:B,updateSelectedBox:P}=K(),{clearAllResult:m}=U(),A=W(s.result),{copySelectedBoxes:j,pasteSelectedBoxes:O,copiedBoxes:S}=T(),{toolInstanceRef:n}=M({basicInfo:A}),{updateRotate:f}=N({currentData:s}),{updatePointCloudData:y}=Y(),{redo:v,undo:x,pushHistoryWithList:I}=J(),{syncThreeViewsAttribute:w,reRenderPointCloud3DBox:L}=Q(),V=(t,o)=>{var l;const{topViewInstance:a,mainViewInstance:u}=e;if(!a)return;const{pointCloud2dOperation:i}=a;switch(t){case"q":{f(2);break}case"e":f(-2);break;case"g":f(180);break;case"u":{const c=i.pattern===p.Normal?p.Rect:p.Normal;i.setPattern(c);const R={[p.Normal]:"Normal Pattern",[p.Rect]:"Rect Pattern"};b.success(`Change Pattern to ${R[c]} successfully`),i.clearActiveStatus(),i.clearDrawingStatus()}break;case"+":u==null||u.updatePointSize(!0);break;case"-":u==null||u.updatePointSize(!1);break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){B();break}h();break;case"f":_();break;default:{if(((l=r.attributeList)==null?void 0:l.length)>0){const c=z.getAttributeByKeycode(o.keyCode,r.attributeList);c!==void 0&&n.current.setDefaultAttribute(c)}return}}},E=(t,o)=>{switch(t){case"c":j();break;case"v":O();break;case"a":e.selectedAllBoxes();break;case"z":{o.shiftKey?v():x();break}}},C=t=>{const o=t.key.toLocaleLowerCase();if(t.ctrlKey){E(o,t);return}V(o,t)};return d(()=>{const{topViewInstance:t}=e;if(!!t)return window.addEventListener("keydown",C),()=>{window.removeEventListener("keydown",C)}},[e,S,r]),d(()=>{y==null||y()},[s,e.mainViewInstance]),d(()=>{n.current.exportData=()=>[e.pointCloudBoxList,{valid:e.valid}],n.current.exportCustomData=()=>{var t;return{renderPolygon:(t=e.polygonList)!=null?t:[]}},n.current.setDefaultAttribute=t=>{w(t);const o=e.selectedPointCloudBox;o&&(o.attribute=t,P(o),L(o))},n.current.setSubAttribute=(t,o)=>{var l;const a=e.selectedPointCloudBox;if(a){const u=(l=a==null?void 0:a.subAttribute)!=null?l:{};a.subAttribute=se(re({},u),{[t]:o}),P(a)}},n.current.clearResult=()=>{m==null||m()},n.current.redo=()=>{v()},n.current.undo=()=>{x()},n.current.setValid=t=>{n.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&m()})}},[e.pointCloudBoxList,e.selectedID,e.valid,e.polygonList]),d(()=>{n.current.history={pushHistory:t=>{I({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.pointCloud2dOperation;if(!o)return;const l=i=>{w(i)},a=i=>{b.error(i)},u=i=>{b.info(i)};return o.on("syncAttribute",l),o.on("messageError",a),o.on("messageInfo",u),()=>{o.unbind("syncAttribute",l),o.unbind("messageError",a),o.unbind("messageInfo",u)}},[e.topViewInstance]),null};var ae=q(G,null,null,{context:F})(ne);export{ae as default};
|