@labelbee/lb-components 1.23.0-alpha.22 → 1.23.0-alpha.23

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.
@@ -1 +1 @@
1
- "use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),reactI18next=require("react-i18next"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,a,r)=>a in n?__defProp(n,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[a]=r,__spreadValues=(n,a)=>{for(var r in a||(a={}))__hasOwnProp.call(a,r)&&__defNormalProp(n,r,a[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(a))__propIsEnum.call(a,r)&&__defNormalProp(n,r,a[r]);return n},__spreadProps=(n,a)=>__defProps(n,__getOwnPropDescs(a));const PointCloud2DRectOperationView=n=>{var a;const{mappingData:r,size:l,config:f,checkMode:O,afterImgOnLoad:L}=n,v=(a=r==null?void 0:r.url)!=null?a:"",{t:y}=reactI18next.useTranslation(),{pointCloudBoxList:s,setPointCloudResult:V,defaultAttribute:p,rectList:R,addRectIn2DView:E,updateRectIn2DView:m,removeRectIn2DView:S}=React.useContext(PointCloudContext.PointCloudContext),{update2DViewRect:j}=usePointCloudViews.usePointCloudViews(),_=React__default.default.useRef(null),t=React.useRef(null),D=ahooks.useLatest(j),P=React.useRef(null),[q,w]=React.useState(!0),g=React.useMemo(()=>R==null?void 0:R.filter(e=>e.imageName===(r==null?void 0:r.path)),[r==null?void 0:r.path,R]),d=ahooks.useLatest(r==null?void 0:r.path),C=e=>{var o;const{boxID:u}=e;if(u){const i=(o=D.current)==null?void 0:o.call(D,e);P.current=i,V(i);return}m(e)},I=e=>{d.current&&E(__spreadProps(__spreadValues({},e),{imageName:d.current}))},x=e=>{e.some(u=>u.boxID)&&es.message.warning(y("ProjectionFrameCannotBeDeleted")),S(e)},B=React.useCallback(()=>{let e=[];return s.forEach(o=>{const{rects:u=[],id:i,attribute:c,trackID:A}=o,h=u.find(k=>k.imageName===d.current),N=i+"_"+d.current;h&&(e=[...e,__spreadProps(__spreadValues({},h),{boxID:i,id:N,attribute:c,order:A})])}),e},[s]),b=()=>{var e,o,u;const i=B(),c=(e=t.current)==null?void 0:e.selectedRectID;(o=t.current)==null||o.setResult([...i,...g]),c&&((u=t.current)==null||u.setSelectedRectID(c))};return React.useEffect(()=>{if(_.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:_.current,size:l,config:__spreadProps(__spreadValues({},f),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:O});return t.current=e,t.current.init(),t.current.on("updateDragResult",C),t.current.on("afterAddingDrawingRect",I),t.current.on("deleteSelectedRects",x),()=>{var o,u,i,c;(o=t.current)==null||o.unbind("updateDragResult",C),(u=t.current)==null||u.unbind("afterAddingDrawingRect",I),(i=t.current)==null||i.unbind("deleteSelectedRects",x),(c=t.current)==null||c.destroy()}}},[]),React.useEffect(()=>{w(!0),t.current&&v&&lbAnnotation.ImgUtils.load(v).then(e=>{t.current.setImgNode(e),L(e),w(!1)})},[v]),React.useEffect(()=>{var e;(e=t.current)==null||e.setSize(l)},[l]),React.useEffect(()=>{s!==P.current&&b()},[s]),React.useEffect(()=>{var e,o,u;const i=g.find(c=>c.id===t.current.selectedRectID);(o=(e=t.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,p),i&&m(__spreadProps(__spreadValues({},(u=t.current)==null?void 0:u.selectedRect),{attribute:p})),b()},[p]),React.useEffect(()=>{b()},[g]),React.useEffect(()=>{var e,o,u,i;const c=(o=(e=t.current)==null?void 0:e.config)!=null?o:{};(i=t.current)==null||i.setConfig(JSON.stringify(__spreadProps(__spreadValues({},c),{attributeList:(u=f.attributeList)!=null?u:[]})))},[f.attributeList]),React__default.default.createElement(es.Spin,{spinning:q},React__default.default.createElement("div",{ref:_,style:__spreadValues({position:"relative"},l)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
1
+ "use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,i,n)=>i in u?__defProp(u,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):u[i]=n,__spreadValues=(u,i)=>{for(var n in i||(i={}))__hasOwnProp.call(i,n)&&__defNormalProp(u,n,i[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(i))__propIsEnum.call(i,n)&&__defNormalProp(u,n,i[n]);return u},__spreadProps=(u,i)=>__defProps(u,__getOwnPropDescs(i));const PointCloud2DRectOperationView=u=>{var i;const{mappingData:n,size:l,config:f,checkMode:V,afterImgOnLoad:y}=u,p=(i=n==null?void 0:n.url)!=null?i:"",{pointCloudBoxList:v,setPointCloudResult:b,defaultAttribute:R,rectList:_,addRectIn2DView:E,updateRectIn2DView:w,removeRectIn2DView:S}=React.useContext(PointCloudContext.PointCloudContext),{update2DViewRect:j,remove2DViewRect:q}=usePointCloudViews.usePointCloudViews(),g=React__default.default.useRef(null),r=React.useRef(null),P=ahooks.useMemoizedFn(j),C=ahooks.useMemoizedFn(q),m=React.useRef(null),[B,I]=React.useState(!0),D=React.useMemo(()=>_==null?void 0:_.filter(e=>e.imageName===(n==null?void 0:n.path)),[n==null?void 0:n.path,_]),s=ahooks.useLatest(n==null?void 0:n.path),x=e=>{const{boxID:o}=e;if(o){const t=P==null?void 0:P(e);m.current=t,b(t);return}w(e)},O=e=>{s.current&&E(__spreadProps(__spreadValues({},e),{imageName:s.current}))},h=e=>{const o=e.find(t=>t.boxID);if(o){const t=C==null?void 0:C(o);m.current=t,b(t),d();return}S(e)},M=ahooks.useMemoizedFn(()=>{let e=[];return v.forEach(o=>{const{rects:t=[],id:c,attribute:a,trackID:z}=o,L=t.find(F=>F.imageName===s.current),A=c+"_"+s.current;L&&(e=[...e,__spreadProps(__spreadValues({},L),{boxID:c,id:A,attribute:a,order:z})])}),e}),d=ahooks.useMemoizedFn(()=>{var e,o,t;const c=M(),a=(e=r.current)==null?void 0:e.selectedRectID;(o=r.current)==null||o.setResult([...c,...D]),a&&((t=r.current)==null||t.setSelectedRectID(a))});return React.useEffect(()=>{if(g.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:g.current,size:l,config:__spreadProps(__spreadValues({},f),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:V});return r.current=e,r.current.init(),r.current.on("updateDragResult",x),r.current.on("afterAddingDrawingRect",O),r.current.on("deleteSelectedRects",h),()=>{var o,t,c,a;(o=r.current)==null||o.unbind("updateDragResult",x),(t=r.current)==null||t.unbind("afterAddingDrawingRect",O),(c=r.current)==null||c.unbind("deleteSelectedRects",h),(a=r.current)==null||a.destroy()}}},[]),React.useEffect(()=>{I(!0),r.current&&p&&lbAnnotation.ImgUtils.load(p).then(e=>{r.current.setImgNode(e),y(e),I(!1)})},[p]),React.useEffect(()=>{var e;(e=r.current)==null||e.setSize(l)},[l]),React.useEffect(()=>{v!==m.current&&d()},[v]),React.useEffect(()=>{var e,o,t;const c=D.find(a=>a.id===r.current.selectedRectID);(o=(e=r.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,R),c&&w(__spreadProps(__spreadValues({},(t=r.current)==null?void 0:t.selectedRect),{attribute:R})),d()},[R]),React.useEffect(()=>{d()},[D]),React.useEffect(()=>{var e,o,t,c;const a=(o=(e=r.current)==null?void 0:e.config)!=null?o:{};(c=r.current)==null||c.setConfig(JSON.stringify(__spreadProps(__spreadValues({},a),{attributeList:(t=f.attributeList)!=null?t:[]})))},[f.attributeList]),React__default.default.createElement(es.Spin,{spinning:B},React__default.default.createElement("div",{ref:g,style:__spreadValues({position:"relative"},l)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o));const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:o,setTarget3DView:i}=React.useContext(PointCloud3DContext),n=u=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",u)]:!0,active:o});return React__default.default.createElement("span",{onClick:()=>{i(lbUtils.EPerspectiveView[t])},className:n(t.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:t})=>{const{reset3DView:o,followTopView:i}=React.useContext(PointCloud3DContext),{t:n}=reactI18next.useTranslation(),u=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Top"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Front"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Left"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Back"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Right"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"LFT"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"RBT"})),p=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:n("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{o()},className:dom.getClassName("point-cloud-3d-view","reset")}));return t?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},p,u):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},u,p)},PointCloud3D=({currentData:t,config:o,highlightAttribute:i})=>{const n=React.useContext(PointCloudContext.PointCloudContext),[u,p]=React.useState(!0),[d,w]=React.useState(!1),m=React.useRef(null),{initPointCloud3d:E}=usePointCloudViews.usePointCloudViews(),f=useSize(m),{t:C}=reactI18next.useTranslation();React.useEffect(()=>{!n.mainViewInstance||E==null||E(f)},[f]);const{selectedBox:c}=useSingleBox.useSingleBox(),{selectedSphere:v}=useSphere.useSphere(),V=e=>{var a,l;const r=c==null?void 0:c.info;if(r){const s=__spreadValues({},r.center);s.x=s.x-.01,s.z=1e3;const g=e===lbUtils.EPerspectiveView.Top;(a=n.mainViewInstance)==null||a.updateCameraByBox(r,e,g?s:void 0)}v&&((l=n.mainViewInstance)==null||l.updateCameraBySphere(v,e))},_=()=>{var e;(e=n.mainViewInstance)==null||e.resetCamera()},h=()=>{var e,a;const l=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance.camera;l&&((a=n.mainViewInstance)==null||a.applyCameraTarget(l))};React.useEffect(()=>{if(m.current&&(t==null?void 0:t.url)){let e=n.mainViewInstance;!e&&f.width&&(e=new lbAnnotation.PointCloud({container:m.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(f),config:o}),n.setMainViewInstance(e))}},[f,t]),React.useEffect(()=>{var e;if(m.current&&(t==null?void 0:t.url)&&t.result&&n.mainViewInstance){let a=n.mainViewInstance;const l=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t.result);l.forEach(r=>{var s;const g=(s=lbUtils.toolStyleConverter.getColorFromConfig({attribute:r.attribute},__spreadProps(__spreadValues({},o),{attributeConfigurable:!0}),{}))==null?void 0:s.hex;a==null||a.addBoxToSense(r,g)}),a.render(),n.setPointCloudResult(l),n.setPointCloudValid((e=index.jsonParser(t.result))==null?void 0:e.valid)}},[t,n.mainViewInstance]),React.useEffect(()=>{var e,a,l,r;if(c){V(lbUtils.EPerspectiveView.Top);const s=(l=(a=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(r=n.mainViewInstance)==null||r.updateCameraZoom(s)}},[c]),React.useEffect(()=>{var e,a,l,r;if(v){V(lbUtils.EPerspectiveView.Top);const s=(l=(a=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(r=n.mainViewInstance)==null||r.updateCameraZoom(s)}},[v]),React.useEffect(()=>(window.addEventListener("keydown",P),()=>{window.removeEventListener("keydown",P)}),[]);const P=e=>{if(e.keyCode===EKeyCode.Esc){w(!1);return}},x=React.useMemo(()=>({reset3DView:_,setTarget3DView:V,isActive:!!c,followTopView:h}),[c,n.mainViewInstance]);React.useEffect(()=>{var e,a,l;const r=n.pointCloudBoxList.filter(s=>s.attribute===i);(r==null?void 0:r.length)>0&&((e=n.mainViewInstance)==null||e.clearHighlightBoxes(),(a=n.mainViewInstance)==null||a.highlightBoxes(r)),r.length===0&&((l=n.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[i,n.mainViewInstance]);const I=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:e=>{var a;(a=n.mainViewInstance)==null||a.updatePointSize({customSize:e})}}),React__default.default.createElement("span",{style:{marginRight:8}},C("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:u,onChange:e=>{var a;p(e),(a=n.mainViewInstance)==null||a.setShowDirection(e)}}),d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:x},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:d})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:d}),title:d?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{w(!1)}}),C("3DView")):React__default.default.createElement(index$2,{title:C("3DView"),onClick:()=>{w(!0)}}),toolbar:I},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:x},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:m})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
1
+ "use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o));const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:o,setTarget3DView:i}=React.useContext(PointCloud3DContext),n=u=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",u)]:!0,active:o});return React__default.default.createElement("span",{onClick:()=>{i(lbUtils.EPerspectiveView[t])},className:n(t.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:t})=>{const{reset3DView:o,followTopView:i}=React.useContext(PointCloud3DContext),{t:n}=reactI18next.useTranslation(),u=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Top"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Front"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Left"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Back"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Right"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"LFT"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"RBT"})),p=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:n("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{o()},className:dom.getClassName("point-cloud-3d-view","reset")}));return t?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},p,u):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},u,p)},PointCloud3D=({currentData:t,config:o,highlightAttribute:i})=>{const n=React.useContext(PointCloudContext.PointCloudContext),[u,p]=React.useState(!0),[d,C]=React.useState(!1),m=React.useRef(null),{initPointCloud3d:E}=usePointCloudViews.usePointCloudViews(),f=useSize(m),{t:g}=reactI18next.useTranslation();React.useEffect(()=>{!n.mainViewInstance||E==null||E(f)},[f]);const{selectedBox:c}=useSingleBox.useSingleBox(),{selectedSphere:v}=useSphere.useSphere(),V=e=>{var a,l;const r=c==null?void 0:c.info;if(r){const s=__spreadValues({},r.center);s.x=s.x-.01,s.z=1e3;const w=e===lbUtils.EPerspectiveView.Top;(a=n.mainViewInstance)==null||a.updateCameraByBox(r,e,w?s:void 0)}v&&((l=n.mainViewInstance)==null||l.updateCameraBySphere(v,e))},_=()=>{var e;(e=n.mainViewInstance)==null||e.resetCamera()},h=()=>{var e,a;const l=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance.camera;l&&((a=n.mainViewInstance)==null||a.applyCameraTarget(l))};React.useEffect(()=>{if(m.current&&(t==null?void 0:t.url)){let e=n.mainViewInstance;!e&&f.width&&(e=new lbAnnotation.PointCloud({container:m.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(f),config:o}),n.setMainViewInstance(e))}},[f,t]),React.useEffect(()=>{var e;if(m.current&&(t==null?void 0:t.url)&&t.result&&n.mainViewInstance){let a=n.mainViewInstance;const l=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t.result);l.forEach(s=>{var w;const b=(w=lbUtils.toolStyleConverter.getColorFromConfig({attribute:s.attribute},__spreadProps(__spreadValues({},o),{attributeConfigurable:!0}),{}))==null?void 0:w.hex;a==null||a.addBoxToSense(s,b)}),a.render(),n.setPointCloudResult(l);const r=lbUtils.PointCloudUtils.getRectParamsFromResultList(t.result);n.setRectList(r),n.setPointCloudValid((e=index.jsonParser(t.result))==null?void 0:e.valid)}},[t,n.mainViewInstance]),React.useEffect(()=>{var e,a,l,r;if(c){V(lbUtils.EPerspectiveView.Top);const s=(l=(a=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(r=n.mainViewInstance)==null||r.updateCameraZoom(s)}},[c]),React.useEffect(()=>{var e,a,l,r;if(v){V(lbUtils.EPerspectiveView.Top);const s=(l=(a=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(r=n.mainViewInstance)==null||r.updateCameraZoom(s)}},[v]),React.useEffect(()=>(window.addEventListener("keydown",P),()=>{window.removeEventListener("keydown",P)}),[]);const P=e=>{if(e.keyCode===EKeyCode.Esc){C(!1);return}},x=React.useMemo(()=>({reset3DView:_,setTarget3DView:V,isActive:!!c,followTopView:h}),[c,n.mainViewInstance]);React.useEffect(()=>{var e,a,l;const r=n.pointCloudBoxList.filter(s=>s.attribute===i);(r==null?void 0:r.length)>0&&((e=n.mainViewInstance)==null||e.clearHighlightBoxes(),(a=n.mainViewInstance)==null||a.highlightBoxes(r)),r.length===0&&((l=n.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[i,n.mainViewInstance]);const I=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:e=>{var a;(a=n.mainViewInstance)==null||a.updatePointSize({customSize:e})}}),React__default.default.createElement("span",{style:{marginRight:8}},g("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:u,onChange:e=>{var a;p(e),(a=n.mainViewInstance)==null||a.setShowDirection(e)}}),d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:x},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:d})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:d}),title:d?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{C(!1)}}),g("3DView")):React__default.default.createElement(index$2,{title:g("3DView"),onClick:()=>{C(!0)}}),toolbar:I},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:x},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:m})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,n)=>new Promise((a,o)=>{var d=u=>{try{c(n.next(u))}catch(f){o(f)}},P=u=>{try{c(n.throw(u))}catch(f){o(f)}},c=u=>u.done?a(u.value):Promise.resolve(u.value).then(d,P);c((n=n.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,n,a,o)=>{const{x:d,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,u={center:{x:d,y:P,z:c},id:e.id},f=a?__spreadValues(__spreadValues({},a),u):__spreadProps(__spreadValues({},u),{attribute:"",valid:!0});return o&&Object.assign(f,o),f},topViewPolygon2PointCloud=(e,t,n,a,o,d)=>{let P=e.pointList.map(y=>lbUtils.PointCloudUtils.transferCanvas2World(y,t)),c=0,u=1,f={};if(n){const y=n.getSensesPointZAxisInPolygon(P,void 0,d);d&&y.fittedCoordinates.length>0&&(P=y.fittedCoordinates),c=(y.maxZ+y.minZ)/2,u=y.maxZ-y.minZ,f={count:y.zCount}}const[v,B,j]=P,_=lbAnnotation.MathUtils.getLineCenterPoint([v,j]),O=lbAnnotation.MathUtils.getLineLength(v,B),I=lbAnnotation.MathUtils.getLineLength(B,j),A=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(c=a.center.z,u=a.depth);const k={center:{x:_.x,y:_.y,z:c},width:d?I+INTELLIGENT_FIT_MARGIN:I,height:d?O+INTELLIGENT_FIT_MARGIN:O,depth:u,rotation:A,id:e.id},R=__spreadValues(a?__spreadValues(__spreadValues({},a),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),f);o&&Object.assign(R,o);const z=P.map(y=>lbUtils.PointCloudUtils.transferWorld2Canvas(y,t));return{boxParams:R,newPointList:z}},sideViewPoint2PointCloud=(e,t,n)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},n),{center:{x:n.center.x-a.x,y:n.center.y,z:n.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,n,a)=>{const[o,d,P]=e.pointList,[c,u,f]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([c,f]),_={x:{x:v.x-B.x,y:v.y-B.y}.x,y:0,z:v.y-B.y},O=lbAnnotation.MathUtils.getLineLength(o,d),I=lbAnnotation.MathUtils.getLineLength(c,u),A=O-I,k=lbAnnotation.MathUtils.getLineLength(d,P),R=lbAnnotation.MathUtils.getLineLength(u,f),z=k-R,{newBoxParams:y}=a.getNewBoxBySideUpdate(_,z,A,n);return y},backViewPoint2PointCloud=(e,t,n)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},n),{center:{x:n.center.x,y:n.center.y-a.x,z:n.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,n,a)=>{const[o,d,P]=e.pointList,[c,u,f]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([c,f]),_={x:{x:v.x-B.x,y:v.y-B.y}.x,y:0,z:v.y-B.y},O=lbAnnotation.MathUtils.getLineLength(o,d),I=lbAnnotation.MathUtils.getLineLength(c,u),A=O-I,k=lbAnnotation.MathUtils.getLineLength(d,P),R=lbAnnotation.MathUtils.getLineLength(u,f),z=k-R;let{newBoxParams:y}=a.getNewBoxByBackUpdate(_,z,A,n);return y},syncSideViewByPoint=(e,t,n,a,o)=>{var d;if(!n)return;const{toolInstance:P,pointCloudInstance:c}=n;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(u);const{point2d:f,zoom:v}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,n,a)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=n;d.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxSidePolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,n,a,o)=>{var d;if(!n)return;const{toolInstance:P,pointCloudInstance:c}=n;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(u);const{point2d:f,zoom:v}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,n,a)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=n;d.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxBackPolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,n,a)=>{if(!n||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:d}=n,{point2d:P}=d.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,n,a)=>{var o,d;if(!n||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=n,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),f=[...P.polygonList],v=f.find(B=>B.id===t.id);v?(v.pointList=u,v.valid=(o=e.valid)!=null?o:!0):f.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=e.valid)!=null?d:!0}),P.setResultAndSelectedID(f,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:n,backViewInstance:a,mainViewInstance:o,addPointCloudBox:d,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:f,pointCloudSphereList:v,hideAttributes:B,setHighlight2DDataList:j,cuboidBoxIn2DView:_,imageSizes:O}=e,{addHistory:I,initHistory:A,pushHistoryUnderUpdatePolygon:k}=useHistory.useHistory(),{selectedPolygon:R}=usePolygon.usePolygon(),{getPointCloudSphereByID:z,updatePointCloudSphere:y,selectedSphere:q}=useSphere.useSphere(),{currentData:M,config:w}=ctx.useSelector(i=>{const{stepList:s,step:p,imgList:l,imgIndex:r}=i.annotation;return{currentData:l[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),T=ctx.useDispatch(),tt=ahooks.useLatest(_),W=i=>{if(!tt.current){const{mappingImgList:s=[]}=M,p=s.map(l=>index.getRectPointCloudBox({pointCloudBox:i,mappingData:l,imageSizes:O}));Object.assign(i,{rects:p.filter(l=>l!==void 0)})}},{selectedBox:S,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),Q=S==null?void 0:S.info;if(!t||!n||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},nt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:i,size:s,zoom:p,trackConfigurable:l})=>{var r;const C={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const h=topViewPoint2PointCloud(i,s,G,void 0,C);c(i.id);const x=P(h);F(PointCloudView.Top,i,h,p,x,w),I({newSphereParams:h})},lt=({polygon:i,size:s,imgList:p,trackConfigurable:l,zoom:r,intelligentFit:C})=>{var h,x;const g={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};l===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:v})});const b=t==null?void 0:t.toolInstance,m=__spreadValues({},i);let{boxParams:L,newPointList:D}=topViewPolygon2PointCloud(m,s,G,void 0,g,C);L=T(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[L],stepConfig:w,action:"viewUpdateBox"}))[0],C&&(D==null?void 0:D.length)&&(m.pointList=D);const U=B.includes(m.attribute);W(L);const N=d(L),J=(x=e==null?void 0:e.polygonList)!=null?x:[];t==null||t.updatePolygonList(N!=null?N:[],J),U?c([]):(c(L.id),b.selection.setSelectedIDs(m.id),E({omitView:PointCloudView.Top,polygon:m,boxParams:L,zoom:r,newPointCloudBoxList:N}),C&&synchronizeTopView(L,m,t,o)),I({newBoxParams:L})},rt=i=>{const{boxID:s,imageName:p,width:l,height:r,x:C,y:h}=i,x=f.find(g=>g.id===s);if(x==null?void 0:x.rects){const{rects:g=[]}=x,b=g.find(m=>m.imageName===p);if(b){let m=g;const L=__spreadProps(__spreadValues({},b),{width:l,height:r,x:C,y:h});m=g.map(U=>U===b?L:U);const D=__spreadProps(__spreadValues({},x),{rects:m}),V=f.map(U=>U===x?D:U);return t==null||t.updatePolygonList(V!=null?V:[]),V}}},at=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:p,newSphereList:l})=>{var r;const C=t==null?void 0:t.toolInstance;if(!(u.length===0||!C)){if(i||(S==null?void 0:S.info)){const h=i!=null?i:S==null?void 0:S.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(u[0]);const x=C.selectedPolygon;if(u.length===1&&h){E({omitView:PointCloudView.Top,polygon:x,boxParams:h,newPointCloudBoxList:s});return}}if((p||q)&&u.length===1){const h=p!=null?p:q;C.setSelectedID(u[0]);const x=C.selectedPoint;h&&F(PointCloudView.Top,x,h,void 0,l,w)}}},X=(i,s,p)=>{if(Q){let l,r;switch(p){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(r=l(i,s,Q,n.pointCloudInstance),o){const{count:b}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:b})}const h=T(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:w,action:"viewUpdateBox"}))[0],x=r.valid!==h.valid;r=h;const g=ot(r);return r=g.find(b=>b.id===r.id),E({omitView:x?void 0:p,polygon:i,boxParams:r,newPointCloudBoxList:g}),g}},Y=(i,s,p)=>{if(q){let l,r;switch(p){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}r=l(i,s,q);const C=y(r);return F(p,i,r,void 0,C,w),C}},dt=(i,s)=>{Y(i,s,PointCloudView.Side)},ct=(i,s)=>{Y(i,s,PointCloudView.Back)},ut=(i,s)=>{X(i,s,PointCloudView.Side)},pt=(i,s)=>{X(i,s,PointCloudView.Back)},Pt=(i,s)=>{const p=z(i.id),l=topViewPoint2PointCloud(i,s,G,p),r=y(l);F(PointCloudView.Top,i,l,void 0,r,w)},Ct=(i,s)=>{if(R){const l=__spreadValues({},i[0].newPolygon);l.pointList=l.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,s)),k(l);return}let p=i.map(({newPolygon:l})=>{const r=et(l.id),{boxParams:C}=topViewPolygon2PointCloud(l,s,t.pointCloudInstance,r);return C});if(p=T(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:w,action:"viewUpdateBox"})),p.length===1){const{newPolygon:l}=i[0],r=Z(p);E({polygon:l,boxParams:p[0],newPointCloudBoxList:r})}else{const l=Z(p);l&&e.syncAllViewPointCloudColor(l)}},gt=i=>{var s,p,l,r,C;if(S){const h=Number(i.widthDefault),x=Number(i.depthDefault),g=Number(i.heightDefault),b=S==null?void 0:S.info.trackID,L=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(H=>(H==null?void 0:H.trackID)===b),D={width:(l=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:l.width,height:(C=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:C.height},V=L.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,D)),U=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(V,g,h),N=U[0],J=U[2],K=lbAnnotation.MathUtils.getLineCenterPoint([N,J]),ht=S.info.center.z-S.info.depth/2,$=__spreadProps(__spreadValues({},S.info),{center:{x:K.x,y:K.y,z:ht+x/2},width:h,height:g,depth:x,valid:!0}),ft=Z([$]);E({omitView:PointCloudView["3D"],polygon:L,boxParams:$,newPointCloudBoxList:ft})}},F=(i,s,p,l,r,C)=>__async(void 0,null,function*(){const h=M==null?void 0:M.url,x={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,n,h,C)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(p,s,a,h,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,t,o)}};Object.keys(x).forEach(g=>{g!==i&&x[g]()}),l&&(o==null||o.updateCameraZoom(l)),nt(p)}),E=i=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:l,zoom:r,newPointCloudBoxList:C}=i,h=M==null?void 0:M.url;C&&(yield e.syncAllViewPointCloudColor(C));const x={[PointCloudView.Side]:()=>{synchronizeSideView(l,p,n,h)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(l,p,a,h)},[PointCloudView.Top]:()=>{synchronizeTopView(l,p,t,o)}};Object.keys(x).forEach(g=>{g!==s&&x[g]()}),r&&(o==null||o.updateCameraZoom(r)),it(l)});return{topViewAddSphere:st,topViewAddBox:lt,topViewSelectedChanged:at,topViewUpdatePoint:Pt,sideViewUpdatePoint:dt,backViewUpdatePoint:ct,topViewUpdateBox:Ct,sideViewUpdateBox:ut,backViewUpdateBox:pt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(i);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(s=M){var p,l,r,C,h,x;if(!(s==null?void 0:s.url)||!o)return;j([]),actionCreators.SetPointCloudLoading(T,!0),actionCreators.SetLoadPCDFileLoading(T,!0),yield o.loadPCDFile(s.url,(p=w==null?void 0:w.radius)!=null?p:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let g=[],b=[],m=[],L=[];o.updateTopCamera();const D=(r=(l=index.jsonParser(s.result))==null?void 0:l.valid)!=null?r:!0;if(e.setPointCloudValid(D),(C=e.sideViewInstance)==null||C.clearAllData(),(h=e.backViewInstance)==null||h.clearAllData(),s.result){if(g=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),(g==null?void 0:g.length)>0&&s.isPreResult&&(w==null?void 0:w.lowerLimitPointsNumInBox)>0){g=yield o==null?void 0:o.filterPreResult(s.url,w,g);const V=index.jsonParser(s.result);V[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=g,s.result=JSON.stringify(V),e.setPointCloudResult(g)}m=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),L=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t.updateData(s.url,s.result,{radius:(x=w==null?void 0:w.radius)!=null?x:DEFAULT_RADIUS}),o==null||o.generateBoxes(g),o==null||o.generateSpheres(L),yield e.syncAllViewPointCloudColor(g,[])}A({pointCloudBoxList:g,polygonList:m,lineList:b,pointCloudSphereList:L}),actionCreators.SetPointCloudLoading(T,!1),actionCreators.SetLoadPCDFileLoading(T,!1)}),updateViewsByDefaultSize:gt,generateRects:W,update2DViewRect:rt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,r)=>new Promise((a,o)=>{var c=p=>{try{u(r.next(p))}catch(f){o(f)}},P=p=>{try{u(r.throw(p))}catch(f){o(f)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,P);u((r=r.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,r,a,o)=>{const{x:c,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:u}=lbUtils.DEFAULT_SPHERE_PARAMS,p={center:{x:c,y:P,z:u},id:e.id},f=a?__spreadValues(__spreadValues({},a),p):__spreadProps(__spreadValues({},p),{attribute:"",valid:!0});return o&&Object.assign(f,o),f},topViewPolygon2PointCloud=(e,t,r,a,o,c)=>{let P=e.pointList.map(L=>lbUtils.PointCloudUtils.transferCanvas2World(L,t)),u=0,p=1,f={};if(r){const L=r.getSensesPointZAxisInPolygon(P,void 0,c);c&&L.fittedCoordinates.length>0&&(P=L.fittedCoordinates),u=(L.maxZ+L.minZ)/2,p=L.maxZ-L.minZ,f={count:L.zCount}}const[x,B,z]=P,U=lbAnnotation.MathUtils.getLineCenterPoint([x,z]),V=lbAnnotation.MathUtils.getLineLength(x,B),I=lbAnnotation.MathUtils.getLineLength(B,z),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const _={center:{x:U.x,y:U.y,z:u},width:c?I+INTELLIGENT_FIT_MARGIN:I,height:c?V+INTELLIGENT_FIT_MARGIN:V,depth:p,rotation:k,id:e.id},O=__spreadValues(a?__spreadValues(__spreadValues({},a),_):__spreadProps(__spreadValues({},_),{attribute:"",valid:!0}),f);o&&Object.assign(O,o);const R=P.map(L=>lbUtils.PointCloudUtils.transferWorld2Canvas(L,t));return{boxParams:O,newPointList:R}},sideViewPoint2PointCloud=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},r),{center:{x:r.center.x-a.x,y:r.center.y,z:r.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,r,a)=>{const[o,c,P]=e.pointList,[u,p,f]=t.pointList,x=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([u,f]),U={x:{x:x.x-B.x,y:x.y-B.y}.x,y:0,z:x.y-B.y},V=lbAnnotation.MathUtils.getLineLength(o,c),I=lbAnnotation.MathUtils.getLineLength(u,p),k=V-I,_=lbAnnotation.MathUtils.getLineLength(c,P),O=lbAnnotation.MathUtils.getLineLength(p,f),R=_-O,{newBoxParams:L}=a.getNewBoxBySideUpdate(U,R,k,r);return L},backViewPoint2PointCloud=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},r),{center:{x:r.center.x,y:r.center.y-a.x,z:r.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,r,a)=>{const[o,c,P]=e.pointList,[u,p,f]=t.pointList,x=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([u,f]),U={x:{x:x.x-B.x,y:x.y-B.y}.x,y:0,z:x.y-B.y},V=lbAnnotation.MathUtils.getLineLength(o,c),I=lbAnnotation.MathUtils.getLineLength(u,p),k=V-I,_=lbAnnotation.MathUtils.getLineLength(c,P),O=lbAnnotation.MathUtils.getLineLength(p,f),R=_-O;let{newBoxParams:L}=a.getNewBoxByBackUpdate(U,R,k,r);return L},syncSideViewByPoint=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:P,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(p);const{point2d:f,zoom:x}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(x),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=c.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(P);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:P,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(p);const{point2d:f,zoom:x}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(x),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=c.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(P);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,r,a)=>{if(!r||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=r,{point2d:P}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},synchronizeTopView=(e,t,r,a)=>{var o,c;if(!r||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:u}=r,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),f=[...P.polygonList],x=f.find(B=>B.id===t.id);x?(x.pointList=p,x.valid=(o=e.valid)!=null?o:!0):f.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),P.setResultAndSelectedID(f,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:r,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:P,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:f,pointCloudSphereList:x,hideAttributes:B,setHighlight2DDataList:z,cuboidBoxIn2DView:U,imageSizes:V}=e,{addHistory:I,initHistory:k,pushHistoryUnderUpdatePolygon:_}=useHistory.useHistory(),{selectedPolygon:O}=usePolygon.usePolygon(),{getPointCloudSphereByID:R,updatePointCloudSphere:L,selectedSphere:N}=useSphere.useSphere(),{currentData:T,config:w}=ctx.useSelector(i=>{const{stepList:n,step:d,imgList:s,imgIndex:l}=i.annotation;return{currentData:s[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,n).config)}}),A=ctx.useDispatch(),tt=ahooks.useLatest(U),W=i=>{if(!tt.current){const{mappingImgList:n=[]}=T,d=n.map(s=>index.getRectPointCloudBox({pointCloudBox:i,mappingData:s,imageSizes:V}));Object.assign(i,{rects:d.filter(s=>s!==void 0)})}},{selectedBox:b,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),Q=b==null?void 0:b.info;if(!t||!r||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},nt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:i,size:n,zoom:d,trackConfigurable:s})=>{var l;const C={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};s===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:x})});const h=topViewPoint2PointCloud(i,n,G,void 0,C);u(i.id);const g=P(h);q(PointCloudView.Top,i,h,d,g,w),I({newSphereParams:h})},rt=({polygon:i,size:n,imgList:d,trackConfigurable:s,zoom:l,intelligentFit:C})=>{var h,g;const v={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};s===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:x})});const S=t==null?void 0:t.toolInstance,D=__spreadValues({},i);let{boxParams:y,newPointList:m}=topViewPolygon2PointCloud(D,n,G,void 0,v,C);y=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[y],stepConfig:w,action:"viewUpdateBox"}))[0],C&&(m==null?void 0:m.length)&&(D.pointList=m);const F=B.includes(D.attribute);W(y);const E=c(y),J=(g=e==null?void 0:e.polygonList)!=null?g:[];t==null||t.updatePolygonList(E!=null?E:[],J),F?u([]):(u(y.id),S.selection.setSelectedIDs(D.id),j({omitView:PointCloudView.Top,polygon:D,boxParams:y,zoom:l,newPointCloudBoxList:E}),C&&synchronizeTopView(y,D,t,o)),I({newBoxParams:y})},lt=i=>{const{boxID:n,imageName:d,width:s,height:l,x:C,y:h}=i,g=f.find(m=>m.id===n);if(!(g==null?void 0:g.rects)||!g.rects.find(m=>m.imageName===d))return;const S=g.rects.map(m=>m.imageName===d?__spreadProps(__spreadValues({},m),{width:s,height:l,x:C,y:h}):m),D=__spreadProps(__spreadValues({},g),{rects:S}),y=f.map(m=>m.id===n?D:m);return t==null||t.updatePolygonList(y!=null?y:[]),y},dt=i=>{const{boxID:n,imageName:d}=i,s=f.find(g=>g.id===n);if(!(s==null?void 0:s.rects))return;const l=s.rects.filter(g=>g.imageName!==d),C=__spreadProps(__spreadValues({},s),{rects:l}),h=f.map(g=>g.id===n?C:g);return t==null||t.updatePolygonList(h!=null?h:[]),h},at=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:s})=>{var l;const C=t==null?void 0:t.toolInstance;if(!(p.length===0||!C)){if(i||(b==null?void 0:b.info)){const h=i!=null?i:b==null?void 0:b.info;(l=C==null?void 0:C.selection)==null||l.setSelectedIDs(p[0]);const g=C.selectedPolygon;if(p.length===1&&h){j({omitView:PointCloudView.Top,polygon:g,boxParams:h,newPointCloudBoxList:n});return}}if((d||N)&&p.length===1){const h=d!=null?d:N;C.setSelectedID(p[0]);const g=C.selectedPoint;h&&q(PointCloudView.Top,g,h,void 0,s,w)}}},X=(i,n,d)=>{if(Q){let s,l;switch(d){case PointCloudView.Back:s=backViewPolygon2PointCloud;break;case PointCloudView.Side:s=sideViewPolygon2PointCloud;break;default:s=sideViewPolygon2PointCloud;break}if(l=s(i,n,Q,r.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:S})}const h=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:w,action:"viewUpdateBox"}))[0],g=l.valid!==h.valid;l=h;const v=ot(l);return l=v.find(S=>S.id===l.id),j({omitView:g?void 0:d,polygon:i,boxParams:l,newPointCloudBoxList:v}),v}},Y=(i,n,d)=>{if(N){let s,l;switch(d){case PointCloudView.Back:s=backViewPoint2PointCloud;break;case PointCloudView.Side:s=sideViewPoint2PointCloud;break;default:s=sideViewPoint2PointCloud;break}l=s(i,n,N);const C=L(l);return q(d,i,l,void 0,C,w),C}},ct=(i,n)=>{Y(i,n,PointCloudView.Side)},ut=(i,n)=>{Y(i,n,PointCloudView.Back)},pt=(i,n)=>{X(i,n,PointCloudView.Side)},Pt=(i,n)=>{X(i,n,PointCloudView.Back)},Ct=(i,n)=>{const d=R(i.id),s=topViewPoint2PointCloud(i,n,G,d),l=L(s);q(PointCloudView.Top,i,s,void 0,l,w)},gt=(i,n)=>{if(O){const s=__spreadValues({},i[0].newPolygon);s.pointList=s.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,n)),_(s);return}let d=i.map(({newPolygon:s})=>{const l=et(s.id),{boxParams:C}=topViewPolygon2PointCloud(s,n,t.pointCloudInstance,l);return C});if(d=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:w,action:"viewUpdateBox"})),d.length===1){const{newPolygon:s}=i[0],l=Z(d);j({polygon:s,boxParams:d[0],newPointCloudBoxList:l})}else{const s=Z(d);s&&e.syncAllViewPointCloudColor(s)}},ht=i=>{var n,d,s,l,C;if(b){const h=Number(i.widthDefault),g=Number(i.depthDefault),v=Number(i.heightDefault),S=b==null?void 0:b.info.trackID,y=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(H=>(H==null?void 0:H.trackID)===S),m={width:(s=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:s.width,height:(C=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:C.height},M=y.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,m)),F=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(M,v,h),E=F[0],J=F[2],K=lbAnnotation.MathUtils.getLineCenterPoint([E,J]),ft=b.info.center.z-b.info.depth/2,$=__spreadProps(__spreadValues({},b.info),{center:{x:K.x,y:K.y,z:ft+g/2},width:h,height:v,depth:g,valid:!0}),vt=Z([$]);j({omitView:PointCloudView["3D"],polygon:y,boxParams:$,newPointCloudBoxList:vt})}},q=(i,n,d,s,l,C)=>__async(void 0,null,function*(){const h=T==null?void 0:T.url,g={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,n,r,h,C)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(d,n,a,h,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,n,t,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),s&&(o==null||o.updateCameraZoom(s)),nt(d)}),j=i=>__async(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:s,zoom:l,newPointCloudBoxList:C}=i,h=T==null?void 0:T.url;C&&(yield e.syncAllViewPointCloudColor(C));const g={[PointCloudView.Side]:()=>{synchronizeSideView(s,d,r,h)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(s,d,a,h)},[PointCloudView.Top]:()=>{synchronizeTopView(s,d,t,o)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),l&&(o==null||o.updateCameraZoom(l)),it(s)});return{topViewAddSphere:st,topViewAddBox:rt,topViewSelectedChanged:at,topViewUpdatePoint:Ct,sideViewUpdatePoint:ct,backViewUpdatePoint:ut,topViewUpdateBox:gt,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=lbUtils.PointCloudUtils.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(n=T){var d,s,l,C,h,g;if(!(n==null?void 0:n.url)||!o)return;z([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(n.url,(d=w==null?void 0:w.radius)!=null?d:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],S=[],D=[],y=[];o.updateTopCamera();const m=(l=(s=index.jsonParser(n.result))==null?void 0:s.valid)!=null?l:!0;if(e.setPointCloudValid(m),(C=e.sideViewInstance)==null||C.clearAllData(),(h=e.backViewInstance)==null||h.clearAllData(),n.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),(v==null?void 0:v.length)>0&&n.isPreResult&&(w==null?void 0:w.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(n.url,w,v);const M=index.jsonParser(n.result);M[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,n.result=JSON.stringify(M),e.setPointCloudResult(v)}D=lbUtils.PointCloudUtils.getPolygonListFromResultList(n.result),S=lbUtils.PointCloudUtils.getLineListFromResultList(n.result),y=lbUtils.PointCloudUtils.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(g=w==null?void 0:w.radius)!=null?g:DEFAULT_RADIUS}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(v,[])}k({pointCloudBoxList:v,polygonList:D,lineList:S,pointCloudSphereList:y}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:ht,generateRects:W,update2DViewRect:lt,remove2DViewRect:dt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$2=require("../../components/customResizeHook/index.js"),index$1=require("../../constant/index.js"),styleString=require("../../constant/styleString.js"),Actions=require("../Actions.js"),index=require("../../utils/index.js"),AnnotationDataUtils=require("../../utils/AnnotationDataUtils.js"),ConfigUtils=require("../../utils/ConfigUtils.js"),data=require("../../utils/data.js"),StepUtils=require("../../utils/StepUtils.js"),ToolUtils=require("../../utils/ToolUtils.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),antd=require("antd"),es=require("antd/es"),_=require("lodash"),actionCreators=require("./actionCreators.js"),ToolType=require("../../data/enums/ToolType.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,s)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,__spreadValues=(e,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(e,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(e,s,t[s]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,s)=>new Promise((g,a)=>{var S=I=>{try{N(s.next(I))}catch(m){a(m)}},A=I=>{try{N(s.throw(I))}catch(m){a(m)}},N=I=>I.done?g(I.value):Promise.resolve(I.value).then(S,A);N((s=s.apply(e,t)).next())});const getStepConfig=(e,t)=>e.find(s=>s.step===t),initialState={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},getTotalPage=e=>{const{imgList:t,imgPageSize:s}=e;return Math.ceil(t.length/s)},calcStepProgress=(e,t)=>e.reduce((s,g)=>{if(g){const a=g.result;if(index.jsonParser(a)[`step_${t}`])return s+1}return s},0)/e.length,updateToolInstance=(e,t)=>{const{step:s,stepList:g}=e,a=StepUtils.getCurrentStepInfo(s,g),S=ConfigUtils.ConfigUtils.jsonParser(a.config);if(ToolUtils.isVideoTool(a==null?void 0:a.tool)||ToolUtils.isAudioTool(a==null?void 0:a.tool)||ToolUtils.isPointCloudTool(a==null?void 0:a.tool)||[ToolType.EToolName.LLM,ToolType.EToolName.NLP].includes(a==null?void 0:a.tool))return;const A=document.getElementById("toolContainer");if(!A)throw"Not exist dom named id-toolContainer";const N=index$2.getFormatSize({width:window.innerWidth,height:window.innerHeight}),I=new lbAnnotation.AnnotationEngine({container:A,toolName:a.tool,size:N,imgNode:t,config:S,style:JSON.parse(styleString)});return{toolInstance:I==null?void 0:I.toolInstance,annotationEngine:I}},LoadFileAndFileData=(e,t)=>(s,g)=>__async(void 0,null,function*(){var a,S;const{stepList:A,step:N}=g().annotation,I=StepUtils.currentToolIsVideo(N,A),m=StepUtils.currentToolIsPointCloud(N,A),D=((a=StepUtils.getCurrentStepInfo(N,A))==null?void 0:a.tool)===ToolType.EToolName.LLM,y=((S=StepUtils.getCurrentStepInfo(N,A))==null?void 0:S.tool)===ToolType.EToolName.NLP,P=StepUtils.currentToolIsAudio(N,A);if(actionCreators.SetAnnotationLoading(s,!0),yield s(TryGetFileDataByAPI(e)),I){s(AfterVideoLoaded(e));return}if(m||D||P||y){s(AfterCommonLoaded(e));return}s(AfterImageLoaded(e,t))}),TryGetFileDataByAPI=e=>(t,s)=>__async(void 0,null,function*(){const{getFileData:g,imgList:a}=s().annotation;if(g){const S=yield g(a[e],e);t({type:Actions.ANNOTATION_ACTIONS.SET_FILE_DATA,payload:{fileData:S,index:e}})}}),AfterVideoLoaded=e=>t=>{t({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterCommonLoaded=e=>t=>{actionCreators.SetAnnotationLoading(t,!1),t({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterImageLoaded=(e,t)=>(s,g)=>{var a;const{toolInstance:S,imgList:A}=g().annotation,N=(a=A==null?void 0:A[e])==null?void 0:a.url;lbAnnotation.ImgUtils.load(N).then(I=>{actionCreators.SetAnnotationLoading(s,!1),s({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{imgNode:I,nextIndex:e,nextBasicIndex:t}})}).catch(()=>{actionCreators.SetAnnotationLoading(s,!1),S==null||S.setErrorImg(),s({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e,nextBasicIndex:t}})})},composeResultByToolInstance=({toolInstance:e,imgList:t,imgIndex:s,stepList:g,step:a=1})=>{var S,A,N,I;const m=((S=t[s])==null?void 0:S.result)||"",[D,y,P]=(A=e==null?void 0:e.exportData())!=null?A:[],x=(I=(N=e==null?void 0:e.exportCustomData)==null?void 0:N.call(e))!=null?I:{},B=data.composeResultWithBasicImgInfo(m,y),w=data.composeResult(B,{step:a,stepList:g},{rect:D},x);return t.map((b,F)=>F===s?__spreadValues(__spreadProps(__spreadValues({},b),{result:w}),P):__spreadValues({},b))},annotationReducer=(e=__spreadValues({},initialState),t)=>{var s,g,a,S,A,N,I,m,D,y,P,x,B,w,b,F,G,M,V,q,k,H,z,K,W;switch(t.type){case Actions.ANNOTATION_ACTIONS.INIT_ALL_STATE:return __spreadValues(__spreadValues({},e),initialState);case Actions.ANNOTATION_ACTIONS.UPDATE_TOOL_INSTANCE:return __spreadProps(__spreadValues({},e),{toolInstance:t.payload.toolInstance});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_LIST:return __spreadProps(__spreadValues({},e),{imgList:t.payload.imgList});case Actions.ANNOTATION_ACTIONS.CALC_STEP_PROGRESS:{const{imgList:n,step:o}=e,l=calcStepProgress(n,o);return __spreadProps(__spreadValues({},e),{stepProgress:l})}case Actions.ANNOTATION_ACTIONS.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:o,step:l,stepList:r,toolInstance:u,onSubmit:i,resultList:p}=e;if(!u||!n[o])return e;const d=((s=n[o])==null?void 0:s.result)||"",[,c,T]=(g=u==null?void 0:u.exportData())!=null?g:[],O=(S=(a=u==null?void 0:u.exportCustomData)==null?void 0:a.call(u))!=null?S:{},f=data.composeResultWithBasicImgInfo(d,c),E=data.composeResult(f,{step:l,stepList:r},{rect:p},O),L=e.imgList.map((v,C)=>{if(C===o){const U=AnnotationDataUtils.dataCorrection(E,d,l,r);return __spreadValues(__spreadProps(__spreadValues({},v),{result:U}),T)}return v});if(((A=t.payload)==null?void 0:A.submitType)===index$1.ESubmitType.SyncImgList)return __spreadProps(__spreadValues({},e),{imgList:L});i&&i([L[o]],(N=t.payload)==null?void 0:N.submitType,o,L);const R=calcStepProgress(L,l);return __spreadProps(__spreadValues({},e),{stepProgress:R,imgList:L})}case Actions.ANNOTATION_ACTIONS.SAVE_RESULT:{const{imgList:n,imgIndex:o,onSave:l}=e;return l==null||l(n[o],o,n),__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SUBMIT_RESULT:{const{imgList:n,basicIndex:o,resultList:l,toolInstance:r,basicResultList:u}=e;if(!r)return e;const[i]=(I=r==null?void 0:r.exportData())!=null?I:[];let p=i;if((u==null?void 0:u.length)>0){const d=(m=u[o])==null?void 0:m.id,c=i.map(T=>__spreadProps(__spreadValues({},T),{sourceID:d}));p=___default.default.cloneDeep(l).filter(T=>T.sourceID!==d),p.push(...c)}return __spreadProps(__spreadValues({},e),{resultList:p,imgList:n})}case Actions.ANNOTATION_ACTIONS.SET_BASIC_INDEX:{const{toolInstance:n,step:o,imgList:l,imgIndex:r,stepList:u,annotationEngine:i,resultList:p,basicResultList:d}=e;if(!n||!i)return e;const c=t.payload.basicIndex,T=(D=d[c])==null?void 0:D.id,O=index.jsonParser((y=l[r])==null?void 0:y.result),f=(p||[]).filter(U=>U.sourceID===T),E=getStepConfig(u,o),{dataSourceStep:L,tool:R}=E,v=getStepConfig(u,L);let C=[];return L&&R&&(C=(P=O[`step_${L}`])==null?void 0:P.result,(C==null?void 0:C.length)>0?(i==null||i.setBasicInfo(v.tool,C[c]),i==null||i.launchOperation()):(i==null||i.setBasicInfo(v.tool),i==null||i.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),n==null||n.setResult(f),n==null||n.history.initRecord(f,!0),__spreadProps(__spreadValues({},e),{basicIndex:c})}case Actions.ANNOTATION_ACTIONS.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=t.payload;return __spreadProps(__spreadValues({},e),{triggerEventAfterIndexChanged:!!n})}case Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA:{const{imgList:n,step:o,toolInstance:l,annotationEngine:r,stepList:u}=e;if(!l)return __spreadProps(__spreadValues({},e),{imgIndex:t.payload.nextIndex});const i=StepUtils.getCurrentStepInfo(o,u),{nextIndex:p,imgNode:d,nextBasicIndex:c,imgError:T}=t.payload,O=c!=null?c:0,f=index.jsonParser((x=n[p])==null?void 0:x.result),E=f[`step_${i.step}`],L=!E,R={rotate:(B=f.rotate)!=null?B:0,valid:(w=f.valid)!=null?w:!0};d&&T!==!0?r==null||r.setImgNode(d,R):l==null||l.setValid(R.valid);const v=getStepConfig(u,i.step),{dataSourceStep:C,tool:U}=v,$=getStepConfig(u,C),X=C&&U,h=(F=(b=f[`step_${C}`])==null?void 0:b.result)!=null?F:[],j=AnnotationDataUtils.getInitialResultList(E==null?void 0:E.result,l,v,h,L);if(r==null||r.launchOperation(),X&&((h==null?void 0:h.length)>0?r==null||r.setBasicInfo($.tool,h[O]):(r==null||r.setBasicInfo($.tool),r==null||r.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),i.tool!=="check"){const Y=(M=(G=h[O])==null?void 0:G.id)!=null?M:"",J=X?j.filter(Z=>lbAnnotation.CommonToolUtils.isSameSourceID(Z.sourceID,Y)):j;(V=l==null?void 0:l.history)==null||V.initRecord(j,!0),l==null||l.setResult(J)}return __spreadProps(__spreadValues({},e),{imgIndex:p,basicIndex:O,basicResultList:h,resultList:j})}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_CONFIG:return __spreadProps(__spreadValues({},e),{config:(q=t.payload.config)!=null?q:"{}"});case Actions.ANNOTATION_ACTIONS.SET_TASK_STEP_LIST:{const{stepList:n}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n})}case Actions.ANNOTATION_ACTIONS.SET_TASK_CONFIG:{const{stepList:n,step:o}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n,step:o})}case Actions.ANNOTATION_ACTIONS.INIT_TOOL:{const{imgNode:n}=e,o=updateToolInstance(e,n);if(o){const{toolInstance:l,annotationEngine:r}=o;return __spreadProps(__spreadValues({},e),{toolInstance:l,annotationEngine:r})}return __spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SET_TOOL:{const n=(k=t.payload)==null?void 0:k.instance;return n?__spreadProps(__spreadValues({},e),{toolInstance:n}):__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SUBMIT:return __spreadProps(__spreadValues({},e),{onSubmit:t.payload.onSubmit});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SAVE:return __spreadProps(__spreadValues({},e),{onSave:t.payload.onSave});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_PAGE_CHANGE:return __spreadProps(__spreadValues({},e),{onPageChange:t.payload.onPageChange});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT:return __spreadProps(__spreadValues({},e),{predictionResult:t.payload.result});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT_VISIBLE:return __spreadProps(__spreadValues({},e),{predictionResultVisible:t.payload.visible});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_STEP_CHANGE:return __spreadProps(__spreadValues({},e),{onStepChange:t.payload.onStepChange});case Actions.ANNOTATION_ACTIONS.UPDATE_GET_FILE_DATA:return __spreadProps(__spreadValues({},e),{getFileData:t.payload.getFileData});case Actions.ANNOTATION_ACTIONS.UPDATE_PAGE_SIZE:return __spreadProps(__spreadValues({},e),{pageSize:t.payload.pageSize});case Actions.ANNOTATION_ACTIONS.UPDATE_LOAD_FILE_LIST:return __spreadProps(__spreadValues({},e),{loadFileList:t.payload.loadFileList});case Actions.ANNOTATION_ACTIONS.UPDATE_BEFORE_ROTATE:return __spreadProps(__spreadValues({},e),{beforeRotate:t.payload.beforeRotate});case Actions.ANNOTATION_ACTIONS.UPDATE_PRE_DATA_PROCESS:return __spreadProps(__spreadValues({},e),{preDataProcess:t.payload.preDataProcess});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_INDEX_BY_EXTERNAL:return __spreadProps(__spreadValues({},e),{getImgIndexByExternal:t.payload.getImgIndexByExternal});case Actions.ANNOTATION_ACTIONS.SKIP_BEFORE_PAGE_TURNING:return __spreadProps(__spreadValues({},e),{skipBeforePageTurning:t.payload.skipBeforePageTurning});case Actions.ANNOTATION_ACTIONS.SET_FILE_DATA:{const{fileData:n,index:o}=t.payload,{imgList:l}=e,r=[...l];return r[o]=__spreadValues(__spreadValues({},r[o]),n),__spreadProps(__spreadValues({},e),{imgList:r})}case Actions.ANNOTATION_ACTIONS.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:o}=e;return o&&o()===!1||(H=n==null?void 0:n.updateRotate)==null||H.call(n),e}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=e,o=(z=n==null?void 0:n.valid)!=null?z:!0;return antd.Modal.destroyAll(),antd.Modal.confirm({content:lbUtils.i18n.t(o?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!o)},okText:lbUtils.i18n.t("Confirm"),cancelText:lbUtils.i18n.t("Cancel")}),e}case Actions.ANNOTATION_ACTIONS.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:o,imgList:l,step:r}=e;if(!n)return e;if(o===0||o>=l.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),e;const u=l[o-1].result;if(!u)return e;const i=AnnotationDataUtils.copyResultChange(u,r,(K=l[o].result)!=null?K:"");l[o]=__spreadProps(__spreadValues({},l[o]),{result:i});const d=index.jsonParser(i)[`step_${r}`],c=(d==null?void 0:d.result)||[];return n==null||n.setResult(c),n==null||n.history.pushHistory(c),(W=n==null?void 0:n.asyncData)==null||W.call(n,l[o]),__spreadProps(__spreadValues({},e),{imgList:[...l]})}case Actions.ANNOTATION_ACTIONS.SET_STEP:{const{stepList:n,annotationEngine:o}=e,{toStep:l}=t.payload;if(o){const r=getStepConfig(n,l);return o==null||o.setToolName(r.tool,r.config),__spreadProps(__spreadValues({},e),{step:l,toolInstance:o==null?void 0:o.toolInstance})}return __spreadProps(__spreadValues({},e),{step:l})}case Actions.ANNOTATION_ACTIONS.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loadPCDFileLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_LOADING:{const{loading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{pointCloudLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_CHECK_MODE:{const{checkMode:n}=t.payload;return __spreadProps(__spreadValues({},e),{checkMode:!!n})}case Actions.ANNOTATION_ACTIONS.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=t.payload;return __spreadProps(__spreadValues({},e),{highlightAttribute:n})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:o,rangeIndex:l,imgList:r}=t.payload,{imgIndex:u,onSubmit:i}=e,p=[],d=r.map((c,T)=>{if(lbAnnotation.MathUtils.isInRange(T,l)){const O=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateTrackID({id:n,newID:o,result:c.result})});return p.push({imgIndex:T,newInfo:O}),O}return c});return i&&i([d[u]],index$1.ESubmitType.BatchUpdateTrackID,u,d,{updateImgList:p}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:o,rangeIndex:l}=t.payload,{imgList:r,imgIndex:u,onSubmit:i}=e,p=[],d=r.map((c,T)=>{if(lbAnnotation.MathUtils.isInRange(T,l)){const O=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateResultByTrackID({id:n,newData:o,result:c.result})});return p.push({imgIndex:T,newInfo:O}),O}return c});return i&&i([d[u]],index$1.ESubmitType.BatchUpdateTrackID,u,d,{updateImgList:p}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:o,stepList:l,step:r,predictionResult:u}=e,i={};u.forEach(T=>{const{index:O}=T;i[O]=___default.default.pick(T,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const p=`step_${r}`,d=[],c=o.map((T,O)=>{if(i[O]){const f=T.result==="{}"?index.jsonParser(data.composeResult("",{step:r,stepList:l},{rect:[]},{})):index.jsonParser(T.result);f[p].result.push(i[O]);const E=__spreadProps(__spreadValues({},T),{result:JSON.stringify(f)});return d.push({imgIndex:O,newInfo:E}),E}return T});return n==null||n(c,index$1.ESubmitType.BatchUpdateImgList,-1,c,{updateImgList:d}),__spreadProps(__spreadValues({},e),{imgList:c})}default:return e}};exports.LoadFileAndFileData=LoadFileAndFileData,exports.annotationReducer=annotationReducer,exports.composeResultByToolInstance=composeResultByToolInstance,exports.getStepConfig=getStepConfig,exports.getTotalPage=getTotalPage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$2=require("../../components/customResizeHook/index.js"),index$1=require("../../constant/index.js"),styleString=require("../../constant/styleString.js"),Actions=require("../Actions.js"),index=require("../../utils/index.js"),AnnotationDataUtils=require("../../utils/AnnotationDataUtils.js"),ConfigUtils=require("../../utils/ConfigUtils.js"),data=require("../../utils/data.js"),StepUtils=require("../../utils/StepUtils.js"),ToolUtils=require("../../utils/ToolUtils.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),antd=require("antd"),es=require("antd/es"),_=require("lodash"),actionCreators=require("./actionCreators.js"),ToolType=require("../../data/enums/ToolType.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,l)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,__spreadValues=(e,t)=>{for(var l in t||(t={}))__hasOwnProp.call(t,l)&&__defNormalProp(e,l,t[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(t))__propIsEnum.call(t,l)&&__defNormalProp(e,l,t[l]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,l)=>new Promise((g,u)=>{var S=I=>{try{N(l.next(I))}catch(m){u(m)}},A=I=>{try{N(l.throw(I))}catch(m){u(m)}},N=I=>I.done?g(I.value):Promise.resolve(I.value).then(S,A);N((l=l.apply(e,t)).next())});const getStepConfig=(e,t)=>e.find(l=>l.step===t),initialState={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},getTotalPage=e=>{const{imgList:t,imgPageSize:l}=e;return Math.ceil(t.length/l)},calcStepProgress=(e,t)=>e.reduce((l,g)=>{if(g){const u=g.result;if(index.jsonParser(u)[`step_${t}`])return l+1}return l},0)/e.length,updateToolInstance=(e,t)=>{const{step:l,stepList:g}=e,u=StepUtils.getCurrentStepInfo(l,g),S=ConfigUtils.ConfigUtils.jsonParser(u.config);if(ToolUtils.isVideoTool(u==null?void 0:u.tool)||ToolUtils.isAudioTool(u==null?void 0:u.tool)||ToolUtils.isPointCloudTool(u==null?void 0:u.tool)||[ToolType.EToolName.LLM,ToolType.EToolName.NLP].includes(u==null?void 0:u.tool))return;const A=document.getElementById("toolContainer");if(!A)throw"Not exist dom named id-toolContainer";const N=index$2.getFormatSize({width:window.innerWidth,height:window.innerHeight}),I=new lbAnnotation.AnnotationEngine({container:A,toolName:u.tool,size:N,imgNode:t,config:S,style:JSON.parse(styleString)});return{toolInstance:I==null?void 0:I.toolInstance,annotationEngine:I}},LoadFileAndFileData=(e,t)=>(l,g)=>__async(void 0,null,function*(){var u,S;const{stepList:A,step:N}=g().annotation,I=StepUtils.currentToolIsVideo(N,A),m=StepUtils.currentToolIsPointCloud(N,A),D=((u=StepUtils.getCurrentStepInfo(N,A))==null?void 0:u.tool)===ToolType.EToolName.LLM,y=((S=StepUtils.getCurrentStepInfo(N,A))==null?void 0:S.tool)===ToolType.EToolName.NLP,P=StepUtils.currentToolIsAudio(N,A);if(actionCreators.SetAnnotationLoading(l,!0),yield l(TryGetFileDataByAPI(e)),I){l(AfterVideoLoaded(e));return}if(m||D||P||y){l(AfterCommonLoaded(e));return}l(AfterImageLoaded(e,t))}),TryGetFileDataByAPI=e=>(t,l)=>__async(void 0,null,function*(){const{getFileData:g,imgList:u}=l().annotation;if(g){const S=yield g(u[e],e);t({type:Actions.ANNOTATION_ACTIONS.SET_FILE_DATA,payload:{fileData:S,index:e}})}}),AfterVideoLoaded=e=>t=>{t({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterCommonLoaded=e=>t=>{actionCreators.SetAnnotationLoading(t,!1),t({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterImageLoaded=(e,t)=>(l,g)=>{var u;const{toolInstance:S,imgList:A}=g().annotation,N=(u=A==null?void 0:A[e])==null?void 0:u.url;lbAnnotation.ImgUtils.load(N).then(I=>{actionCreators.SetAnnotationLoading(l,!1),l({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{imgNode:I,nextIndex:e,nextBasicIndex:t}})}).catch(()=>{actionCreators.SetAnnotationLoading(l,!1),S==null||S.setErrorImg(),l({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e,nextBasicIndex:t}})})},composeResultByToolInstance=({toolInstance:e,imgList:t,imgIndex:l,stepList:g,step:u=1})=>{var S,A,N,I;const m=((S=t[l])==null?void 0:S.result)||"",[D,y,P]=(A=e==null?void 0:e.exportData())!=null?A:[],x=(I=(N=e==null?void 0:e.exportCustomData)==null?void 0:N.call(e))!=null?I:{},B=data.composeResultWithBasicImgInfo(m,y),w=data.composeResult(B,{step:u,stepList:g},{rect:D},x);return t.map((b,F)=>F===l?__spreadValues(__spreadProps(__spreadValues({},b),{result:w}),P):__spreadValues({},b))},annotationReducer=(e=__spreadValues({},initialState),t)=>{var l,g,u,S,A,N,I,m,D,y,P,x,B,w,b,F,G,M,V,q,k,H,z,K,W,$,X;switch(t.type){case Actions.ANNOTATION_ACTIONS.INIT_ALL_STATE:return __spreadValues(__spreadValues({},e),initialState);case Actions.ANNOTATION_ACTIONS.UPDATE_TOOL_INSTANCE:return __spreadProps(__spreadValues({},e),{toolInstance:t.payload.toolInstance});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_LIST:return __spreadProps(__spreadValues({},e),{imgList:t.payload.imgList});case Actions.ANNOTATION_ACTIONS.CALC_STEP_PROGRESS:{const{imgList:n,step:o}=e,s=calcStepProgress(n,o);return __spreadProps(__spreadValues({},e),{stepProgress:s})}case Actions.ANNOTATION_ACTIONS.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:o,step:s,stepList:i,toolInstance:a,onSubmit:r,resultList:p}=e;if(!a||!n[o])return e;const d=((l=n[o])==null?void 0:l.result)||"",[,c,T]=(g=a==null?void 0:a.exportData())!=null?g:[],O=(S=(u=a==null?void 0:a.exportCustomData)==null?void 0:u.call(a))!=null?S:{},f=data.composeResultWithBasicImgInfo(d,c),E=data.composeResult(f,{step:s,stepList:i},{rect:p},O),L=e.imgList.map((v,C)=>{if(C===o){const U=AnnotationDataUtils.dataCorrection(E,d,s,i);return __spreadValues(__spreadProps(__spreadValues({},v),{result:U}),T)}return v});if(((A=t.payload)==null?void 0:A.submitType)===index$1.ESubmitType.SyncImgList)return __spreadProps(__spreadValues({},e),{imgList:L});r&&r([L[o]],(N=t.payload)==null?void 0:N.submitType,o,L);const R=calcStepProgress(L,s);return __spreadProps(__spreadValues({},e),{stepProgress:R,imgList:L})}case Actions.ANNOTATION_ACTIONS.SAVE_RESULT:{const{imgList:n,imgIndex:o,onSave:s}=e;return s==null||s(n[o],o,n),__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SUBMIT_RESULT:{const{imgList:n,basicIndex:o,resultList:s,toolInstance:i,basicResultList:a}=e;if(!i)return e;const[r]=(I=i==null?void 0:i.exportData())!=null?I:[];let p=r;if((a==null?void 0:a.length)>0){const d=(m=a[o])==null?void 0:m.id,c=r.map(T=>__spreadProps(__spreadValues({},T),{sourceID:d}));p=___default.default.cloneDeep(s).filter(T=>T.sourceID!==d),p.push(...c)}return __spreadProps(__spreadValues({},e),{resultList:p,imgList:n})}case Actions.ANNOTATION_ACTIONS.SET_BASIC_INDEX:{const{toolInstance:n,step:o,imgList:s,imgIndex:i,stepList:a,annotationEngine:r,resultList:p,basicResultList:d}=e;if(!n||!r)return e;const c=t.payload.basicIndex,T=(D=d[c])==null?void 0:D.id,O=index.jsonParser((y=s[i])==null?void 0:y.result),f=(p||[]).filter(U=>U.sourceID===T),E=getStepConfig(a,o),{dataSourceStep:L,tool:R}=E,v=getStepConfig(a,L);let C=[];return L&&R&&(C=(P=O[`step_${L}`])==null?void 0:P.result,(C==null?void 0:C.length)>0?(r==null||r.setBasicInfo(v.tool,C[c]),r==null||r.launchOperation()):(r==null||r.setBasicInfo(v.tool),r==null||r.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),n==null||n.setResult(f),n==null||n.history.initRecord(f,!0),__spreadProps(__spreadValues({},e),{basicIndex:c})}case Actions.ANNOTATION_ACTIONS.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=t.payload;return __spreadProps(__spreadValues({},e),{triggerEventAfterIndexChanged:!!n})}case Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA:{const{imgList:n,step:o,toolInstance:s,annotationEngine:i,stepList:a}=e;if(!s)return __spreadProps(__spreadValues({},e),{imgIndex:t.payload.nextIndex});const r=StepUtils.getCurrentStepInfo(o,a),{nextIndex:p,imgNode:d,nextBasicIndex:c,imgError:T}=t.payload,O=c!=null?c:0,f=index.jsonParser((x=n[p])==null?void 0:x.result),E=f[`step_${r.step}`],L=!E,R={rotate:(B=f.rotate)!=null?B:0,valid:(w=f.valid)!=null?w:!0};d&&T!==!0?i==null||i.setImgNode(d,R):s==null||s.setValid(R.valid);const v=getStepConfig(a,r.step),{dataSourceStep:C,tool:U}=v,Y=getStepConfig(a,C),J=C&&U,h=(F=(b=f[`step_${C}`])==null?void 0:b.result)!=null?F:[],j=AnnotationDataUtils.getInitialResultList(E==null?void 0:E.result,s,v,h,L);if(i==null||i.launchOperation(),J&&((h==null?void 0:h.length)>0?i==null||i.setBasicInfo(Y.tool,h[O]):(i==null||i.setBasicInfo(Y.tool),i==null||i.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),r.tool!=="check"){const Z=(M=(G=h[O])==null?void 0:G.id)!=null?M:"",Q=J?j.filter(ee=>lbAnnotation.CommonToolUtils.isSameSourceID(ee.sourceID,Z)):j;(V=s==null?void 0:s.history)==null||V.initRecord(j,!0),s==null||s.setResult(Q)}return __spreadProps(__spreadValues({},e),{imgIndex:p,basicIndex:O,basicResultList:h,resultList:j})}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_CONFIG:return __spreadProps(__spreadValues({},e),{config:(q=t.payload.config)!=null?q:"{}"});case Actions.ANNOTATION_ACTIONS.SET_TASK_STEP_LIST:{const{stepList:n}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n})}case Actions.ANNOTATION_ACTIONS.SET_TASK_CONFIG:{const{stepList:n,step:o}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n,step:o})}case Actions.ANNOTATION_ACTIONS.INIT_TOOL:{const{imgNode:n}=e,o=updateToolInstance(e,n);if(o){const{toolInstance:s,annotationEngine:i}=o;return __spreadProps(__spreadValues({},e),{toolInstance:s,annotationEngine:i})}return __spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SET_TOOL:{const n=(k=t.payload)==null?void 0:k.instance;return n?__spreadProps(__spreadValues({},e),{toolInstance:n}):__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SUBMIT:return __spreadProps(__spreadValues({},e),{onSubmit:t.payload.onSubmit});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SAVE:return __spreadProps(__spreadValues({},e),{onSave:t.payload.onSave});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_PAGE_CHANGE:return __spreadProps(__spreadValues({},e),{onPageChange:t.payload.onPageChange});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT:return __spreadProps(__spreadValues({},e),{predictionResult:t.payload.result});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT_VISIBLE:return __spreadProps(__spreadValues({},e),{predictionResultVisible:t.payload.visible});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_STEP_CHANGE:return __spreadProps(__spreadValues({},e),{onStepChange:t.payload.onStepChange});case Actions.ANNOTATION_ACTIONS.UPDATE_GET_FILE_DATA:return __spreadProps(__spreadValues({},e),{getFileData:t.payload.getFileData});case Actions.ANNOTATION_ACTIONS.UPDATE_PAGE_SIZE:return __spreadProps(__spreadValues({},e),{pageSize:t.payload.pageSize});case Actions.ANNOTATION_ACTIONS.UPDATE_LOAD_FILE_LIST:return __spreadProps(__spreadValues({},e),{loadFileList:t.payload.loadFileList});case Actions.ANNOTATION_ACTIONS.UPDATE_BEFORE_ROTATE:return __spreadProps(__spreadValues({},e),{beforeRotate:t.payload.beforeRotate});case Actions.ANNOTATION_ACTIONS.UPDATE_PRE_DATA_PROCESS:return __spreadProps(__spreadValues({},e),{preDataProcess:t.payload.preDataProcess});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_INDEX_BY_EXTERNAL:return __spreadProps(__spreadValues({},e),{getImgIndexByExternal:t.payload.getImgIndexByExternal});case Actions.ANNOTATION_ACTIONS.SKIP_BEFORE_PAGE_TURNING:return __spreadProps(__spreadValues({},e),{skipBeforePageTurning:t.payload.skipBeforePageTurning});case Actions.ANNOTATION_ACTIONS.SET_FILE_DATA:{const{fileData:n,index:o}=t.payload,{imgList:s}=e,i=[...s];return i[o]=__spreadValues(__spreadValues({},i[o]),n),__spreadProps(__spreadValues({},e),{imgList:i})}case Actions.ANNOTATION_ACTIONS.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:o}=e;return o&&o()===!1||(H=n==null?void 0:n.updateRotate)==null||H.call(n),e}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=e,o=(z=n==null?void 0:n.valid)!=null?z:!0;return antd.Modal.destroyAll(),antd.Modal.confirm({content:lbUtils.i18n.t(o?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!o)},okText:lbUtils.i18n.t("Confirm"),cancelText:lbUtils.i18n.t("Cancel")}),e}case Actions.ANNOTATION_ACTIONS.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:o,imgList:s,step:i}=e;if(!n)return e;if(o===0||o>=s.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),e;const a=s[o-1].result;if(!a)return e;const r=AnnotationDataUtils.copyResultChange({copyResult:a,step:i,currentResult:(K=s[o].result)!=null?K:"",preMappingImgList:(W=s[o-1].mappingImgList)!=null?W:[],mappingImgList:($=s[o].mappingImgList)!=null?$:[]});s[o]=__spreadProps(__spreadValues({},s[o]),{result:r});const d=index.jsonParser(r)[`step_${i}`],c=(d==null?void 0:d.result)||[];return n==null||n.setResult(c),n==null||n.history.pushHistory(c),(X=n==null?void 0:n.asyncData)==null||X.call(n,s[o]),__spreadProps(__spreadValues({},e),{imgList:[...s]})}case Actions.ANNOTATION_ACTIONS.SET_STEP:{const{stepList:n,annotationEngine:o}=e,{toStep:s}=t.payload;if(o){const i=getStepConfig(n,s);return o==null||o.setToolName(i.tool,i.config),__spreadProps(__spreadValues({},e),{step:s,toolInstance:o==null?void 0:o.toolInstance})}return __spreadProps(__spreadValues({},e),{step:s})}case Actions.ANNOTATION_ACTIONS.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loadPCDFileLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_LOADING:{const{loading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{pointCloudLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_CHECK_MODE:{const{checkMode:n}=t.payload;return __spreadProps(__spreadValues({},e),{checkMode:!!n})}case Actions.ANNOTATION_ACTIONS.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=t.payload;return __spreadProps(__spreadValues({},e),{highlightAttribute:n})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:o,rangeIndex:s,imgList:i}=t.payload,{imgIndex:a,onSubmit:r}=e,p=[],d=i.map((c,T)=>{if(lbAnnotation.MathUtils.isInRange(T,s)){const O=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateTrackID({id:n,newID:o,result:c.result})});return p.push({imgIndex:T,newInfo:O}),O}return c});return r&&r([d[a]],index$1.ESubmitType.BatchUpdateTrackID,a,d,{updateImgList:p}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:o,rangeIndex:s}=t.payload,{imgList:i,imgIndex:a,onSubmit:r}=e,p=[],d=i.map((c,T)=>{if(lbAnnotation.MathUtils.isInRange(T,s)){const O=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateResultByTrackID({id:n,newData:o,result:c.result})});return p.push({imgIndex:T,newInfo:O}),O}return c});return r&&r([d[a]],index$1.ESubmitType.BatchUpdateTrackID,a,d,{updateImgList:p}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:o,stepList:s,step:i,predictionResult:a}=e,r={};a.forEach(T=>{const{index:O}=T;r[O]=___default.default.pick(T,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const p=`step_${i}`,d=[],c=o.map((T,O)=>{if(r[O]){const f=T.result==="{}"?index.jsonParser(data.composeResult("",{step:i,stepList:s},{rect:[]},{})):index.jsonParser(T.result);f[p].result.push(r[O]);const E=__spreadProps(__spreadValues({},T),{result:JSON.stringify(f)});return d.push({imgIndex:O,newInfo:E}),E}return T});return n==null||n(c,index$1.ESubmitType.BatchUpdateImgList,-1,c,{updateImgList:d}),__spreadProps(__spreadValues({},e),{imgList:c})}default:return e}};exports.LoadFileAndFileData=LoadFileAndFileData,exports.annotationReducer=annotationReducer,exports.composeResultByToolInstance=composeResultByToolInstance,exports.getStepConfig=getStepConfig,exports.getTotalPage=getTotalPage;
@@ -69,6 +69,7 @@ export declare const usePointCloudViews: () => {
69
69
  updateViewsByDefaultSize?: undefined;
70
70
  generateRects?: undefined;
71
71
  update2DViewRect?: undefined;
72
+ remove2DViewRect?: undefined;
72
73
  } | {
73
74
  topViewAddSphere: ({ newPoint, size, zoom, trackConfigurable, }: {
74
75
  newPoint: IPointUnit;
@@ -105,4 +106,8 @@ export declare const usePointCloudViews: () => {
105
106
  boxID: string;
106
107
  imageName: string;
107
108
  }) => IPointCloudBox[] | undefined;
109
+ remove2DViewRect: (params: {
110
+ boxID: string;
111
+ imageName: string;
112
+ }) => IPointCloudBox[] | undefined;
108
113
  };
@@ -24,5 +24,5 @@ export interface IVideoAnnotateProps {
24
24
  }
25
25
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IVideoAnnotateProps>, import("react-redux").Omit<IVideoAnnotateProps & {
26
26
  children?: React.ReactNode;
27
- }, "stepList" | "step" | "imgIndex" | "imgList" | "config" | "skipBeforePageTurning" | "loading" | "path" | "stepInfo">>;
27
+ }, "step" | "stepList" | "imgIndex" | "imgList" | "config" | "skipBeforePageTurning" | "loading" | "path" | "stepInfo">>;
28
28
  export default _default;
@@ -1,5 +1,57 @@
1
1
  import { IStepInfo } from '@/types/step';
2
+ import { IMappingImg } from '@/types/data';
3
+ interface ICopyResultChangeParams {
4
+ copyResult: string;
5
+ step: number;
6
+ currentResult: string;
7
+ mappingImgList: IMappingImg[];
8
+ preMappingImgList: IMappingImg[];
9
+ }
10
+ interface IGetNextPath {
11
+ prePath: string;
12
+ preMappingImgList: IMappingImg[];
13
+ nextMappingImgList: IMappingImg[];
14
+ }
15
+ interface ICopyResultItemHandlerParams {
16
+ item: any;
17
+ key?: string | number;
18
+ parent: any;
19
+ mappingImgList: IMappingImg[];
20
+ preMappingImgList: IMappingImg[];
21
+ }
2
22
  export default class AnnotationDataUtils {
23
+ /**
24
+ * Performs a depth-first traversal of an object or array, executing a callback function on each element.
25
+ *
26
+ * @param {any} objOrArr - The object or array to be traversed.
27
+ * @param {Function} callback - The callback function to be executed on each element.
28
+ * The callback function takes three parameters: element, key, and parent.
29
+ * @param {string | number} [key] - The key or index of the current element in its parent (optional).
30
+ * @param {any} [parent] - The parent of the current element (optional).
31
+ */
32
+ static traverseDF(objOrArr: any, callback: (element: any, key?: string | number, parent?: any) => void, key?: string | number, parent?: any): void;
33
+ /**
34
+ * Calculates the next path based on the provided parameters.
35
+ *
36
+ * @param {IGetNextPath} params - The object containing necessary information.
37
+ * @param {string} params.prePath - The current path.
38
+ * @param {IImgList} params.preMappingImgList - The list of current mapping images.
39
+ * @param {IImgList} params.nextMappingImgList - The list of next mapping images.
40
+ * @returns {string} The next path, returns an empty string if not found.
41
+ */
42
+ static getNextPath(params: IGetNextPath): string;
43
+ /**
44
+ * Handles the processing of individual items during the traversal of results or resultRect.
45
+ * This function updates specific properties of the parent object based on the key of the current item.
46
+ *
47
+ * @param {ICopyResultItemHandlerParams} params - Parameters containing the current item, its key, parent object, and image lists.
48
+ * @param {ICopyResultItemHandlerParams.item} item - The current item being processed.
49
+ * @param {ICopyResultItemHandlerParams.key} key - The key associated with the current item.
50
+ * @param {ICopyResultItemHandlerParams.parent} parent - The parent object of the current item.
51
+ * @param {ICopyResultItemHandlerParams.mappingImgList} mappingImgList - The list of images for mapping.
52
+ * @param {ICopyResultItemHandlerParams.preMappingImgList} preMappingImgList - The list of images before mapping.
53
+ */
54
+ static copyResultItemHandler(params: ICopyResultItemHandlerParams): void;
3
55
  /**
4
56
  * 复制上一张图片结果
5
57
  * @param copyResult 复制的结果
@@ -7,7 +59,7 @@ export default class AnnotationDataUtils {
7
59
  * @param currentResult 当前的步骤
8
60
  * @returns
9
61
  */
10
- static copyResultChange(copyResult: string, step: number, currentResult: string): string;
62
+ static copyResultChange(params: ICopyResultChangeParams): string;
11
63
  /**
12
64
  * 判断结果sourceID与依赖数据的id是否能对应
13
65
  * @param result
@@ -75,3 +127,4 @@ export default class AnnotationDataUtils {
75
127
  */
76
128
  static deleteRes(resData: any, dataSourceStep: number, deletedIds: string[], stepKeys: number[]): void;
77
129
  }
130
+ export {};
@@ -20,5 +20,5 @@ interface IProps {
20
20
  export declare const SingleTextInput: (props: any) => React.JSX.Element;
21
21
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IProps>, import("react-redux").Omit<IProps & {
22
22
  children?: React.ReactNode;
23
- }, "stepList" | "step" | "imgIndex" | "basicResultList" | "toolInstance" | "triggerEventAfterIndexChanged" | "dispatch">>;
23
+ }, "step" | "stepList" | "imgIndex" | "basicResultList" | "toolInstance" | "triggerEventAfterIndexChanged" | "dispatch">>;
24
24
  export default _default;
@@ -20,5 +20,5 @@ export declare const footerCls: string;
20
20
  export declare const FooterDivider: () => React.JSX.Element;
21
21
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IProps>, import("react-redux").Omit<IProps & {
22
22
  children?: React.ReactNode;
23
- }, "stepList" | "step" | "imgIndex" | "basicResultList" | "basicIndex" | "skipBeforePageTurning" | "totalPage">>;
23
+ }, "step" | "stepList" | "imgIndex" | "basicResultList" | "basicIndex" | "skipBeforePageTurning" | "totalPage">>;
24
24
  export default _default;
@@ -10,5 +10,5 @@ interface IProps {
10
10
  }
11
11
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IProps>, import("react-redux").Omit<IProps & {
12
12
  children?: React.ReactNode;
13
- }, "stepList" | "step">>;
13
+ }, "step" | "stepList">>;
14
14
  export default _default;
@@ -22,5 +22,5 @@ interface IToolHeaderProps {
22
22
  }
23
23
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IToolHeaderProps>, import("react-redux").Omit<IToolHeaderProps & {
24
24
  children?: React.ReactNode;
25
- }, "stepList" | "step" | "imgList" | "annotationEngine" | "toolName" | "stepInfo" | "stepProgress">>;
25
+ }, "step" | "stepList" | "imgList" | "annotationEngine" | "toolName" | "stepInfo" | "stepProgress">>;
26
26
  export default _default;
@@ -1 +1 @@
1
- "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index=require("./index.js"),ToolType=require("../data/enums/ToolType.js"),_=require("lodash"),StepUtils=require("./StepUtils.js");function _interopDefaultLegacy(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,e,t)=>e in i?__defProp(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,__spreadValues=(i,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(i,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(i,t,e[t]);return i},__spreadProps=(i,e)=>__defProps(i,__getOwnPropDescs(e));class AnnotationDataUtils{static copyResultChange(e,t,r){try{const s=index.jsonParser(e),n=index.jsonParser(r),o=`step_${t}`;if(s[o]){const a=s[o];if(a.result)return a.result=a.result.map(u=>__spreadProps(__spreadValues({},u),{id:lbAnnotation.uuid(8,62)})),n[o]=a,JSON.stringify(n)}return e}catch(s){return e}}static isResultSourceMatchedDependence(e,t){const r=e==null?void 0:e.map(n=>n.sourceID).sort(),s=t==null?void 0:t.map(n=>n.id).sort();return ___default.default.isEqual(r,s)}static deltaUpdateBasicResultList(e,t){const r=e==null?void 0:e.map(s=>s.sourceID).sort();return t.filter(s=>!r.includes(s.id))}static getInitialResultList(e,t,r,s,n){const o=e!=null?e:[];switch(r.tool){case ToolType.EToolName.Tag:case ToolType.EToolName.Text:{if(r.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(o,s);if(a.length>0)return o.concat(t.getInitResultList(r.dataSourceStep,a))}return n!==!0?o:t.getInitResultList(r.dataSourceStep,s)}default:return o}}static dataCorrection(e,t,r,s){var n,o;try{const u=`step_${StepUtils.getStepInfo(r,s).step}`,l=index.jsonParser(e),f=index.jsonParser(t),d=(n=l[u])==null?void 0:n.result,c=(o=f[u])==null?void 0:o.result;if(!c||___default.default.isEqual(d.sort(this.idCmp),c.sort(this.idCmp)))return e;const p=this.findDeletedIds(d,c);if(p.length===0)return e;const m=r,h=this.getStepKeys(l).sort();return this.deleteRes(l,m,p,h),JSON.stringify(l)}catch(a){return console.error(a),e}}static idCmp(e,t){const r=e.id,s=t.id;return r<s?-1:r>s?1:0}static findDeletedIds(e,t){return this.findDeletedItems(t,e).map(r=>r.id)}static findDeletedItems(e,t){const r=[];return e.forEach(s=>{t.some(o=>o.id===s.id)||r.push(s)}),r}static getStepKeys(e){return Object.keys(e).map(t=>parseInt(t.replace("step_",""),10)).filter(t=>!isNaN(t))}static deleteRes(e,t,r,s){s.forEach(n=>{if(n>t){const o=e[`step_${n}`];if([ToolType.EToolName.FolderTag,ToolType.EToolName.Segmentation].includes(o.tool))return;if(o.dataSourceStep===t){const a=[];o.result=o.result.filter(u=>r.includes(u.sourceID)?(a.push(u.id),!1):!0),this.deleteRes(e,n,a,s)}else o.result=o.result.filter(a=>!r.includes(a.sourceID))}})}}module.exports=AnnotationDataUtils;
1
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index=require("./index.js"),ToolType=require("../data/enums/ToolType.js"),_=require("lodash"),StepUtils=require("./StepUtils.js");function _interopDefaultLegacy(c){return c&&typeof c=="object"&&"default"in c?c:{default:c}}var ___default=_interopDefaultLegacy(_);class AnnotationDataUtils{static traverseDF(t,e,s,i){e(t,s,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((n,r)=>{this.traverseDF(n,e,r,t)}):Object.keys(t).forEach(n=>{this.traverseDF(t[n],e,n,t)}))}static getNextPath(t){var e,s,i;const{prePath:n,preMappingImgList:r,nextMappingImgList:a}=t,u=(s=(e=r==null?void 0:r.find(l=>l.path===n))==null?void 0:e.calib)==null?void 0:s.calName,o=(i=a.find(l=>{var d;return((d=l.calib)==null?void 0:d.calName)===u}))==null?void 0:i.path;return o!=null?o:""}static copyResultItemHandler(t){const{item:e,key:s,parent:i,mappingImgList:n,preMappingImgList:r}=t;s==="id"&&(i.id=lbAnnotation.uuid(8,62)),s==="imageName"&&(i.imageName=this.getNextPath({prePath:e,preMappingImgList:r,nextMappingImgList:n}))}static copyResultChange(t){const{copyResult:e,step:s,currentResult:i,mappingImgList:n,preMappingImgList:r}=t;try{const a=index.jsonParser(e),u=index.jsonParser(i),o=`step_${s}`;if(a[o]){const l=a[o];return["result","resultRect"].forEach(p=>{l[p]&&this.traverseDF(l[p],(f,m,h)=>{this.copyResultItemHandler({item:f,key:m,parent:h,mappingImgList:n,preMappingImgList:r})})}),u[o]=l,JSON.stringify(u)}return e}catch(a){return e}}static isResultSourceMatchedDependence(t,e){const s=t==null?void 0:t.map(n=>n.sourceID).sort(),i=e==null?void 0:e.map(n=>n.id).sort();return ___default.default.isEqual(s,i)}static deltaUpdateBasicResultList(t,e){const s=t==null?void 0:t.map(i=>i.sourceID).sort();return e.filter(i=>!s.includes(i.id))}static getInitialResultList(t,e,s,i,n){const r=t!=null?t:[];switch(s.tool){case ToolType.EToolName.Tag:case ToolType.EToolName.Text:{if(s.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(r,i);if(a.length>0)return r.concat(e.getInitResultList(s.dataSourceStep,a))}return n!==!0?r:e.getInitResultList(s.dataSourceStep,i)}default:return r}}static dataCorrection(t,e,s,i){var n,r;try{const u=`step_${StepUtils.getStepInfo(s,i).step}`,o=index.jsonParser(t),l=index.jsonParser(e),d=(n=o[u])==null?void 0:n.result,p=(r=l[u])==null?void 0:r.result;if(!p||___default.default.isEqual(d.sort(this.idCmp),p.sort(this.idCmp)))return t;const f=this.findDeletedIds(d,p);if(f.length===0)return t;const m=s,h=this.getStepKeys(o).sort();return this.deleteRes(o,m,f,h),JSON.stringify(o)}catch(a){return console.error(a),t}}static idCmp(t,e){const s=t.id,i=e.id;return s<i?-1:s>i?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(s=>s.id)}static findDeletedItems(t,e){const s=[];return t.forEach(i=>{e.some(r=>r.id===i.id)||s.push(i)}),s}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,s,i){i.forEach(n=>{if(n>e){const r=t[`step_${n}`];if([ToolType.EToolName.FolderTag,ToolType.EToolName.Segmentation].includes(r.tool))return;if(r.dataSourceStep===e){const a=[];r.result=r.result.filter(u=>s.includes(u.sourceID)?(a.push(u.id),!1):!0),this.deleteRes(t,n,a,i)}else r.result=r.result.filter(a=>!s.includes(a.sourceID))}})}}module.exports=AnnotationDataUtils;
@@ -1 +1 @@
1
- import{useLatest as S}from"ahooks";import{Spin as H,message as K}from"antd/es";import P,{useContext as Q,useRef as j,useState as W,useMemo as X,useCallback as Y,useEffect as u}from"react";import{connect as Z}from"react-redux";import{useTranslation as ee}from"react-i18next";import{usePointCloudViews as te}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as re}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ne}from"../../store/annotation/map.js";import{LabelBeeContext as oe}from"../../store/ctx.js";import{PointCloud2DRectOperation as ie,ImgUtils as ae}from"@labelbee/lb-annotation";var ce=Object.defineProperty,le=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,E=(c,i,r)=>i in c?ce(c,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):c[i]=r,s=(c,i)=>{for(var r in i||(i={}))se.call(i,r)&&E(c,r,i[r]);if(B)for(var r of B(i))de.call(i,r)&&E(c,r,i[r]);return c},d=(c,i)=>le(c,ue(i));const pe=c=>{var i;const{mappingData:r,size:p,config:v,checkMode:A,afterImgOnLoad:N}=c,_=(i=r==null?void 0:r.url)!=null?i:"",{t:U}=ee(),{pointCloudBoxList:f,setPointCloudResult:k,defaultAttribute:R,rectList:g,addRectIn2DView:M,updateRectIn2DView:C,removeRectIn2DView:z}=Q(re),{update2DViewRect:F}=te(),b=P.useRef(null),t=j(null),I=S(F),O=j(null),[T,h]=W(!0),D=X(()=>g==null?void 0:g.filter(e=>e.imageName===(r==null?void 0:r.path)),[r==null?void 0:r.path,g]),m=S(r==null?void 0:r.path),x=e=>{var n;const{boxID:o}=e;if(o){const a=(n=I.current)==null?void 0:n.call(I,e);O.current=a,k(a);return}C(e)},L=e=>{m.current&&M(d(s({},e),{imageName:m.current}))},y=e=>{e.some(o=>o.boxID)&&K.warning(U("ProjectionFrameCannotBeDeleted")),z(e)},J=Y(()=>{let e=[];return f.forEach(n=>{const{rects:o=[],id:a,attribute:l,trackID:$}=n,V=o.find(G=>G.imageName===m.current),q=a+"_"+m.current;V&&(e=[...e,d(s({},V),{boxID:a,id:q,attribute:l,order:$})])}),e},[f]),w=()=>{var e,n,o;const a=J(),l=(e=t.current)==null?void 0:e.selectedRectID;(n=t.current)==null||n.setResult([...a,...D]),l&&((o=t.current)==null||o.setSelectedRectID(l))};return u(()=>{if(b.current){const e=new ie({container:b.current,size:p,config:d(s({},v),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:A});return t.current=e,t.current.init(),t.current.on("updateDragResult",x),t.current.on("afterAddingDrawingRect",L),t.current.on("deleteSelectedRects",y),()=>{var n,o,a,l;(n=t.current)==null||n.unbind("updateDragResult",x),(o=t.current)==null||o.unbind("afterAddingDrawingRect",L),(a=t.current)==null||a.unbind("deleteSelectedRects",y),(l=t.current)==null||l.destroy()}}},[]),u(()=>{h(!0),t.current&&_&&ae.load(_).then(e=>{t.current.setImgNode(e),N(e),h(!1)})},[_]),u(()=>{var e;(e=t.current)==null||e.setSize(p)},[p]),u(()=>{f!==O.current&&w()},[f]),u(()=>{var e,n,o;const a=D.find(l=>l.id===t.current.selectedRectID);(n=(e=t.current)==null?void 0:e.setDefaultAttribute)==null||n.call(e,R),a&&C(d(s({},(o=t.current)==null?void 0:o.selectedRect),{attribute:R})),w()},[R]),u(()=>{w()},[D]),u(()=>{var e,n,o,a;const l=(n=(e=t.current)==null?void 0:e.config)!=null?n:{};(a=t.current)==null||a.setConfig(JSON.stringify(d(s({},l),{attributeList:(o=v.attributeList)!=null?o:[]})))},[v.attributeList]),P.createElement(H,{spinning:T},P.createElement("div",{ref:b,style:s({position:"relative"},p)}))};var fe=Z(ne,null,null,{context:oe})(pe);export{fe as default};
1
+ import{useMemoizedFn as v,useLatest as K}from"ahooks";import{Spin as Q}from"antd/es";import C,{useContext as W,useRef as E,useState as X,useMemo as Y,useEffect as a}from"react";import{connect as Z}from"react-redux";import{usePointCloudViews as tt}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as et}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as rt}from"../../store/annotation/map.js";import{LabelBeeContext as nt}from"../../store/ctx.js";import{PointCloud2DRectOperation as ot,ImgUtils as it}from"@labelbee/lb-annotation";var ct=Object.defineProperty,ut=Object.defineProperties,lt=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable,N=(u,i,n)=>i in u?ct(u,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):u[i]=n,s=(u,i)=>{for(var n in i||(i={}))at.call(i,n)&&N(u,n,i[n]);if(A)for(var n of A(i))st.call(i,n)&&N(u,n,i[n]);return u},d=(u,i)=>ut(u,lt(i));const dt=u=>{var i;const{mappingData:n,size:p,config:_,checkMode:M,afterImgOnLoad:z}=u,R=(i=n==null?void 0:n.url)!=null?i:"",{pointCloudBoxList:g,setPointCloudResult:O,defaultAttribute:D,rectList:b,addRectIn2DView:F,updateRectIn2DView:h,removeRectIn2DView:k}=W(et),{update2DViewRect:U,remove2DViewRect:J}=tt(),w=C.useRef(null),r=E(null),x=v(U),L=v(J),P=E(null),[T,V]=X(!0),I=Y(()=>b==null?void 0:b.filter(t=>t.imageName===(n==null?void 0:n.path)),[n==null?void 0:n.path,b]),f=K(n==null?void 0:n.path),y=t=>{const{boxID:o}=t;if(o){const e=x==null?void 0:x(t);P.current=e,O(e);return}h(t)},S=t=>{f.current&&F(d(s({},t),{imageName:f.current}))},j=t=>{const o=t.find(e=>e.boxID);if(o){const e=L==null?void 0:L(o);P.current=e,O(e),m();return}k(t)},$=v(()=>{let t=[];return g.forEach(o=>{const{rects:e=[],id:c,attribute:l,trackID:q}=o,B=e.find(H=>H.imageName===f.current),G=c+"_"+f.current;B&&(t=[...t,d(s({},B),{boxID:c,id:G,attribute:l,order:q})])}),t}),m=v(()=>{var t,o,e;const c=$(),l=(t=r.current)==null?void 0:t.selectedRectID;(o=r.current)==null||o.setResult([...c,...I]),l&&((e=r.current)==null||e.setSelectedRectID(l))});return a(()=>{if(w.current){const t=new ot({container:w.current,size:p,config:d(s({},_),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:M});return r.current=t,r.current.init(),r.current.on("updateDragResult",y),r.current.on("afterAddingDrawingRect",S),r.current.on("deleteSelectedRects",j),()=>{var o,e,c,l;(o=r.current)==null||o.unbind("updateDragResult",y),(e=r.current)==null||e.unbind("afterAddingDrawingRect",S),(c=r.current)==null||c.unbind("deleteSelectedRects",j),(l=r.current)==null||l.destroy()}}},[]),a(()=>{V(!0),r.current&&R&&it.load(R).then(t=>{r.current.setImgNode(t),z(t),V(!1)})},[R]),a(()=>{var t;(t=r.current)==null||t.setSize(p)},[p]),a(()=>{g!==P.current&&m()},[g]),a(()=>{var t,o,e;const c=I.find(l=>l.id===r.current.selectedRectID);(o=(t=r.current)==null?void 0:t.setDefaultAttribute)==null||o.call(t,D),c&&h(d(s({},(e=r.current)==null?void 0:e.selectedRect),{attribute:D})),m()},[D]),a(()=>{m()},[I]),a(()=>{var t,o,e,c;const l=(o=(t=r.current)==null?void 0:t.config)!=null?o:{};(c=r.current)==null||c.setConfig(JSON.stringify(d(s({},l),{attributeList:(e=_.attributeList)!=null?e:[]})))},[_.attributeList]),C.createElement(Q,{spinning:T},C.createElement("div",{ref:w,style:s({position:"relative"},p)}))};var pt=Z(rt,null,null,{context:nt})(dt);export{pt as default};
@@ -1 +1 @@
1
- import{getClassName as m}from"../../utils/dom.js";import{cKeyCode as K,PointCloud as M}from"@labelbee/lb-annotation";import{PointCloudUtils as B,toolStyleConverter as Z,EPerspectiveView as E}from"@labelbee/lb-utils";import j from"classnames";import e,{useContext as b,useState as O,useRef as H,useEffect as u,useMemo as U}from"react";import{PointCloudContainer as q}from"./PointCloudLayout.js";import{PointCloudContext as G}from"./PointCloudContext.js";import{a2MapStateToProps as J}from"../../store/annotation/map.js";import{connect as Q}from"react-redux";import{jsonParser as W}from"../../utils/index.js";import{useSingleBox as X}from"./hooks/useSingleBox.js";import{useSphere as Y}from"./hooks/useSphere.js";import{Switch as $,Tooltip as ee}from"antd";import te from"../../hooks/useSize.js";import{usePointCloudViews as oe}from"./hooks/usePointCloudViews.js";import{useTranslation as L}from"react-i18next";import{LabelBeeContext as ne}from"../../store/ctx.js";import ie from"./components/PointCloudSizeSlider/index.js";import re from"./components/TitleButton/index.js";import{LeftOutlined as ae}from"@ant-design/icons";var le=Object.defineProperty,se=Object.defineProperties,ce=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,D=(n,r,a)=>r in n?le(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,N=(n,r)=>{for(var a in r||(r={}))me.call(r,a)&&D(n,a,r[a]);if(z)for(var a of z(r))ue.call(r,a)&&D(n,a,r[a]);return n},de=(n,r)=>se(n,ce(r));const pe=K.default,we="LABELBEE-POINTCLOUD",P=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),d=({perspectiveView:n})=>{const{isActive:r,setTarget3DView:a}=b(P),o=p=>j({[m("point-cloud-3d-view",p)]:!0,active:r});return e.createElement("span",{onClick:()=>{a(E[n])},className:o(n.toLocaleLowerCase())})},k=({isEnlarge:n})=>{const{reset3DView:r,followTopView:a}=b(P),{t:o}=L(),p=e.createElement(e.Fragment,null,e.createElement(d,{perspectiveView:"Top"}),e.createElement(d,{perspectiveView:"Front"}),e.createElement(d,{perspectiveView:"Left"}),e.createElement(d,{perspectiveView:"Back"}),e.createElement(d,{perspectiveView:"Right"}),e.createElement(d,{perspectiveView:"LFT"}),e.createElement(d,{perspectiveView:"RBT"})),V=e.createElement(e.Fragment,null,e.createElement(ee,{title:o("CameraFollowTopView")},e.createElement("span",{onClick:()=>{a()},className:m("point-cloud-3d-view","followTop")})),e.createElement("span",{onClick:()=>{r()},className:m("point-cloud-3d-view","reset")}));return n?e.createElement("div",{className:m("point-cloud-3d-sidebarZoom")},V,p):e.createElement("div",{className:m("point-cloud-3d-sidebar")},p,V)},ve=({currentData:n,config:r,highlightAttribute:a})=>{const o=b(G),[p,V]=O(!0),[v,_]=O(!1),f=H(null),{initPointCloud3d:S}=oe(),C=te(f),{t:h}=L();u(()=>{!o.mainViewInstance||S==null||S(C)},[C]);const{selectedBox:w}=X(),{selectedSphere:g}=Y(),x=t=>{var i,l;const s=w==null?void 0:w.info;if(s){const c=N({},s.center);c.x=c.x-.01,c.z=1e3;const I=t===E.Top;(i=o.mainViewInstance)==null||i.updateCameraByBox(s,t,I?c:void 0)}g&&((l=o.mainViewInstance)==null||l.updateCameraBySphere(g,t))},R=()=>{var t;(t=o.mainViewInstance)==null||t.resetCamera()},F=()=>{var t,i;const l=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((i=o.mainViewInstance)==null||i.applyCameraTarget(l))};u(()=>{if(f.current&&(n==null?void 0:n.url)){let t=o.mainViewInstance;!t&&C.width&&(t=new M({container:f.current,isOrthographicCamera:!0,orthographicParams:B.getDefaultOrthographicParams(C),config:r}),o.setMainViewInstance(t))}},[C,n]),u(()=>{var t;if(f.current&&(n==null?void 0:n.url)&&n.result&&o.mainViewInstance){let i=o.mainViewInstance;const l=B.getBoxParamsFromResultList(n.result);l.forEach(s=>{var c;const I=(c=Z.getColorFromConfig({attribute:s.attribute},de(N({},r),{attributeConfigurable:!0}),{}))==null?void 0:c.hex;i==null||i.addBoxToSense(s,I)}),i.render(),o.setPointCloudResult(l),o.setPointCloudValid((t=W(n.result))==null?void 0:t.valid)}},[n,o.mainViewInstance]),u(()=>{var t,i,l,s;if(w){x(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[w]),u(()=>{var t,i,l,s;if(g){x(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[g]),u(()=>(window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}),[]);const T=t=>{if(t.keyCode===pe.Esc){_(!1);return}},y=U(()=>({reset3DView:R,setTarget3DView:x,isActive:!!w,followTopView:F}),[w,o.mainViewInstance]);u(()=>{var t,i,l;const s=o.pointCloudBoxList.filter(c=>c.attribute===a);(s==null?void 0:s.length)>0&&((t=o.mainViewInstance)==null||t.clearHighlightBoxes(),(i=o.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((l=o.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,o.mainViewInstance]);const A=e.createElement(e.Fragment,null,e.createElement(ie,{onChange:t=>{var i;(i=o.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),e.createElement("span",{style:{marginRight:8}},h("ShowArrows")),e.createElement($,{size:"small",checked:p,onChange:t=>{var i;V(t),(i=o.mainViewInstance)==null||i.setShowDirection(t)}}),v&&e.createElement(P.Provider,{value:y},e.createElement(k,{isEnlarge:v})));return e.createElement(q,{className:j({[m("point-cloud-3d-container")]:!0,[m("point-cloud-container","zoom")]:v}),title:v?e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement(ae,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{_(!1)}}),h("3DView")):e.createElement(re,{title:h("3DView"),onClick:()=>{_(!0)}}),toolbar:A},e.createElement("div",{className:m("point-cloud-3d-content")},!v&&e.createElement(P.Provider,{value:y},e.createElement(k,null)),e.createElement("div",{className:m("point-cloud-3d-view"),id:we,ref:f})))};var fe=Q(J,null,null,{context:ne})(ve);export{fe as default};
1
+ import{getClassName as m}from"../../utils/dom.js";import{cKeyCode as M,PointCloud as Z}from"@labelbee/lb-annotation";import{PointCloudUtils as b,toolStyleConverter as H,EPerspectiveView as E}from"@labelbee/lb-utils";import L from"classnames";import e,{useContext as S,useState as j,useRef as U,useEffect as u,useMemo as q}from"react";import{PointCloudContainer as G}from"./PointCloudLayout.js";import{PointCloudContext as J}from"./PointCloudContext.js";import{a2MapStateToProps as Q}from"../../store/annotation/map.js";import{connect as W}from"react-redux";import{jsonParser as X}from"../../utils/index.js";import{useSingleBox as Y}from"./hooks/useSingleBox.js";import{useSphere as $}from"./hooks/useSphere.js";import{Switch as ee,Tooltip as te}from"antd";import oe from"../../hooks/useSize.js";import{usePointCloudViews as ne}from"./hooks/usePointCloudViews.js";import{useTranslation as O}from"react-i18next";import{LabelBeeContext as ie}from"../../store/ctx.js";import re from"./components/PointCloudSizeSlider/index.js";import ae from"./components/TitleButton/index.js";import{LeftOutlined as le}from"@ant-design/icons";var se=Object.defineProperty,ce=Object.defineProperties,me=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,D=(n,r,a)=>r in n?se(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,N=(n,r)=>{for(var a in r||(r={}))ue.call(r,a)&&D(n,a,r[a]);if(z)for(var a of z(r))de.call(r,a)&&D(n,a,r[a]);return n},pe=(n,r)=>ce(n,me(r));const we=M.default,ve="LABELBEE-POINTCLOUD",_=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),d=({perspectiveView:n})=>{const{isActive:r,setTarget3DView:a}=S(_),o=p=>L({[m("point-cloud-3d-view",p)]:!0,active:r});return e.createElement("span",{onClick:()=>{a(E[n])},className:o(n.toLocaleLowerCase())})},k=({isEnlarge:n})=>{const{reset3DView:r,followTopView:a}=S(_),{t:o}=O(),p=e.createElement(e.Fragment,null,e.createElement(d,{perspectiveView:"Top"}),e.createElement(d,{perspectiveView:"Front"}),e.createElement(d,{perspectiveView:"Left"}),e.createElement(d,{perspectiveView:"Back"}),e.createElement(d,{perspectiveView:"Right"}),e.createElement(d,{perspectiveView:"LFT"}),e.createElement(d,{perspectiveView:"RBT"})),V=e.createElement(e.Fragment,null,e.createElement(te,{title:o("CameraFollowTopView")},e.createElement("span",{onClick:()=>{a()},className:m("point-cloud-3d-view","followTop")})),e.createElement("span",{onClick:()=>{r()},className:m("point-cloud-3d-view","reset")}));return n?e.createElement("div",{className:m("point-cloud-3d-sidebarZoom")},V,p):e.createElement("div",{className:m("point-cloud-3d-sidebar")},p,V)},fe=({currentData:n,config:r,highlightAttribute:a})=>{const o=S(J),[p,V]=j(!0),[v,h]=j(!1),f=U(null),{initPointCloud3d:T}=ne(),C=oe(f),{t:x}=O();u(()=>{!o.mainViewInstance||T==null||T(C)},[C]);const{selectedBox:w}=Y(),{selectedSphere:g}=$(),I=t=>{var i,l;const s=w==null?void 0:w.info;if(s){const c=N({},s.center);c.x=c.x-.01,c.z=1e3;const P=t===E.Top;(i=o.mainViewInstance)==null||i.updateCameraByBox(s,t,P?c:void 0)}g&&((l=o.mainViewInstance)==null||l.updateCameraBySphere(g,t))},R=()=>{var t;(t=o.mainViewInstance)==null||t.resetCamera()},F=()=>{var t,i;const l=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((i=o.mainViewInstance)==null||i.applyCameraTarget(l))};u(()=>{if(f.current&&(n==null?void 0:n.url)){let t=o.mainViewInstance;!t&&C.width&&(t=new Z({container:f.current,isOrthographicCamera:!0,orthographicParams:b.getDefaultOrthographicParams(C),config:r}),o.setMainViewInstance(t))}},[C,n]),u(()=>{var t;if(f.current&&(n==null?void 0:n.url)&&n.result&&o.mainViewInstance){let i=o.mainViewInstance;const l=b.getBoxParamsFromResultList(n.result);l.forEach(c=>{var P;const K=(P=H.getColorFromConfig({attribute:c.attribute},pe(N({},r),{attributeConfigurable:!0}),{}))==null?void 0:P.hex;i==null||i.addBoxToSense(c,K)}),i.render(),o.setPointCloudResult(l);const s=b.getRectParamsFromResultList(n.result);o.setRectList(s),o.setPointCloudValid((t=X(n.result))==null?void 0:t.valid)}},[n,o.mainViewInstance]),u(()=>{var t,i,l,s;if(w){I(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[w]),u(()=>{var t,i,l,s;if(g){I(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[g]),u(()=>(window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}),[]);const y=t=>{if(t.keyCode===we.Esc){h(!1);return}},B=q(()=>({reset3DView:R,setTarget3DView:I,isActive:!!w,followTopView:F}),[w,o.mainViewInstance]);u(()=>{var t,i,l;const s=o.pointCloudBoxList.filter(c=>c.attribute===a);(s==null?void 0:s.length)>0&&((t=o.mainViewInstance)==null||t.clearHighlightBoxes(),(i=o.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((l=o.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,o.mainViewInstance]);const A=e.createElement(e.Fragment,null,e.createElement(re,{onChange:t=>{var i;(i=o.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),e.createElement("span",{style:{marginRight:8}},x("ShowArrows")),e.createElement(ee,{size:"small",checked:p,onChange:t=>{var i;V(t),(i=o.mainViewInstance)==null||i.setShowDirection(t)}}),v&&e.createElement(_.Provider,{value:B},e.createElement(k,{isEnlarge:v})));return e.createElement(G,{className:L({[m("point-cloud-3d-container")]:!0,[m("point-cloud-container","zoom")]:v}),title:v?e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement(le,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{h(!1)}}),x("3DView")):e.createElement(ae,{title:x("3DView"),onClick:()=>{h(!0)}}),toolbar:A},e.createElement("div",{className:m("point-cloud-3d-content")},!v&&e.createElement(_.Provider,{value:B},e.createElement(k,null)),e.createElement("div",{className:m("point-cloud-3d-view"),id:ve,ref:f})))};var Ce=W(Q,null,null,{context:ie})(fe);export{Ce as default};
@@ -1 +1 @@
1
- import{EPointCloudName as nt,MathUtils as B,getCuboidFromPointCloudBox as Mt}from"@labelbee/lb-annotation";import{EPerspectiveView as J,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Gt,DEFAULT_SPHERE_PARAMS as Jt}from"@labelbee/lb-utils";import{useContext as Qt}from"react";import{PointCloudContext as Xt}from"../PointCloudContext.js";import{useSingleBox as Yt}from"./useSingleBox.js";import{useSphere as qt}from"./useSphere.js";import{useSelector as Kt,useDispatch as $t}from"../../../store/ctx.js";import to from"../../../utils/StepUtils.js";import{jsonParser as it,getRectPointCloudBox as oo}from"../../../utils/index.js";import{PreDataProcess as st,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as eo}from"./useHistory.js";import{usePolygon as no}from"./usePolygon.js";import{useLatest as io}from"ahooks";var so=Object.defineProperty,ro=Object.defineProperties,lo=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable,xt=(e,t,i)=>t in e?so(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,L=(e,t)=>{for(var i in t||(t={}))ao.call(t,i)&&xt(e,i,t[i]);if(ht)for(var i of ht(t))co.call(t,i)&&xt(e,i,t[i]);return e},O=(e,t)=>ro(e,lo(t)),rt=(e,t,i)=>new Promise((d,o)=>{var a=u=>{try{c(i.next(u))}catch(h){o(h)}},g=u=>{try{c(i.throw(u))}catch(h){o(h)}},c=u=>u.done?d(u.value):Promise.resolve(u.value).then(a,g);c((i=i.apply(e,t)).next())});const q=5,K=90,mt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(e,t,i,d,o)=>{const{x:a,y:g}=V.transferCanvas2World(e,t),{defaultZ:c}=Jt,u={center:{x:a,y:g,z:c},id:e.id},h=d?L(L({},d),u):O(L({},u),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},dt=(e,t,i,d,o,a)=>{let g=e.pointList.map(v=>V.transferCanvas2World(v,t)),c=0,u=1,h={};if(i){const v=i.getSensesPointZAxisInPolygon(g,void 0,a);a&&v.fittedCoordinates.length>0&&(g=v.fittedCoordinates),c=(v.maxZ+v.minZ)/2,u=v.maxZ-v.minZ,h={count:v.zCount}}const[m,I,W]=g,z=B.getLineCenterPoint([m,W]),T=B.getLineLength(m,I),R=B.getLineLength(I,W),E=B.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,u=d.depth);const j={center:{x:z.x,y:z.y,z:c},width:a?R+mt:R,height:a?T+mt:T,depth:u,rotation:E,id:e.id},N=L(d?L(L({},d),j):O(L({},j),{attribute:"",valid:!0}),h);o&&Object.assign(N,o);const F=g.map(v=>V.transferWorld2Canvas(v,t));return{boxParams:N,newPointList:F}},Lt=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x-d.x,y:i.center.y,z:i.center.z-d.y}})},yt=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,h]=t.pointList,m=B.getLineCenterPoint([o,g]),I=B.getLineCenterPoint([c,h]),z={x:{x:m.x-I.x,y:m.y-I.y}.x,y:0,z:m.y-I.y},T=B.getLineLength(o,a),R=B.getLineLength(c,u),E=T-R,j=B.getLineLength(a,g),N=B.getLineLength(u,h),F=j-N,{newBoxParams:v}=d.getNewBoxBySideUpdate(z,F,E,i);return v},uo=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x,y:i.center.y-d.x,z:i.center.z-d.y}})},po=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,h]=t.pointList,m=B.getLineCenterPoint([o,g]),I=B.getLineCenterPoint([c,h]),z={x:{x:m.x-I.x,y:m.y-I.y}.x,y:0,z:m.y-I.y},T=B.getLineLength(o,a),R=B.getLineLength(c,u),E=T-R,j=B.getLineLength(a,g),N=B.getLineLength(u,h),F=j-N;let{newBoxParams:v}=d.getNewBoxByBackUpdate(z,F,E,i);return v},vt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,J.Left);c.setInitCameraPosition(u);const{point2d:h,zoom:m}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=m,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(m),g.setResult([O(L(L({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{width:q,depth:q});const{cameraPositionVector:g}=a.updateOrthoCamera(e,J.Left);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,J.Back);c.setInitCameraPosition(u);const{point2d:h,zoom:m}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=m,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(m),g.setResult([O(L(L({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{height:q,depth:q});const{cameraPositionVector:g}=a.updateOrthoCamera(e,J.Back);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,i,d)=>{if(!i||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,J.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=i,{point2d:g}=a.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},at=(e,t,i,d)=>{var o,a;if(!i||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:g,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),h=[...g.polygonList],m=h.find(I=>I.id===t.id);m?(m.pointList=u,m.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(a=e.valid)!=null?a:!0}),g.setResultAndSelectedID(h,t.id)},go=()=>{const e=Qt(Xt),{topViewInstance:t,sideViewInstance:i,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:g,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:h,pointCloudSphereList:m,hideAttributes:I,setHighlight2DDataList:W,cuboidBoxIn2DView:z,imageSizes:T}=e,{addHistory:R,initHistory:E,pushHistoryUnderUpdatePolygon:j}=eo(),{selectedPolygon:N}=no(),{getPointCloudSphereByID:F,updatePointCloudSphere:v,selectedSphere:Q}=qt(),{currentData:Z,config:S}=Kt(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:it(to.getCurrentStepInfo(p,s).config)}}),H=$t(),St=io(z),$=n=>{if(!St.current){const{mappingImgList:s=[]}=Z,p=s.map(r=>oo({pointCloudBox:n,mappingData:r,imageSizes:T}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:_,updateSelectedBox:Dt,updateSelectedBoxes:tt,getPointCloudByID:_t}=Yt({generateRects:$}),ct=_==null?void 0:_.info;if(!t||!i||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ot=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},kt=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const P=lt(n,s,ot,void 0,f);c(n.id);const x=g(P);X(y.Top,n,P,p,x,S),R({newSphereParams:P})},Rt=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var P,x;const C={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};r===!0&&Object.assign(C,{trackID:V.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:m})});const D=t==null?void 0:t.toolInstance,w=L({},n);let{boxParams:b,newPointList:A}=dt(w,s,ot,void 0,C,f);b=H(st({tool:nt.PointCloud,dataList:[b],stepConfig:S,action:"viewUpdateBox"}))[0],f&&(A==null?void 0:A.length)&&(w.pointList=A);const k=I.includes(w.attribute);$(b);const G=a(b),et=(x=e==null?void 0:e.polygonList)!=null?x:[];t==null||t.updatePolygonList(G!=null?G:[],et),k?c([]):(c(b.id),D.selection.setSelectedIDs(w.id),M({omitView:y.Top,polygon:w,boxParams:b,zoom:l,newPointCloudBoxList:G}),f&&at(b,w,t,o)),R({newBoxParams:b})},At=n=>{const{boxID:s,imageName:p,width:r,height:l,x:f,y:P}=n,x=h.find(C=>C.id===s);if(x==null?void 0:x.rects){const{rects:C=[]}=x,D=C.find(w=>w.imageName===p);if(D){let w=C;const b=O(L({},D),{width:r,height:l,x:f,y:P});w=C.map(k=>k===D?b:k);const A=O(L({},x),{rects:w}),U=h.map(k=>k===x?A:k);return t==null||t.updatePolygonList(U!=null?U:[]),U}}},Ut=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(u.length===0||!f)){if(n||(_==null?void 0:_.info)){const P=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(u[0]);const x=f.selectedPolygon;if(u.length===1&&P){M({omitView:y.Top,polygon:x,boxParams:P,newPointCloudBoxList:s});return}}if((p||Q)&&u.length===1){const P=p!=null?p:Q;f.setSelectedID(u[0]);const x=f.selectedPoint;P&&X(y.Top,x,P,void 0,r,S)}}},ut=(n,s,p)=>{if(ct){let r,l;switch(p){case y.Back:r=po;break;case y.Side:r=yt;break;default:r=yt;break}if(l=r(n,s,ct,i.pointCloudInstance),o){const{count:D}=o.getSensesPointZAxisInPolygon(Mt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:D})}const P=H(st({tool:nt.PointCloud,dataList:[l],stepConfig:S,action:"viewUpdateBox"}))[0],x=l.valid!==P.valid;l=P;const C=Dt(l);return l=C.find(D=>D.id===l.id),M({omitView:x?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:C}),C}},pt=(n,s,p)=>{if(Q){let r,l;switch(p){case y.Back:r=uo;break;case y.Side:r=Lt;break;default:r=Lt;break}l=r(n,s,Q);const f=v(l);return X(p,n,l,void 0,f,S),f}},zt=(n,s)=>{pt(n,s,y.Side)},Tt=(n,s)=>{pt(n,s,y.Back)},jt=(n,s)=>{ut(n,s,y.Side)},Nt=(n,s)=>{ut(n,s,y.Back)},Et=(n,s)=>{const p=F(n.id),r=lt(n,s,ot,p),l=v(r);X(y.Top,n,r,void 0,l,S)},Ft=(n,s)=>{if(N){const r=L({},n[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,s)),j(r);return}let p=n.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=dt(r,s,t.pointCloudInstance,l);return f});if(p=H(st({tool:nt.PointCloud,dataList:p,stepConfig:S,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=tt(p);M({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=tt(p);r&&e.syncAllViewPointCloudColor(r)}},Ht=n=>{var s,p,r,l,f;if(_){const P=Number(n.widthDefault),x=Number(n.depthDefault),C=Number(n.heightDefault),D=_==null?void 0:_.info.trackID,b=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===D),A={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},U=b.pointList.map(Y=>V.transferCanvas2World(Y,A)),k=B.getModifiedRectangleCoordinates(U,C,P),G=k[0],et=k[2],gt=B.getLineCenterPoint([G,et]),Wt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:gt.x,y:gt.y,z:Wt+x/2},width:P,height:C,depth:x,valid:!0}),Zt=tt([ft]);M({omitView:y["3D"],polygon:b,boxParams:ft,newPointCloudBoxList:Zt})}},X=(n,s,p,r,l,f)=>rt(void 0,null,function*(){const P=Z==null?void 0:Z.url,x={[y.Side]:()=>{vt(p,s,i,P,f)},[y.Back]:()=>{d&&bt(p,s,d,P,f)},[y.Top]:()=>{It(p,s,t,o)}};Object.keys(x).forEach(C=>{C!==n&&x[C]()}),r&&(o==null||o.updateCameraZoom(r)),Ot(p)}),M=n=>rt(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:f}=n,P=Z==null?void 0:Z.url;f&&(yield e.syncAllViewPointCloudColor(f));const x={[y.Side]:()=>{Bt(r,p,i,P)},[y.Back]:()=>{d&&wt(r,p,d,P)},[y.Top]:()=>{at(r,p,t,o)}};Object.keys(x).forEach(C=>{C!==s&&x[C]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(r)});return{topViewAddSphere:kt,topViewAddBox:Rt,topViewSelectedChanged:Ut,topViewUpdatePoint:Et,sideViewUpdatePoint:zt,backViewUpdatePoint:Tt,topViewUpdateBox:Ft,sideViewUpdateBox:jt,backViewUpdateBox:Nt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>rt(void 0,[...n],function*(s=Z){var p,r,l,f,P,x;if(!(s==null?void 0:s.url)||!o)return;W([]),Ct(H,!0),Pt(H,!0),yield o.loadPCDFile(s.url,(p=S==null?void 0:S.radius)!=null?p:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let C=[],D=[],w=[],b=[];o.updateTopCamera();const A=(l=(r=it(s.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(A),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),s.result){if(C=V.getBoxParamsFromResultList(s.result),(C==null?void 0:C.length)>0&&s.isPreResult&&(S==null?void 0:S.lowerLimitPointsNumInBox)>0){C=yield o==null?void 0:o.filterPreResult(s.url,S,C);const U=it(s.result);U[Gt].result=C,s.result=JSON.stringify(U),e.setPointCloudResult(C)}w=V.getPolygonListFromResultList(s.result),D=V.getLineListFromResultList(s.result),b=V.getSphereParamsFromResultList(s.result),t.updateData(s.url,s.result,{radius:(x=S==null?void 0:S.radius)!=null?x:K}),o==null||o.generateBoxes(C),o==null||o.generateSpheres(b),yield e.syncAllViewPointCloudColor(C,[])}E({pointCloudBoxList:C,polygonList:w,lineList:D,pointCloudSphereList:b}),Ct(H,!1),Pt(H,!1)}),updateViewsByDefaultSize:Ht,generateRects:$,update2DViewRect:At}};export{bt as syncBackViewByPoint,vt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,go as usePointCloudViews};
1
+ import{EPointCloudName as nt,MathUtils as w,getCuboidFromPointCloudBox as Gt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as Jt,DEFAULT_SPHERE_PARAMS as Qt}from"@labelbee/lb-utils";import{useContext as Xt}from"react";import{PointCloudContext as Yt}from"../PointCloudContext.js";import{useSingleBox as qt}from"./useSingleBox.js";import{useSphere as Kt}from"./useSphere.js";import{useSelector as $t,useDispatch as to}from"../../../store/ctx.js";import oo from"../../../utils/StepUtils.js";import{jsonParser as it,getRectPointCloudBox as eo}from"../../../utils/index.js";import{PreDataProcess as st,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as no}from"./useHistory.js";import{usePolygon as io}from"./usePolygon.js";import{useLatest as so}from"ahooks";var ro=Object.defineProperty,lo=Object.defineProperties,ao=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,co=Object.prototype.hasOwnProperty,uo=Object.prototype.propertyIsEnumerable,ht=(e,t,r)=>t in e?ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))co.call(t,r)&&ht(e,r,t[r]);if(mt)for(var r of mt(t))uo.call(t,r)&&ht(e,r,t[r]);return e},R=(e,t)=>lo(e,ao(t)),rt=(e,t,r)=>new Promise((a,o)=>{var c=p=>{try{u(r.next(p))}catch(m){o(m)}},g=p=>{try{u(r.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((r=r.apply(e,t)).next())});const q=5,K=90,xt=.01,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(e,t,r,a,o)=>{const{x:c,y:g}=O.transferCanvas2World(e,t),{defaultZ:u}=Qt,p={center:{x:c,y:g,z:u},id:e.id},m=a?v(v({},a),p):R(v({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},dt=(e,t,r,a,o,c)=>{let g=e.pointList.map(B=>O.transferCanvas2World(B,t)),u=0,p=1,m={};if(r){const B=r.getSensesPointZAxisInPolygon(g,void 0,c);c&&B.fittedCoordinates.length>0&&(g=B.fittedCoordinates),u=(B.maxZ+B.minZ)/2,p=B.maxZ-B.minZ,m={count:B.zCount}}const[x,I,F]=g,A=w.getLineCenterPoint([x,F]),U=w.getLineLength(x,I),k=w.getLineLength(I,F),j=w.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const z={center:{x:A.x,y:A.y,z:u},width:c?k+xt:k,height:c?U+xt:U,depth:p,rotation:j,id:e.id},T=v(a?v(v({},a),z):R(v({},z),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(B=>O.transferWorld2Canvas(B,t));return{boxParams:T,newPointList:N}},vt=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(v({},r),{center:{x:r.center.x-a.x,y:r.center.y,z:r.center.z-a.y}})},Lt=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,x=w.getLineCenterPoint([o,g]),I=w.getLineCenterPoint([u,m]),A={x:{x:x.x-I.x,y:x.y-I.y}.x,y:0,z:x.y-I.y},U=w.getLineLength(o,c),k=w.getLineLength(u,p),j=U-k,z=w.getLineLength(c,g),T=w.getLineLength(p,m),N=z-T,{newBoxParams:B}=a.getNewBoxBySideUpdate(A,N,j,r);return B},po=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(v({},r),{center:{x:r.center.x,y:r.center.y-a.x,z:r.center.z-a.y}})},go=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,x=w.getLineCenterPoint([o,g]),I=w.getLineCenterPoint([u,m]),A={x:{x:x.x-I.x,y:x.y-I.y}.x,y:0,z:x.y-I.y},U=w.getLineLength(o,c),k=w.getLineLength(u,p),j=U-k,z=w.getLineLength(c,g),T=w.getLineLength(p,m),N=z-T;let{newBoxParams:B}=a.getNewBoxByBackUpdate(A,N,j,r);return B},yt=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Left);u.setInitCameraPosition(p);const{point2d:m,zoom:x}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(x),g.setResult([R(v(v({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{width:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Left);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Back);u.setInitCameraPosition(p);const{point2d:m,zoom:x}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(x),g.setResult([R(v(v({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{height:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Back);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,r,a)=>{if(!r||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=r,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?R(v(v({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},at=(e,t,r,a)=>{var o,c;if(!r||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=r,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],x=m.find(I=>I.id===t.id);x?(x.pointList=p,x.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),g.setResultAndSelectedID(m,t.id)},fo=()=>{const e=Xt(Yt),{topViewInstance:t,sideViewInstance:r,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:x,hideAttributes:I,setHighlight2DDataList:F,cuboidBoxIn2DView:A,imageSizes:U}=e,{addHistory:k,initHistory:j,pushHistoryUnderUpdatePolygon:z}=no(),{selectedPolygon:T}=io(),{getPointCloudSphereByID:N,updatePointCloudSphere:B,selectedSphere:J}=Kt(),{currentData:H,config:S}=$t(n=>{const{stepList:i,step:d,imgList:s,imgIndex:l}=n.annotation;return{currentData:s[l],config:it(oo.getCurrentStepInfo(d,i).config)}}),E=to(),St=so(A),$=n=>{if(!St.current){const{mappingImgList:i=[]}=H,d=i.map(s=>eo({pointCloudBox:n,mappingData:s,imageSizes:U}));Object.assign(n,{rects:d.filter(s=>s!==void 0)})}},{selectedBox:D,updateSelectedBox:Dt,updateSelectedBoxes:tt,getPointCloudByID:_t}=qt({generateRects:$}),ct=D==null?void 0:D.info;if(!t||!r||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ot=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},Rt=({newPoint:n,size:i,zoom:d,trackConfigurable:s})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};s===!0&&Object.assign(f,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:x})});const P=lt(n,i,ot,void 0,f);u(n.id);const C=g(P);Q(L.Top,n,P,d,C,S),k({newSphereParams:P})},kt=({polygon:n,size:i,imgList:d,trackConfigurable:s,zoom:l,intelligentFit:f})=>{var P,C;const h={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};s===!0&&Object.assign(h,{trackID:O.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:x})});const _=t==null?void 0:t.toolInstance,V=v({},n);let{boxParams:y,newPointList:b}=dt(V,i,ot,void 0,h,f);y=E(st({tool:nt.PointCloud,dataList:[y],stepConfig:S,action:"viewUpdateBox"}))[0],f&&(b==null?void 0:b.length)&&(V.pointList=b);const X=I.includes(V.attribute);$(y);const M=c(y),et=(C=e==null?void 0:e.polygonList)!=null?C:[];t==null||t.updatePolygonList(M!=null?M:[],et),X?u([]):(u(y.id),_.selection.setSelectedIDs(V.id),W({omitView:L.Top,polygon:V,boxParams:y,zoom:l,newPointCloudBoxList:M}),f&&at(y,V,t,o)),k({newBoxParams:y})},At=n=>{const{boxID:i,imageName:d,width:s,height:l,x:f,y:P}=n,C=m.find(b=>b.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(b=>b.imageName===d))return;const _=C.rects.map(b=>b.imageName===d?R(v({},b),{width:s,height:l,x:f,y:P}):b),V=R(v({},C),{rects:_}),y=m.map(b=>b.id===i?V:b);return t==null||t.updatePolygonList(y!=null?y:[]),y},Ut=n=>{const{boxID:i,imageName:d}=n,s=m.find(C=>C.id===i);if(!(s==null?void 0:s.rects))return;const l=s.rects.filter(C=>C.imageName!==d),f=R(v({},s),{rects:l}),P=m.map(C=>C.id===i?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},zt=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:d,newSphereList:s})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(n||(D==null?void 0:D.info)){const P=n!=null?n:D==null?void 0:D.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){W({omitView:L.Top,polygon:C,boxParams:P,newPointCloudBoxList:i});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(L.Top,C,P,void 0,s,S)}}},ut=(n,i,d)=>{if(ct){let s,l;switch(d){case L.Back:s=go;break;case L.Side:s=Lt;break;default:s=Lt;break}if(l=s(n,i,ct,r.pointCloudInstance),o){const{count:_}=o.getSensesPointZAxisInPolygon(Gt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=R(v({},l),{count:_})}const P=E(st({tool:nt.PointCloud,dataList:[l],stepConfig:S,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const h=Dt(l);return l=h.find(_=>_.id===l.id),W({omitView:C?void 0:d,polygon:n,boxParams:l,newPointCloudBoxList:h}),h}},pt=(n,i,d)=>{if(J){let s,l;switch(d){case L.Back:s=po;break;case L.Side:s=vt;break;default:s=vt;break}l=s(n,i,J);const f=B(l);return Q(d,n,l,void 0,f,S),f}},Tt=(n,i)=>{pt(n,i,L.Side)},jt=(n,i)=>{pt(n,i,L.Back)},Nt=(n,i)=>{ut(n,i,L.Side)},Et=(n,i)=>{ut(n,i,L.Back)},Ft=(n,i)=>{const d=N(n.id),s=lt(n,i,ot,d),l=B(s);Q(L.Top,n,s,void 0,l,S)},Ht=(n,i)=>{if(T){const s=v({},n[0].newPolygon);s.pointList=s.pointList.map(l=>O.transferCanvas2World(l,i)),z(s);return}let d=n.map(({newPolygon:s})=>{const l=_t(s.id),{boxParams:f}=dt(s,i,t.pointCloudInstance,l);return f});if(d=E(st({tool:nt.PointCloud,dataList:d,stepConfig:S,action:"viewUpdateBox"})),d.length===1){const{newPolygon:s}=n[0],l=tt(d);W({polygon:s,boxParams:d[0],newPointCloudBoxList:l})}else{const s=tt(d);s&&e.syncAllViewPointCloudColor(s)}},Wt=n=>{var i,d,s,l,f;if(D){const P=Number(n.widthDefault),C=Number(n.depthDefault),h=Number(n.heightDefault),_=D==null?void 0:D.info.trackID,y=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===_),b={width:(s=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:s.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},Z=y.pointList.map(Y=>O.transferCanvas2World(Y,b)),X=w.getModifiedRectangleCoordinates(Z,h,P),M=X[0],et=X[2],gt=w.getLineCenterPoint([M,et]),Zt=D.info.center.z-D.info.depth/2,ft=R(v({},D.info),{center:{x:gt.x,y:gt.y,z:Zt+C/2},width:P,height:h,depth:C,valid:!0}),Mt=tt([ft]);W({omitView:L["3D"],polygon:y,boxParams:ft,newPointCloudBoxList:Mt})}},Q=(n,i,d,s,l,f)=>rt(void 0,null,function*(){const P=H==null?void 0:H.url,C={[L.Side]:()=>{yt(d,i,r,P,f)},[L.Back]:()=>{a&&bt(d,i,a,P,f)},[L.Top]:()=>{It(d,i,t,o)}};Object.keys(C).forEach(h=>{h!==n&&C[h]()}),s&&(o==null||o.updateCameraZoom(s)),Ot(d)}),W=n=>rt(void 0,null,function*(){const{omitView:i,polygon:d,boxParams:s,zoom:l,newPointCloudBoxList:f}=n,P=H==null?void 0:H.url;f&&(yield e.syncAllViewPointCloudColor(f));const C={[L.Side]:()=>{Bt(s,d,r,P)},[L.Back]:()=>{a&&wt(s,d,a,P)},[L.Top]:()=>{at(s,d,t,o)}};Object.keys(C).forEach(h=>{h!==i&&C[h]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(s)});return{topViewAddSphere:Rt,topViewAddBox:kt,topViewSelectedChanged:zt,topViewUpdatePoint:Ft,sideViewUpdatePoint:Tt,backViewUpdatePoint:jt,topViewUpdateBox:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=O.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>rt(void 0,[...n],function*(i=H){var d,s,l,f,P,C;if(!(i==null?void 0:i.url)||!o)return;F([]),Ct(E,!0),Pt(E,!0),yield o.loadPCDFile(i.url,(d=S==null?void 0:S.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let h=[],_=[],V=[],y=[];o.updateTopCamera();const b=(l=(s=it(i.result))==null?void 0:s.valid)!=null?l:!0;if(e.setPointCloudValid(b),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),i.result){if(h=O.getBoxParamsFromResultList(i.result),(h==null?void 0:h.length)>0&&i.isPreResult&&(S==null?void 0:S.lowerLimitPointsNumInBox)>0){h=yield o==null?void 0:o.filterPreResult(i.url,S,h);const Z=it(i.result);Z[Jt].result=h,i.result=JSON.stringify(Z),e.setPointCloudResult(h)}V=O.getPolygonListFromResultList(i.result),_=O.getLineListFromResultList(i.result),y=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(C=S==null?void 0:S.radius)!=null?C:K}),o==null||o.generateBoxes(h),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(h,[])}j({pointCloudBoxList:h,polygonList:V,lineList:_,pointCloudSphereList:y}),Ct(E,!1),Pt(E,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:At,remove2DViewRect:Ut}};export{bt as syncBackViewByPoint,yt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,fo as usePointCloudViews};
@@ -1 +1 @@
1
- import{getFormatSize as St}from"../../components/customResizeHook/index.js";import{ESubmitType as K}from"../../constant/index.js";import Dt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as i}from"../Actions.js";import{jsonParser as x}from"../../utils/index.js";import X from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as vt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as ut,composeResult as Y}from"../../utils/data.js";import O from"../../utils/StepUtils.js";import J from"../../utils/ToolUtils.js";import{MathUtils as at,CommonToolUtils as yt,AnnotationEngine as Pt,ImgUtils as Rt}from"@labelbee/lb-annotation";import{PointCloudUtils as ct,i18n as G}from"@labelbee/lb-utils";import{Modal as dt}from"antd";import{message as pt}from"antd/es";import _t from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as W}from"../../data/enums/ToolType.js";var Ct=Object.defineProperty,Ot=Object.defineProperties,ht=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable,It=(t,e,r)=>e in t?Ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,o=(t,e)=>{for(var r in e||(e={}))bt.call(e,r)&&It(t,r,e[r]);if(gt)for(var r of gt(e))Nt.call(e,r)&&It(t,r,e[r]);return t},l=(t,e)=>Ot(t,ht(e)),mt=(t,e,r)=>new Promise((A,d)=>{var S=m=>{try{T(r.next(m))}catch(y){d(y)}},f=m=>{try{T(r.throw(m))}catch(y){d(y)}},T=m=>m.done?A(m.value):Promise.resolve(m.value).then(S,f);T((r=r.apply(t,e)).next())});const w=(t,e)=>t.find(r=>r.step===e),ft={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},Ut=t=>{const{imgList:e,imgPageSize:r}=t;return Math.ceil(e.length/r)},Tt=(t,e)=>t.reduce((r,A)=>{if(A){const d=A.result;if(x(d)[`step_${e}`])return r+1}return r},0)/t.length,Bt=(t,e)=>{const{step:r,stepList:A}=t,d=O.getCurrentStepInfo(r,A),S=vt.jsonParser(d.config);if(J.isVideoTool(d==null?void 0:d.tool)||J.isAudioTool(d==null?void 0:d.tool)||J.isPointCloudTool(d==null?void 0:d.tool)||[W.LLM,W.NLP].includes(d==null?void 0:d.tool))return;const f=document.getElementById("toolContainer");if(!f)throw"Not exist dom named id-toolContainer";const T=St({width:window.innerWidth,height:window.innerHeight}),m=new Pt({container:f,toolName:d.tool,size:T,imgNode:e,config:S,style:JSON.parse(Dt)});return{toolInstance:m==null?void 0:m.toolInstance,annotationEngine:m}},xt=(t,e)=>(r,A)=>mt(void 0,null,function*(){var d,S;const{stepList:f,step:T}=A().annotation,m=O.currentToolIsVideo(T,f),y=O.currentToolIsPointCloud(T,f),h=((d=O.getCurrentStepInfo(T,f))==null?void 0:d.tool)===W.LLM,b=((S=O.getCurrentStepInfo(T,f))==null?void 0:S.tool)===W.NLP,N=O.currentToolIsAudio(T,f);if($(r,!0),yield r(wt(t)),m){r(Ft(t));return}if(y||h||N||b){r(jt(t));return}r(Gt(t,e))}),wt=t=>(e,r)=>mt(void 0,null,function*(){const{getFileData:A,imgList:d}=r().annotation;if(A){const S=yield A(d[t],t);e({type:i.SET_FILE_DATA,payload:{fileData:S,index:t}})}}),Ft=t=>e=>{e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},jt=t=>e=>{$(e,!1),e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},Gt=(t,e)=>(r,A)=>{var d;const{toolInstance:S,imgList:f}=A().annotation,T=(d=f==null?void 0:f[t])==null?void 0:d.url;Rt.load(T).then(m=>{$(r,!1),r({type:i.LOAD_FILE_DATA,payload:{imgNode:m,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(r,!1),S==null||S.setErrorImg(),r({type:i.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},Vt=({toolInstance:t,imgList:e,imgIndex:r,stepList:A,step:d=1})=>{var S,f,T,m;const y=((S=e[r])==null?void 0:S.result)||"",[h,b,N]=(f=t==null?void 0:t.exportData())!=null?f:[],V=(m=(T=t==null?void 0:t.exportCustomData)==null?void 0:T.call(t))!=null?m:{},M=ut(y,b),k=Y(M,{step:d,stepList:A},{rect:h},V);return e.map((F,H)=>H===r?o(l(o({},F),{result:k}),N):o({},F))},Mt=(t=o({},ft),e)=>{var r,A,d,S,f,T,m,y,h,b,N,V,M,k,F,H,q,Z,Q,tt,et,nt,ot,st,lt;switch(e.type){case i.INIT_ALL_STATE:return o(o({},t),ft);case i.UPDATE_TOOL_INSTANCE:return l(o({},t),{toolInstance:e.payload.toolInstance});case i.UPDATE_IMG_LIST:return l(o({},t),{imgList:e.payload.imgList});case i.CALC_STEP_PROGRESS:{const{imgList:n,step:s}=t,u=Tt(n,s);return l(o({},t),{stepProgress:u})}case i.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:s,step:u,stepList:a,toolInstance:p,onSubmit:c,resultList:L}=t;if(!p||!n[s])return t;const g=((r=n[s])==null?void 0:r.result)||"",[,_,I]=(A=p==null?void 0:p.exportData())!=null?A:[],E=(S=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?S:{},D=ut(g,_),P=Y(D,{step:u,stepList:a},{rect:L},E),v=t.imgList.map((C,R)=>{if(R===s){const j=X.dataCorrection(P,g,u,a);return o(l(o({},C),{result:j}),I)}return C});if(((f=e.payload)==null?void 0:f.submitType)===K.SyncImgList)return l(o({},t),{imgList:v});c&&c([v[s]],(T=e.payload)==null?void 0:T.submitType,s,v);const U=Tt(v,u);return l(o({},t),{stepProgress:U,imgList:v})}case i.SAVE_RESULT:{const{imgList:n,imgIndex:s,onSave:u}=t;return u==null||u(n[s],s,n),o({},t)}case i.SUBMIT_RESULT:{const{imgList:n,basicIndex:s,resultList:u,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(m=a==null?void 0:a.exportData())!=null?m:[];let L=c;if((p==null?void 0:p.length)>0){const g=(y=p[s])==null?void 0:y.id,_=c.map(I=>l(o({},I),{sourceID:g}));L=_t.cloneDeep(u).filter(I=>I.sourceID!==g),L.push(..._)}return l(o({},t),{resultList:L,imgList:n})}case i.SET_BASIC_INDEX:{const{toolInstance:n,step:s,imgList:u,imgIndex:a,stepList:p,annotationEngine:c,resultList:L,basicResultList:g}=t;if(!n||!c)return t;const _=e.payload.basicIndex,I=(h=g[_])==null?void 0:h.id,E=x((b=u[a])==null?void 0:b.result),D=(L||[]).filter(j=>j.sourceID===I),P=w(p,s),{dataSourceStep:v,tool:U}=P,C=w(p,v);let R=[];return v&&U&&(R=(N=E[`step_${v}`])==null?void 0:N.result,(R==null?void 0:R.length)>0?(c==null||c.setBasicInfo(C.tool,R[_]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),pt.info(G.t("NoDependency")))),n==null||n.setResult(D),n==null||n.history.initRecord(D,!0),l(o({},t),{basicIndex:_})}case i.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=e.payload;return l(o({},t),{triggerEventAfterIndexChanged:!!n})}case i.LOAD_FILE_DATA:{const{imgList:n,step:s,toolInstance:u,annotationEngine:a,stepList:p}=t;if(!u)return l(o({},t),{imgIndex:e.payload.nextIndex});const c=O.getCurrentStepInfo(s,p),{nextIndex:L,imgNode:g,nextBasicIndex:_,imgError:I}=e.payload,E=_!=null?_:0,D=x((V=n[L])==null?void 0:V.result),P=D[`step_${c.step}`],v=!P,U={rotate:(M=D.rotate)!=null?M:0,valid:(k=D.valid)!=null?k:!0};g&&I!==!0?a==null||a.setImgNode(g,U):u==null||u.setValid(U.valid);const C=w(p,c.step),{dataSourceStep:R,tool:j}=C,it=w(p,R),rt=R&&j,B=(H=(F=D[`step_${R}`])==null?void 0:F.result)!=null?H:[],z=X.getInitialResultList(P==null?void 0:P.result,u,C,B,v);if(a==null||a.launchOperation(),rt&&((B==null?void 0:B.length)>0?a==null||a.setBasicInfo(it.tool,B[E]):(a==null||a.setBasicInfo(it.tool),a==null||a.forbidOperation(),pt.info(G.t("NoDependency")))),c.tool!=="check"){const Lt=(Z=(q=B[E])==null?void 0:q.id)!=null?Z:"",Et=rt?z.filter(At=>yt.isSameSourceID(At.sourceID,Lt)):z;(Q=u==null?void 0:u.history)==null||Q.initRecord(z,!0),u==null||u.setResult(Et)}return l(o({},t),{imgIndex:L,basicIndex:E,basicResultList:B,resultList:z})}case i.UPDATE_ANNOTATION_CONFIG:return l(o({},t),{config:(tt=e.payload.config)!=null?tt:"{}"});case i.SET_TASK_STEP_LIST:{const{stepList:n}=e.payload;return l(o({},t),{stepList:n})}case i.SET_TASK_CONFIG:{const{stepList:n,step:s}=e.payload;return l(o({},t),{stepList:n,step:s})}case i.INIT_TOOL:{const{imgNode:n}=t,s=Bt(t,n);if(s){const{toolInstance:u,annotationEngine:a}=s;return l(o({},t),{toolInstance:u,annotationEngine:a})}return o({},t)}case i.SET_TOOL:{const n=(et=e.payload)==null?void 0:et.instance;return n?l(o({},t),{toolInstance:n}):o({},t)}case i.UPDATE_ON_SUBMIT:return l(o({},t),{onSubmit:e.payload.onSubmit});case i.UPDATE_ON_SAVE:return l(o({},t),{onSave:e.payload.onSave});case i.UPDATE_ON_PAGE_CHANGE:return l(o({},t),{onPageChange:e.payload.onPageChange});case i.SET_PREDICT_RESULT:return l(o({},t),{predictionResult:e.payload.result});case i.SET_PREDICT_RESULT_VISIBLE:return l(o({},t),{predictionResultVisible:e.payload.visible});case i.UPDATE_ON_STEP_CHANGE:return l(o({},t),{onStepChange:e.payload.onStepChange});case i.UPDATE_GET_FILE_DATA:return l(o({},t),{getFileData:e.payload.getFileData});case i.UPDATE_PAGE_SIZE:return l(o({},t),{pageSize:e.payload.pageSize});case i.UPDATE_LOAD_FILE_LIST:return l(o({},t),{loadFileList:e.payload.loadFileList});case i.UPDATE_BEFORE_ROTATE:return l(o({},t),{beforeRotate:e.payload.beforeRotate});case i.UPDATE_PRE_DATA_PROCESS:return l(o({},t),{preDataProcess:e.payload.preDataProcess});case i.UPDATE_IMG_INDEX_BY_EXTERNAL:return l(o({},t),{getImgIndexByExternal:e.payload.getImgIndexByExternal});case i.SKIP_BEFORE_PAGE_TURNING:return l(o({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case i.SET_FILE_DATA:{const{fileData:n,index:s}=e.payload,{imgList:u}=t,a=[...u];return a[s]=o(o({},a[s]),n),l(o({},t),{imgList:a})}case i.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:s}=t;return s&&s()===!1||(nt=n==null?void 0:n.updateRotate)==null||nt.call(n),t}case i.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=t,s=(ot=n==null?void 0:n.valid)!=null?ot:!0;return dt.destroyAll(),dt.confirm({content:G.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!s)},okText:G.t("Confirm"),cancelText:G.t("Cancel")}),t}case i.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:s,imgList:u,step:a}=t;if(!n)return t;if(s===0||s>=u.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const p=u[s-1].result;if(!p)return t;const c=X.copyResultChange(p,a,(st=u[s].result)!=null?st:"");u[s]=l(o({},u[s]),{result:c});const g=x(c)[`step_${a}`],_=(g==null?void 0:g.result)||[];return n==null||n.setResult(_),n==null||n.history.pushHistory(_),(lt=n==null?void 0:n.asyncData)==null||lt.call(n,u[s]),l(o({},t),{imgList:[...u]})}case i.SET_STEP:{const{stepList:n,annotationEngine:s}=t,{toStep:u}=e.payload;if(s){const a=w(n,u);return s==null||s.setToolName(a.tool,a.config),l(o({},t),{step:u,toolInstance:s==null?void 0:s.toolInstance})}return l(o({},t),{step:u})}case i.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=e.payload;return l(o({},t),{loadPCDFileLoading:!!n})}case i.SET_LOADING:{const{loading:n}=e.payload;return l(o({},t),{loading:!!n})}case i.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=e.payload;return l(o({},t),{pointCloudLoading:!!n})}case i.SET_CHECK_MODE:{const{checkMode:n}=e.payload;return l(o({},t),{checkMode:!!n})}case i.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=e.payload;return l(o({},t),{highlightAttribute:n})}case i.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:s,rangeIndex:u,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,L=[],g=a.map((_,I)=>{if(at.isInRange(I,u)){const E=l(o({},_),{result:ct.batchUpdateTrackID({id:n,newID:s,result:_.result})});return L.push({imgIndex:I,newInfo:E}),E}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:L}),l(o({},t),{imgList:g})}case i.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:s,rangeIndex:u}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,L=[],g=a.map((_,I)=>{if(at.isInRange(I,u)){const E=l(o({},_),{result:ct.batchUpdateResultByTrackID({id:n,newData:s,result:_.result})});return L.push({imgIndex:I,newInfo:E}),E}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:L}),l(o({},t),{imgList:g})}case i.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:s,stepList:u,step:a,predictionResult:p}=t,c={};p.forEach(I=>{const{index:E}=I;c[E]=_t.pick(I,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const L=`step_${a}`,g=[],_=s.map((I,E)=>{if(c[E]){const D=I.result==="{}"?x(Y("",{step:a,stepList:u},{rect:[]},{})):x(I.result);D[L].result.push(c[E]);const P=l(o({},I),{result:JSON.stringify(D)});return g.push({imgIndex:E,newInfo:P}),P}return I});return n==null||n(_,K.BatchUpdateImgList,-1,_,{updateImgList:g}),l(o({},t),{imgList:_})}default:return t}};export{xt as LoadFileAndFileData,Mt as annotationReducer,Vt as composeResultByToolInstance,w as getStepConfig,Ut as getTotalPage};
1
+ import{getFormatSize as vt}from"../../components/customResizeHook/index.js";import{ESubmitType as K}from"../../constant/index.js";import yt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as i}from"../Actions.js";import{jsonParser as x}from"../../utils/index.js";import X from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as Rt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as ct,composeResult as Y}from"../../utils/data.js";import O from"../../utils/StepUtils.js";import J from"../../utils/ToolUtils.js";import{MathUtils as dt,CommonToolUtils as Pt,AnnotationEngine as Ct,ImgUtils as Ot}from"@labelbee/lb-annotation";import{PointCloudUtils as pt,i18n as G}from"@labelbee/lb-utils";import{Modal as gt}from"antd";import{message as _t}from"antd/es";import It from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as W}from"../../data/enums/ToolType.js";var ht=Object.defineProperty,bt=Object.defineProperties,Nt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,Ut=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable,ft=(t,e,u)=>e in t?ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,o=(t,e)=>{for(var u in e||(e={}))Ut.call(e,u)&&ft(t,u,e[u]);if(mt)for(var u of mt(e))Bt.call(e,u)&&ft(t,u,e[u]);return t},l=(t,e)=>bt(t,Nt(e)),Tt=(t,e,u)=>new Promise((A,d)=>{var S=m=>{try{T(u.next(m))}catch(y){d(y)}},f=m=>{try{T(u.throw(m))}catch(y){d(y)}},T=m=>m.done?A(m.value):Promise.resolve(m.value).then(S,f);T((u=u.apply(t,e)).next())});const w=(t,e)=>t.find(u=>u.step===e),Lt={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},xt=t=>{const{imgList:e,imgPageSize:u}=t;return Math.ceil(e.length/u)},Et=(t,e)=>t.reduce((u,A)=>{if(A){const d=A.result;if(x(d)[`step_${e}`])return u+1}return u},0)/t.length,wt=(t,e)=>{const{step:u,stepList:A}=t,d=O.getCurrentStepInfo(u,A),S=Rt.jsonParser(d.config);if(J.isVideoTool(d==null?void 0:d.tool)||J.isAudioTool(d==null?void 0:d.tool)||J.isPointCloudTool(d==null?void 0:d.tool)||[W.LLM,W.NLP].includes(d==null?void 0:d.tool))return;const f=document.getElementById("toolContainer");if(!f)throw"Not exist dom named id-toolContainer";const T=vt({width:window.innerWidth,height:window.innerHeight}),m=new Ct({container:f,toolName:d.tool,size:T,imgNode:e,config:S,style:JSON.parse(yt)});return{toolInstance:m==null?void 0:m.toolInstance,annotationEngine:m}},Ft=(t,e)=>(u,A)=>Tt(void 0,null,function*(){var d,S;const{stepList:f,step:T}=A().annotation,m=O.currentToolIsVideo(T,f),y=O.currentToolIsPointCloud(T,f),h=((d=O.getCurrentStepInfo(T,f))==null?void 0:d.tool)===W.LLM,b=((S=O.getCurrentStepInfo(T,f))==null?void 0:S.tool)===W.NLP,N=O.currentToolIsAudio(T,f);if($(u,!0),yield u(jt(t)),m){u(Gt(t));return}if(y||h||N||b){u(Vt(t));return}u(Mt(t,e))}),jt=t=>(e,u)=>Tt(void 0,null,function*(){const{getFileData:A,imgList:d}=u().annotation;if(A){const S=yield A(d[t],t);e({type:i.SET_FILE_DATA,payload:{fileData:S,index:t}})}}),Gt=t=>e=>{e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},Vt=t=>e=>{$(e,!1),e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},Mt=(t,e)=>(u,A)=>{var d;const{toolInstance:S,imgList:f}=A().annotation,T=(d=f==null?void 0:f[t])==null?void 0:d.url;Ot.load(T).then(m=>{$(u,!1),u({type:i.LOAD_FILE_DATA,payload:{imgNode:m,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(u,!1),S==null||S.setErrorImg(),u({type:i.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},kt=({toolInstance:t,imgList:e,imgIndex:u,stepList:A,step:d=1})=>{var S,f,T,m;const y=((S=e[u])==null?void 0:S.result)||"",[h,b,N]=(f=t==null?void 0:t.exportData())!=null?f:[],V=(m=(T=t==null?void 0:t.exportCustomData)==null?void 0:T.call(t))!=null?m:{},M=ct(y,b),k=Y(M,{step:d,stepList:A},{rect:h},V);return e.map((F,H)=>H===u?o(l(o({},F),{result:k}),N):o({},F))},Ht=(t=o({},Lt),e)=>{var u,A,d,S,f,T,m,y,h,b,N,V,M,k,F,H,q,Z,Q,tt,et,nt,ot,st,lt,it,rt;switch(e.type){case i.INIT_ALL_STATE:return o(o({},t),Lt);case i.UPDATE_TOOL_INSTANCE:return l(o({},t),{toolInstance:e.payload.toolInstance});case i.UPDATE_IMG_LIST:return l(o({},t),{imgList:e.payload.imgList});case i.CALC_STEP_PROGRESS:{const{imgList:n,step:s}=t,r=Et(n,s);return l(o({},t),{stepProgress:r})}case i.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:s,step:r,stepList:a,toolInstance:p,onSubmit:c,resultList:L}=t;if(!p||!n[s])return t;const _=((u=n[s])==null?void 0:u.result)||"",[,g,I]=(A=p==null?void 0:p.exportData())!=null?A:[],E=(S=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?S:{},D=ct(_,g),R=Y(D,{step:r,stepList:a},{rect:L},E),v=t.imgList.map((C,P)=>{if(P===s){const j=X.dataCorrection(R,_,r,a);return o(l(o({},C),{result:j}),I)}return C});if(((f=e.payload)==null?void 0:f.submitType)===K.SyncImgList)return l(o({},t),{imgList:v});c&&c([v[s]],(T=e.payload)==null?void 0:T.submitType,s,v);const U=Et(v,r);return l(o({},t),{stepProgress:U,imgList:v})}case i.SAVE_RESULT:{const{imgList:n,imgIndex:s,onSave:r}=t;return r==null||r(n[s],s,n),o({},t)}case i.SUBMIT_RESULT:{const{imgList:n,basicIndex:s,resultList:r,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(m=a==null?void 0:a.exportData())!=null?m:[];let L=c;if((p==null?void 0:p.length)>0){const _=(y=p[s])==null?void 0:y.id,g=c.map(I=>l(o({},I),{sourceID:_}));L=It.cloneDeep(r).filter(I=>I.sourceID!==_),L.push(...g)}return l(o({},t),{resultList:L,imgList:n})}case i.SET_BASIC_INDEX:{const{toolInstance:n,step:s,imgList:r,imgIndex:a,stepList:p,annotationEngine:c,resultList:L,basicResultList:_}=t;if(!n||!c)return t;const g=e.payload.basicIndex,I=(h=_[g])==null?void 0:h.id,E=x((b=r[a])==null?void 0:b.result),D=(L||[]).filter(j=>j.sourceID===I),R=w(p,s),{dataSourceStep:v,tool:U}=R,C=w(p,v);let P=[];return v&&U&&(P=(N=E[`step_${v}`])==null?void 0:N.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[g]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),_t.info(G.t("NoDependency")))),n==null||n.setResult(D),n==null||n.history.initRecord(D,!0),l(o({},t),{basicIndex:g})}case i.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=e.payload;return l(o({},t),{triggerEventAfterIndexChanged:!!n})}case i.LOAD_FILE_DATA:{const{imgList:n,step:s,toolInstance:r,annotationEngine:a,stepList:p}=t;if(!r)return l(o({},t),{imgIndex:e.payload.nextIndex});const c=O.getCurrentStepInfo(s,p),{nextIndex:L,imgNode:_,nextBasicIndex:g,imgError:I}=e.payload,E=g!=null?g:0,D=x((V=n[L])==null?void 0:V.result),R=D[`step_${c.step}`],v=!R,U={rotate:(M=D.rotate)!=null?M:0,valid:(k=D.valid)!=null?k:!0};_&&I!==!0?a==null||a.setImgNode(_,U):r==null||r.setValid(U.valid);const C=w(p,c.step),{dataSourceStep:P,tool:j}=C,ut=w(p,P),at=P&&j,B=(H=(F=D[`step_${P}`])==null?void 0:F.result)!=null?H:[],z=X.getInitialResultList(R==null?void 0:R.result,r,C,B,v);if(a==null||a.launchOperation(),at&&((B==null?void 0:B.length)>0?a==null||a.setBasicInfo(ut.tool,B[E]):(a==null||a.setBasicInfo(ut.tool),a==null||a.forbidOperation(),_t.info(G.t("NoDependency")))),c.tool!=="check"){const At=(Z=(q=B[E])==null?void 0:q.id)!=null?Z:"",St=at?z.filter(Dt=>Pt.isSameSourceID(Dt.sourceID,At)):z;(Q=r==null?void 0:r.history)==null||Q.initRecord(z,!0),r==null||r.setResult(St)}return l(o({},t),{imgIndex:L,basicIndex:E,basicResultList:B,resultList:z})}case i.UPDATE_ANNOTATION_CONFIG:return l(o({},t),{config:(tt=e.payload.config)!=null?tt:"{}"});case i.SET_TASK_STEP_LIST:{const{stepList:n}=e.payload;return l(o({},t),{stepList:n})}case i.SET_TASK_CONFIG:{const{stepList:n,step:s}=e.payload;return l(o({},t),{stepList:n,step:s})}case i.INIT_TOOL:{const{imgNode:n}=t,s=wt(t,n);if(s){const{toolInstance:r,annotationEngine:a}=s;return l(o({},t),{toolInstance:r,annotationEngine:a})}return o({},t)}case i.SET_TOOL:{const n=(et=e.payload)==null?void 0:et.instance;return n?l(o({},t),{toolInstance:n}):o({},t)}case i.UPDATE_ON_SUBMIT:return l(o({},t),{onSubmit:e.payload.onSubmit});case i.UPDATE_ON_SAVE:return l(o({},t),{onSave:e.payload.onSave});case i.UPDATE_ON_PAGE_CHANGE:return l(o({},t),{onPageChange:e.payload.onPageChange});case i.SET_PREDICT_RESULT:return l(o({},t),{predictionResult:e.payload.result});case i.SET_PREDICT_RESULT_VISIBLE:return l(o({},t),{predictionResultVisible:e.payload.visible});case i.UPDATE_ON_STEP_CHANGE:return l(o({},t),{onStepChange:e.payload.onStepChange});case i.UPDATE_GET_FILE_DATA:return l(o({},t),{getFileData:e.payload.getFileData});case i.UPDATE_PAGE_SIZE:return l(o({},t),{pageSize:e.payload.pageSize});case i.UPDATE_LOAD_FILE_LIST:return l(o({},t),{loadFileList:e.payload.loadFileList});case i.UPDATE_BEFORE_ROTATE:return l(o({},t),{beforeRotate:e.payload.beforeRotate});case i.UPDATE_PRE_DATA_PROCESS:return l(o({},t),{preDataProcess:e.payload.preDataProcess});case i.UPDATE_IMG_INDEX_BY_EXTERNAL:return l(o({},t),{getImgIndexByExternal:e.payload.getImgIndexByExternal});case i.SKIP_BEFORE_PAGE_TURNING:return l(o({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case i.SET_FILE_DATA:{const{fileData:n,index:s}=e.payload,{imgList:r}=t,a=[...r];return a[s]=o(o({},a[s]),n),l(o({},t),{imgList:a})}case i.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:s}=t;return s&&s()===!1||(nt=n==null?void 0:n.updateRotate)==null||nt.call(n),t}case i.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=t,s=(ot=n==null?void 0:n.valid)!=null?ot:!0;return gt.destroyAll(),gt.confirm({content:G.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!s)},okText:G.t("Confirm"),cancelText:G.t("Cancel")}),t}case i.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:s,imgList:r,step:a}=t;if(!n)return t;if(s===0||s>=r.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const p=r[s-1].result;if(!p)return t;const c=X.copyResultChange({copyResult:p,step:a,currentResult:(st=r[s].result)!=null?st:"",preMappingImgList:(lt=r[s-1].mappingImgList)!=null?lt:[],mappingImgList:(it=r[s].mappingImgList)!=null?it:[]});r[s]=l(o({},r[s]),{result:c});const _=x(c)[`step_${a}`],g=(_==null?void 0:_.result)||[];return n==null||n.setResult(g),n==null||n.history.pushHistory(g),(rt=n==null?void 0:n.asyncData)==null||rt.call(n,r[s]),l(o({},t),{imgList:[...r]})}case i.SET_STEP:{const{stepList:n,annotationEngine:s}=t,{toStep:r}=e.payload;if(s){const a=w(n,r);return s==null||s.setToolName(a.tool,a.config),l(o({},t),{step:r,toolInstance:s==null?void 0:s.toolInstance})}return l(o({},t),{step:r})}case i.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=e.payload;return l(o({},t),{loadPCDFileLoading:!!n})}case i.SET_LOADING:{const{loading:n}=e.payload;return l(o({},t),{loading:!!n})}case i.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=e.payload;return l(o({},t),{pointCloudLoading:!!n})}case i.SET_CHECK_MODE:{const{checkMode:n}=e.payload;return l(o({},t),{checkMode:!!n})}case i.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=e.payload;return l(o({},t),{highlightAttribute:n})}case i.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:s,rangeIndex:r,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,L=[],_=a.map((g,I)=>{if(dt.isInRange(I,r)){const E=l(o({},g),{result:pt.batchUpdateTrackID({id:n,newID:s,result:g.result})});return L.push({imgIndex:I,newInfo:E}),E}return g});return c&&c([_[p]],K.BatchUpdateTrackID,p,_,{updateImgList:L}),l(o({},t),{imgList:_})}case i.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:s,rangeIndex:r}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,L=[],_=a.map((g,I)=>{if(dt.isInRange(I,r)){const E=l(o({},g),{result:pt.batchUpdateResultByTrackID({id:n,newData:s,result:g.result})});return L.push({imgIndex:I,newInfo:E}),E}return g});return c&&c([_[p]],K.BatchUpdateTrackID,p,_,{updateImgList:L}),l(o({},t),{imgList:_})}case i.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:s,stepList:r,step:a,predictionResult:p}=t,c={};p.forEach(I=>{const{index:E}=I;c[E]=It.pick(I,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const L=`step_${a}`,_=[],g=s.map((I,E)=>{if(c[E]){const D=I.result==="{}"?x(Y("",{step:a,stepList:r},{rect:[]},{})):x(I.result);D[L].result.push(c[E]);const R=l(o({},I),{result:JSON.stringify(D)});return _.push({imgIndex:E,newInfo:R}),R}return I});return n==null||n(g,K.BatchUpdateImgList,-1,g,{updateImgList:_}),l(o({},t),{imgList:g})}default:return t}};export{Ft as LoadFileAndFileData,Ht as annotationReducer,kt as composeResultByToolInstance,w as getStepConfig,xt as getTotalPage};
@@ -1 +1 @@
1
- import{uuid as v}from"@labelbee/lb-annotation";import{jsonParser as l}from"./index.js";import{EToolName as d}from"../data/enums/ToolType.js";import _ from"lodash";import y from"./StepUtils.js";var O=Object.defineProperty,P=Object.defineProperties,j=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,S=(a,t,e)=>t in a?O(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,E=(a,t)=>{for(var e in t||(t={}))w.call(t,e)&&S(a,e,t[e]);if(h)for(var e of h(t))x.call(t,e)&&S(a,e,t[e]);return a},N=(a,t)=>P(a,j(t));class R{static copyResultChange(t,e,r){try{const s=l(t),i=l(r),o=`step_${e}`;if(s[o]){const n=s[o];if(n.result)return n.result=n.result.map(u=>N(E({},u),{id:v(8,62)})),i[o]=n,JSON.stringify(i)}return t}catch(s){return t}}static isResultSourceMatchedDependence(t,e){const r=t==null?void 0:t.map(i=>i.sourceID).sort(),s=e==null?void 0:e.map(i=>i.id).sort();return _.isEqual(r,s)}static deltaUpdateBasicResultList(t,e){const r=t==null?void 0:t.map(s=>s.sourceID).sort();return e.filter(s=>!r.includes(s.id))}static getInitialResultList(t,e,r,s,i){const o=t!=null?t:[];switch(r.tool){case d.Tag:case d.Text:{if(r.dataSourceStep>0){const n=this.deltaUpdateBasicResultList(o,s);if(n.length>0)return o.concat(e.getInitResultList(r.dataSourceStep,n))}return i!==!0?o:e.getInitResultList(r.dataSourceStep,s)}default:return o}}static dataCorrection(t,e,r,s){var i,o;try{const u=`step_${y.getStepInfo(r,s).step}`,c=l(t),I=l(e),f=(i=c[u])==null?void 0:i.result,p=(o=I[u])==null?void 0:o.result;if(!p||_.isEqual(f.sort(this.idCmp),p.sort(this.idCmp)))return t;const m=this.findDeletedIds(f,p);if(m.length===0)return t;const D=r,g=this.getStepKeys(c).sort();return this.deleteRes(c,D,m,g),JSON.stringify(c)}catch(n){return console.error(n),t}}static idCmp(t,e){const r=t.id,s=e.id;return r<s?-1:r>s?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(r=>r.id)}static findDeletedItems(t,e){const r=[];return t.forEach(s=>{e.some(o=>o.id===s.id)||r.push(s)}),r}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,r,s){s.forEach(i=>{if(i>e){const o=t[`step_${i}`];if([d.FolderTag,d.Segmentation].includes(o.tool))return;if(o.dataSourceStep===e){const n=[];o.result=o.result.filter(u=>r.includes(u.sourceID)?(n.push(u.id),!1):!0),this.deleteRes(t,i,n,s)}else o.result=o.result.filter(n=>!r.includes(n.sourceID))}})}}export{R as default};
1
+ import{uuid as D}from"@labelbee/lb-annotation";import{jsonParser as f}from"./index.js";import{EToolName as m}from"../data/enums/ToolType.js";import I from"lodash";import S from"./StepUtils.js";class y{static traverseDF(t,e,s,i){e(t,s,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((n,r)=>{this.traverseDF(n,e,r,t)}):Object.keys(t).forEach(n=>{this.traverseDF(t[n],e,n,t)}))}static getNextPath(t){var e,s,i;const{prePath:n,preMappingImgList:r,nextMappingImgList:a}=t,c=(s=(e=r==null?void 0:r.find(l=>l.path===n))==null?void 0:e.calib)==null?void 0:s.calName,o=(i=a.find(l=>{var u;return((u=l.calib)==null?void 0:u.calName)===c}))==null?void 0:i.path;return o!=null?o:""}static copyResultItemHandler(t){const{item:e,key:s,parent:i,mappingImgList:n,preMappingImgList:r}=t;s==="id"&&(i.id=D(8,62)),s==="imageName"&&(i.imageName=this.getNextPath({prePath:e,preMappingImgList:r,nextMappingImgList:n}))}static copyResultChange(t){const{copyResult:e,step:s,currentResult:i,mappingImgList:n,preMappingImgList:r}=t;try{const a=f(e),c=f(i),o=`step_${s}`;if(a[o]){const l=a[o];return["result","resultRect"].forEach(d=>{l[d]&&this.traverseDF(l[d],(p,h,g)=>{this.copyResultItemHandler({item:p,key:h,parent:g,mappingImgList:n,preMappingImgList:r})})}),c[o]=l,JSON.stringify(c)}return e}catch(a){return e}}static isResultSourceMatchedDependence(t,e){const s=t==null?void 0:t.map(n=>n.sourceID).sort(),i=e==null?void 0:e.map(n=>n.id).sort();return I.isEqual(s,i)}static deltaUpdateBasicResultList(t,e){const s=t==null?void 0:t.map(i=>i.sourceID).sort();return e.filter(i=>!s.includes(i.id))}static getInitialResultList(t,e,s,i,n){const r=t!=null?t:[];switch(s.tool){case m.Tag:case m.Text:{if(s.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(r,i);if(a.length>0)return r.concat(e.getInitResultList(s.dataSourceStep,a))}return n!==!0?r:e.getInitResultList(s.dataSourceStep,i)}default:return r}}static dataCorrection(t,e,s,i){var n,r;try{const c=`step_${S.getStepInfo(s,i).step}`,o=f(t),l=f(e),u=(n=o[c])==null?void 0:n.result,d=(r=l[c])==null?void 0:r.result;if(!d||I.isEqual(u.sort(this.idCmp),d.sort(this.idCmp)))return t;const p=this.findDeletedIds(u,d);if(p.length===0)return t;const h=s,g=this.getStepKeys(o).sort();return this.deleteRes(o,h,p,g),JSON.stringify(o)}catch(a){return console.error(a),t}}static idCmp(t,e){const s=t.id,i=e.id;return s<i?-1:s>i?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(s=>s.id)}static findDeletedItems(t,e){const s=[];return t.forEach(i=>{e.some(r=>r.id===i.id)||s.push(i)}),s}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,s,i){i.forEach(n=>{if(n>e){const r=t[`step_${n}`];if([m.FolderTag,m.Segmentation].includes(r.tool))return;if(r.dataSourceStep===e){const a=[];r.result=r.result.filter(c=>s.includes(c.sourceID)?(a.push(c.id),!1):!0),this.deleteRes(t,n,a,i)}else r.result=r.result.filter(a=>!s.includes(a.sourceID))}})}}export{y as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.22",
3
+ "version": "1.23.0-alpha.23",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.27.0-alpha.11",
47
- "@labelbee/lb-utils": "1.19.0-alpha.6",
46
+ "@labelbee/lb-annotation": "1.27.0-alpha.12",
47
+ "@labelbee/lb-utils": "1.19.0-alpha.7",
48
48
  "@labelbee/wavesurfer": "1.0.0",
49
49
  "@types/react-dom": "^18.2.7",
50
50
  "@types/react-transition-group": "^4.4.9",