@labelbee/lb-components 1.6.0-alpha.5 → 1.6.0-alpha.7

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.
Files changed (35) hide show
  1. package/dist/components/AnnotationView/pointCloudAnnotationView.js +1 -1
  2. package/dist/components/pointCloudView/PointCloud2DView.js +1 -1
  3. package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
  4. package/dist/components/pointCloudView/PointCloudBackView.js +1 -1
  5. package/dist/components/pointCloudView/PointCloudInfos.js +1 -1
  6. package/dist/components/pointCloudView/PointCloudSideView.js +1 -1
  7. package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
  8. package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  9. package/dist/views/MainView/sidebar/GeneralOperation/useOperationList.js +1 -1
  10. package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  11. package/dist/views/MainView/sidebar/ToolIcons.js +1 -1
  12. package/es/components/AnnotationView/pointCloudAnnotationView.js +1 -1
  13. package/es/components/AnnotationView/pointCloudAnnotationView.js.map +1 -1
  14. package/es/components/pointCloudView/PointCloud2DView.js +1 -1
  15. package/es/components/pointCloudView/PointCloud2DView.js.map +1 -1
  16. package/es/components/pointCloudView/PointCloud3DView.js +1 -1
  17. package/es/components/pointCloudView/PointCloud3DView.js.map +1 -1
  18. package/es/components/pointCloudView/PointCloudBackView.js +1 -1
  19. package/es/components/pointCloudView/PointCloudBackView.js.map +1 -1
  20. package/es/components/pointCloudView/PointCloudInfos.js +1 -1
  21. package/es/components/pointCloudView/PointCloudInfos.js.map +1 -1
  22. package/es/components/pointCloudView/PointCloudSideView.js +1 -1
  23. package/es/components/pointCloudView/PointCloudSideView.js.map +1 -1
  24. package/es/components/pointCloudView/PointCloudTopView.js +1 -1
  25. package/es/components/pointCloudView/PointCloudTopView.js.map +1 -1
  26. package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  27. package/es/components/pointCloudView/hooks/usePointCloudViews.js.map +1 -1
  28. package/es/views/MainView/sidebar/GeneralOperation/useOperationList.js +1 -1
  29. package/es/views/MainView/sidebar/GeneralOperation/useOperationList.js.map +1 -1
  30. package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  31. package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js.map +1 -1
  32. package/es/views/MainView/sidebar/ToolIcons.js +1 -1
  33. package/es/views/MainView/sidebar/ToolIcons.js.map +1 -1
  34. package/package.json +4 -5
  35. package/LICENSE +0 -203
@@ -1 +1 @@
1
- "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React);const PointCloudAnnotationView=t=>{const{src:n,result:a,size:o}=t;let l=React.useRef();const r=React.useRef(),c=React.useCallback(e=>{l.current=e},[]);return React.useEffect(()=>{const e=new lbAnnotation.PointCloud({container:l.current,backgroundColor:"#ccc"});r.current=e},[]),React.useEffect(()=>{var e;(e=r.current)==null||e.init()},[o]),React.useEffect(()=>{var e;r.current&&n&&((e=r.current)==null||e.loadPCDFile(n))},[n]),React.useEffect(()=>{a&&lbUtils.PointCloudUtils.getBoxParamsFromResultList(a).forEach(u=>{var i;(i=r.current)==null||i.generateBox(u,u.id)})},[a]),React__default.default.createElement("div",{style:o,ref:c})};module.exports=PointCloudAnnotationView;
1
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React);const PointCloudAnnotationView=t=>{const{src:o,result:a,size:u}=t;let i=React.useRef();const r=React.useRef(),s=React.useCallback(e=>{i.current=e},[]);return React.useEffect(()=>{const e=new lbAnnotation.PointCloud({container:i.current,backgroundColor:"#ccc"});r.current=e},[]),React.useEffect(()=>{var e;(e=r.current)==null||e.init()},[u]),React.useEffect(()=>{var e;r.current&&o&&((e=r.current)==null||e.loadPCDFile(o))},[o]),React.useEffect(()=>(a&&lbUtils.PointCloudUtils.getBoxParamsFromResultList(a).forEach(l=>{var n;(n=r.current)==null||n.generateBox(l,l.id)}),()=>{var e;lbUtils.PointCloudUtils.getBoxParamsFromResultList(a).forEach(n=>{var c;(c=r.current)==null||c.removeObjectByName(n.id)}),(e=r.current)==null||e.render()}),[a]),React__default.default.createElement("div",{style:u,ref:s})};module.exports=PointCloudAnnotationView;
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),index=require("../AnnotationView/index.js"),PointCloudContext=require("./PointCloudContext.js"),reactRedux=require("react-redux"),icons=require("@ant-design/icons"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__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};const Toolbar=({onNext:e,onPrev:t,imgLength:n,imgIndex:l})=>React__default.default.createElement("div",null,React__default.default.createElement(icons.LeftOutlined,{onClick:t}),React__default.default.createElement("span",null," ",l+1," / ",n," "),React__default.default.createElement(icons.RightOutlined,{onClick:e})),PointCloud2DView=({imgInfo:e})=>{var t,n,l,g,_;const[c,y]=React.useState([]),{pointCloudBoxList:C,topViewInstance:L}=React.useContext(PointCloudContext.PointCloudContext),[u,p]=React.useState(0),P=React.useRef(null),v=React.useRef(),{selectedBox:f}=useSingleBox.useSingleBox(),E=useSize(P),r=(t=e==null?void 0:e.mappingImgList)==null?void 0:t[u];React.useEffect(()=>{p(0)},[e]),React.useEffect(()=>{if(L&&r){const{pointCloudInstance:o}=L,i={fill:"transparent",color:"green"},s=C.reduce((a,d)=>{const w=o.pointCloudLidar2image(d,r.calib);return[...a,...w.map(x=>({type:x.type,annotation:__spreadValues({id:d.id,pointList:x.pointList},i)}))]},[]);y(s)}},[C,r]);const m=!e||!(e==null?void 0:e.mappingImgList)||!(((n=e==null?void 0:e.mappingImgList)==null?void 0:n.length)>0);return React.useEffect(()=>{var o,i;const s=(o=v.current)==null?void 0:o.toolInstance;if(!f||!s)return;const a=c.find(d=>d.annotation.id===f.info.id);((i=a==null?void 0:a.annotation.pointList)==null?void 0:i.length)>0&&s.focusPositionByPointList(a==null?void 0:a.annotation.pointList)},[f,v.current,c]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-2d-container"),title:"2D\u89C6\u56FE",toolbar:m?void 0:React__default.default.createElement(Toolbar,{imgIndex:u,imgLength:(g=(l=e.mappingImgList)==null?void 0:l.length)!=null?g:0,onNext:()=>{var o;!e||!(e==null?void 0:e.mappingImgList)||u>=((o=e==null?void 0:e.mappingImgList)==null?void 0:o.length)-1||p(i=>i+1)},onPrev:()=>{u<=0||p(o=>o-1)}}),style:{display:m?"none":"flex"}},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-2d-image"),ref:P},React__default.default.createElement(index,{src:(_=r==null?void 0:r.url)!=null?_:"",annotations:c,size:E,ref:v,globalStyle:{display:m?"none":"block"}})))},mapStateToProps=e=>{const{imgList:t,imgIndex:n}=e.annotation;return{imgInfo:t[n]}};var PointCloud2DView$1=reactRedux.connect(mapStateToProps)(PointCloud2DView);module.exports=PointCloud2DView$1;
1
+ "use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),index=require("../AnnotationView/index.js"),PointCloudContext=require("./PointCloudContext.js"),reactRedux=require("react-redux"),icons=require("@ant-design/icons"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__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};const Toolbar=({onNext:e,onPrev:t,imgLength:n,imgIndex:l})=>React__default.default.createElement("div",null,React__default.default.createElement(icons.LeftOutlined,{onClick:t}),React__default.default.createElement("span",null," ",l+1," / ",n," "),React__default.default.createElement(icons.RightOutlined,{onClick:e})),PointCloud2DView=({imgInfo:e})=>{var t,n,l,g,_;const[c,y]=React.useState([]),{pointCloudBoxList:x,topViewInstance:L}=React.useContext(PointCloudContext.PointCloudContext),[s,p]=React.useState(0),P=React.useRef(null),v=React.useRef(),{selectedBox:f}=useSingleBox.useSingleBox(),w=useSize(P),{t:E}=reactI18next.useTranslation(),r=(t=e==null?void 0:e.mappingImgList)==null?void 0:t[s];React.useEffect(()=>{p(0)},[e]),React.useEffect(()=>{if(L&&r){const{pointCloudInstance:o}=L,i={fill:"transparent",color:"green"},u=x.reduce((a,d)=>{const S=o.pointCloudLidar2image(d,r.calib);return[...a,...S.map(C=>({type:C.type,annotation:__spreadValues({id:d.id,pointList:C.pointList},i)}))]},[]);y(u)}},[x,r]);const m=!e||!(e==null?void 0:e.mappingImgList)||!(((n=e==null?void 0:e.mappingImgList)==null?void 0:n.length)>0);return React.useEffect(()=>{var o,i;const u=(o=v.current)==null?void 0:o.toolInstance;if(!f||!u)return;const a=c.find(d=>d.annotation.id===f.info.id);((i=a==null?void 0:a.annotation.pointList)==null?void 0:i.length)>0&&u.focusPositionByPointList(a==null?void 0:a.annotation.pointList)},[f,v.current,c]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-2d-container"),title:E("2DView"),toolbar:m?void 0:React__default.default.createElement(Toolbar,{imgIndex:s,imgLength:(g=(l=e.mappingImgList)==null?void 0:l.length)!=null?g:0,onNext:()=>{var o;!e||!(e==null?void 0:e.mappingImgList)||s>=((o=e==null?void 0:e.mappingImgList)==null?void 0:o.length)-1||p(i=>i+1)},onPrev:()=>{s<=0||p(o=>o-1)}}),style:{display:m?"none":"flex"}},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-2d-image"),ref:P},React__default.default.createElement(index,{src:(_=r==null?void 0:r.url)!=null?_:"",annotations:c,size:w,ref:v,globalStyle:{display:m?"none":"block"}})))},mapStateToProps=e=>{const{imgList:t,imgIndex:n}=e.annotation;return{imgInfo:t[n]}};var PointCloud2DView$1=reactRedux.connect(mapStateToProps)(PointCloud2DView);module.exports=PointCloud2DView$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"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React);const pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{}}),PointCloudViewIcon=({perspectiveView:e})=>{const{isActive:l,setTarget3DView:a}=React.useContext(PointCloud3DContext),r=u=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",u)]:!0,active:l});return React__default.default.createElement("span",{onClick:()=>{a(lbUtils.EPerspectiveView[e])},className:r(e.toLocaleLowerCase())})},PointCloud3DSideBar=()=>{const{reset3DView:e}=React.useContext(PointCloud3DContext);return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},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"}),React__default.default.createElement("span",{onClick:()=>{e()},className:dom.getClassName("point-cloud-3d-view","reset")}))},PointCloud3D=({currentData:e})=>{var l;const a=React.useContext(PointCloudContext.PointCloudContext),[r,u]=React.useState(!0),s=React.useRef(null),{initPointCloud3d:c}=usePointCloudViews.usePointCloudViews(),m=useSize(s);React.useEffect(()=>{!a.mainViewInstance||c==null||c()},[m]);const{selectedBox:n}=useSingleBox.useSingleBox(),d=i=>{var t;const o=n==null?void 0:n.info;o&&((t=a.mainViewInstance)==null||t.updateCameraByBox(o,i))},v=()=>{var i;(i=a.mainViewInstance)==null||i.resetCamera()};React.useEffect(()=>{var i;if(s.current&&(e==null?void 0:e.url)){let t=a.mainViewInstance;if(t||(t=new lbAnnotation.PointCloud({container:s.current,backgroundColor:"#4c4c4c"})),e.result){const o=lbUtils.PointCloudUtils.getBoxParamsFromResultList(e.result);o.forEach(p=>{t==null||t.generateBox(p)}),a.setPointCloudResult(o),a.setPointCloudValid((i=index.jsonParser(e.result))==null?void 0:i.valid)}a.setMainViewInstance(t)}},[e]),React.useEffect(()=>{n&&d(lbUtils.EPerspectiveView.Top)},[n]);const C=React.useMemo(()=>({reset3DView:v,setTarget3DView:d,isActive:!!n}),[n]),f=React__default.default.createElement("div",null,React__default.default.createElement("span",{style:{marginRight:8}},"\u663E\u793A\u7BAD\u5934"),React__default.default.createElement(antd.Switch,{size:"small",checked:r,onChange:i=>{var t;u(i),(t=a.mainViewInstance)==null||t.setShowDirection(i)}}));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-3d-container"),title:"3D\u89C6\u56FE",toolbar:f,style:{height:e.mappingImgList&&((l=e.mappingImgList)==null?void 0:l.length)>0?"55%":"100%"}},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},React__default.default.createElement(PointCloud3DContext.Provider,{value:C},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:s})))};var PointCloud3DView=reactRedux.connect(map.aMapStateToProps)(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"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React);const pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{}}),PointCloudViewIcon=({perspectiveView:e})=>{const{isActive:s,setTarget3DView:a}=React.useContext(PointCloud3DContext),r=u=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",u)]:!0,active:s});return React__default.default.createElement("span",{onClick:()=>{a(lbUtils.EPerspectiveView[e])},className:r(e.toLocaleLowerCase())})},PointCloud3DSideBar=()=>{const{reset3DView:e}=React.useContext(PointCloud3DContext);return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},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"}),React__default.default.createElement("span",{onClick:()=>{e()},className:dom.getClassName("point-cloud-3d-view","reset")}))},PointCloud3D=({currentData:e})=>{var s;const a=React.useContext(PointCloudContext.PointCloudContext),[r,u]=React.useState(!0),l=React.useRef(null),{initPointCloud3d:c}=usePointCloudViews.usePointCloudViews(),v=useSize(l),{t:d}=reactI18next.useTranslation();React.useEffect(()=>{!a.mainViewInstance||c==null||c()},[v]);const{selectedBox:n}=useSingleBox.useSingleBox(),m=i=>{var t;const o=n==null?void 0:n.info;o&&((t=a.mainViewInstance)==null||t.updateCameraByBox(o,i))},C=()=>{var i;(i=a.mainViewInstance)==null||i.resetCamera()};React.useEffect(()=>{var i;if(l.current&&(e==null?void 0:e.url)){let t=a.mainViewInstance;if(t||(t=new lbAnnotation.PointCloud({container:l.current,backgroundColor:"#4c4c4c"})),e.result){const o=lbUtils.PointCloudUtils.getBoxParamsFromResultList(e.result);o.forEach(w=>{t==null||t.generateBox(w)}),a.setPointCloudResult(o),a.setPointCloudValid((i=index.jsonParser(e.result))==null?void 0:i.valid)}a.setMainViewInstance(t)}},[e]),React.useEffect(()=>{n&&m(lbUtils.EPerspectiveView.Top)},[n]);const f=React.useMemo(()=>({reset3DView:C,setTarget3DView:m,isActive:!!n}),[n]),p=React__default.default.createElement("div",null,React__default.default.createElement("span",{style:{marginRight:8}},d("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:r,onChange:i=>{var t;u(i),(t=a.mainViewInstance)==null||t.setShowDirection(i)}}));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-3d-container"),title:d("3DView"),toolbar:p,style:{height:e.mappingImgList&&((s=e.mappingImgList)==null?void 0:s.length)>0?"55%":"100%"}},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},React__default.default.createElement(PointCloud3DContext.Provider,{value:f},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:l})))};var PointCloud3DView=reactRedux.connect(map.aMapStateToProps)(PointCloud3D);module.exports=PointCloud3DView;
@@ -1 +1 @@
1
- "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),dom=require("../../utils/dom.js"),PointCloudLayout=require("./PointCloudLayout.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useSingleBox=require("./hooks/useSingleBox.js"),lbUtils=require("@labelbee/lb-utils"),PointCloudInfos=require("./PointCloudInfos.js"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),index=require("./components/EmptyPage/index.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React);const TransferCanvas2WorldOffset=(t,e,n=1)=>{const{width:i,height:s}=e,r={x:t.x+i*n/2,y:t.y+s*n/2},o={x:e.width/2,y:e.height/2};return{offsetX:(o.x-r.x)/n,offsetY:-(o.y-r.y)/n}},updateBackViewByCanvas2D=(t,e,n,i,s)=>{const{offsetX:r,offsetY:o}=TransferCanvas2WorldOffset(t,n,e);if(s.camera.zoom=e,t){const c=Math.cos(i.rotation),a=Math.sin(i.rotation),l=r*c,u=r*a,{x:d,y:f,z:C}=s.initCameraPosition;s.camera.position.set(d+u,f-l,C+o)}s.camera.updateProjectionMatrix(),s.render()},PointCloudSideView=({currentData:t})=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),n=React.useRef(null),i=useSize(n),{updateSelectedBox:s,selectedBox:r}=useSingleBox.useSingleBox();return React.useEffect(()=>{if(n.current){const o={width:n.current.clientWidth,height:n.current.clientHeight},c=new lbAnnotation.PointCloudAnnotation({container:n.current,size:o,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0}});e.setBackViewInstance(c)}},[]),React.useEffect(()=>{if(!i||!e.backViewInstance)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=e.backViewInstance;o.singleOn("renderZoom",(a,l)=>{!e.selectedPointCloudBox||updateBackViewByCanvas2D(l,a,i,e.selectedPointCloudBox,c)}),o.singleOn("dragMove",({currentPos:a,zoom:l})=>{!e.selectedPointCloudBox||updateBackViewByCanvas2D(a,l,i,e.selectedPointCloudBox,c)}),o.singleOn("updatePolygonByDrag",({newPolygon:a,originPolygon:l})=>{if(!e.selectedPointCloudBox||!e.mainViewInstance||!t.url)return;const[u,d,f]=a.pointList,[C,x,w]=l.pointList,p=lbAnnotation.MathUtils.getLineCenterPoint([u,f]),g=lbAnnotation.MathUtils.getLineCenterPoint([C,w]),P={x:{x:p.x-g.x,y:p.y-g.y}.x,y:0,z:p.y-g.y},v=lbAnnotation.MathUtils.getLineLength(u,d),m=lbAnnotation.MathUtils.getLineLength(C,x),y=v-m,B=lbAnnotation.MathUtils.getLineLength(d,f),V=lbAnnotation.MathUtils.getLineLength(x,w),L=B-V,{newBoxParams:h}=c.getNewBoxByBackUpdate(P,L,y,e.selectedPointCloudBox);usePointCloudViews.synchronizeTopView(h,a,e.topViewInstance,e.mainViewInstance),usePointCloudViews.synchronizeSideView(h,a,e.sideViewInstance,t.url),e.mainViewInstance.highlightOriginPointCloud(h),s(h)})},[e,i]),React.useEffect(()=>{var o;(o=e==null?void 0:e.backViewInstance)==null||o.initSize(i)},[i]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","back-view"),title:"\u80CC\u89C6\u56FE",toolbar:React__default.default.createElement(PointCloudInfos.SizeInfoForView,{perspectiveView:lbUtils.EPerspectiveView.Back})},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","bottom-view-content")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","core-instance"),ref:n}),!r&&React__default.default.createElement(index,null)))};var PointCloudBackView=reactRedux.connect(map.aMapStateToProps)(PointCloudSideView);module.exports=PointCloudBackView;
1
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),dom=require("../../utils/dom.js"),PointCloudLayout=require("./PointCloudLayout.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useSingleBox=require("./hooks/useSingleBox.js"),lbUtils=require("@labelbee/lb-utils"),PointCloudInfos=require("./PointCloudInfos.js"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),index=require("./components/EmptyPage/index.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React);const TransferCanvas2WorldOffset=(t,e,n=1)=>{const{width:o,height:s}=e,r={x:t.x+o*n/2,y:t.y+s*n/2},u={x:e.width/2,y:e.height/2};return{offsetX:(u.x-r.x)/n,offsetY:-(u.y-r.y)/n}},updateBackViewByCanvas2D=(t,e,n,o,s)=>{const{offsetX:r,offsetY:u}=TransferCanvas2WorldOffset(t,n,e);if(s.camera.zoom=e,t){const i=Math.cos(o.rotation),c=Math.sin(o.rotation),a=r*i,l=r*c,{x:d,y:f,z:h}=s.initCameraPosition;s.camera.position.set(d+l,f-a,h+u)}s.camera.updateProjectionMatrix(),s.render()},PointCloudSideView=({currentData:t})=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),n=React.useRef(null),o=useSize(n),{updateSelectedBox:s,selectedBox:r}=useSingleBox.useSingleBox(),{t:u}=reactI18next.useTranslation();return React.useEffect(()=>{if(n.current){const i={width:n.current.clientWidth,height:n.current.clientHeight},c=new lbAnnotation.PointCloudAnnotation({container:n.current,size:i,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0}});e.setBackViewInstance(c)}},[]),React.useEffect(()=>{if(!o||!e.backViewInstance)return;const{pointCloud2dOperation:i,pointCloudInstance:c}=e.backViewInstance;i.singleOn("renderZoom",(a,l)=>{!e.selectedPointCloudBox||updateBackViewByCanvas2D(l,a,o,e.selectedPointCloudBox,c)}),i.singleOn("dragMove",({currentPos:a,zoom:l})=>{!e.selectedPointCloudBox||updateBackViewByCanvas2D(a,l,o,e.selectedPointCloudBox,c)}),i.singleOn("updatePolygonByDrag",({newPolygon:a,originPolygon:l})=>{if(!e.selectedPointCloudBox||!e.mainViewInstance||!t.url)return;const[d,f,h]=a.pointList,[g,w,v]=l.pointList,C=lbAnnotation.MathUtils.getLineCenterPoint([d,h]),x=lbAnnotation.MathUtils.getLineCenterPoint([g,v]),P={x:{x:C.x-x.x,y:C.y-x.y}.x,y:0,z:C.y-x.y},m=lbAnnotation.MathUtils.getLineLength(d,f),y=lbAnnotation.MathUtils.getLineLength(g,w),B=m-y,V=lbAnnotation.MathUtils.getLineLength(f,h),L=lbAnnotation.MathUtils.getLineLength(w,v),b=V-L,{newBoxParams:p}=c.getNewBoxByBackUpdate(P,b,B,e.selectedPointCloudBox);usePointCloudViews.synchronizeTopView(p,a,e.topViewInstance,e.mainViewInstance),usePointCloudViews.synchronizeSideView(p,a,e.sideViewInstance,t.url),e.mainViewInstance.highlightOriginPointCloud(p),s(p)})},[e,o]),React.useEffect(()=>{var i;(i=e==null?void 0:e.backViewInstance)==null||i.initSize(o)},[o]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","back-view"),title:u("BackView"),toolbar:React__default.default.createElement(PointCloudInfos.SizeInfoForView,{perspectiveView:lbUtils.EPerspectiveView.Back})},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","bottom-view-content")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","core-instance"),ref:n}),!r&&React__default.default.createElement(index,null)))};var PointCloudBackView=reactRedux.connect(map.aMapStateToProps)(PointCloudSideView);module.exports=PointCloudBackView;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useSingleBox=require("./hooks/useSingleBox.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const DECIMAL_PLACES=2,SizeInfoForView=({perspectiveView:e})=>{const{pointCloudBoxList:l,selectedID:i}=React__default.default.useContext(PointCloudContext.PointCloudContext),n=l.find(t=>t.id===i);if(i&&n){const{length:t,width:u,height:r}=lbUtils.PointCloudUtils.transferBox2Kitti(n),s=e===lbUtils.EPerspectiveView.Back?[{label:"\u5BBD",value:u},{label:"\u9AD8",value:r}]:[{label:"\u957F",value:t},{label:"\u5BBD",value:u}];return React__default.default.createElement(React__default.default.Fragment,null,s.map((a,o)=>React__default.default.createElement("span",{key:o,style:{marginRight:o===0?16:0,fontSize:12}},`${a.label}: ${a.value.toFixed(DECIMAL_PLACES)}`)))}return null},BoxInfos=()=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),{selectedBox:l}=useSingleBox.useSingleBox(),[i,n]=React.useState([]);return React.useEffect(()=>{var t;if(!l)return;const{length:u,width:r,height:s,rotation_y:a}=lbUtils.PointCloudUtils.transferBox2Kitti(l.info);let o=[{label:"\u957F",value:u.toFixed(DECIMAL_PLACES)},{label:"\u5BBD",value:r.toFixed(DECIMAL_PLACES)},{label:"\u9AD8",value:s.toFixed(DECIMAL_PLACES)},{label:"\u671D\u5411\u89D2",value:lbAnnotation.UnitUtils.rad2deg(a).toFixed(DECIMAL_PLACES)}];(t=e.mainViewInstance)==null||t.filterPointsByBox(l.info).then(d=>{if(!d){n(o);return}o.push({label:"\u70B9\u6570",value:`${d.num}`}),n(o)})},[l]),l?React__default.default.createElement("div",{style:{position:"absolute",color:"white",backgroundColor:"rgba(153, 153, 153, 0.3)",right:8,top:8,fontSize:12,padding:8,zIndex:20}},i.map(t=>React__default.default.createElement("div",{key:t.label},`${t.label}: ${t.value}`))):null},PointCloudValidity=()=>React__default.default.useContext(PointCloudContext.PointCloudContext).valid===!1?React__default.default.createElement("div",{style:{position:"absolute",backgroundColor:"rgb(242, 101, 73)",color:"white",left:0,top:0,fontSize:20,padding:"8px 16px",zIndex:20}},"\u65E0\u6548"):null;exports.BoxInfos=BoxInfos,exports.PointCloudValidity=PointCloudValidity,exports.SizeInfoForView=SizeInfoForView;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useSingleBox=require("./hooks/useSingleBox.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const DECIMAL_PLACES=2,SizeInfoForView=({perspectiveView:e})=>{const{pointCloudBoxList:n,selectedID:a}=React__default.default.useContext(PointCloudContext.PointCloudContext),l=n.find(i=>i.id===a),d=reactI18next.useTranslation(),{t}=d;if(a&&l){const{length:i,width:o,height:r}=lbUtils.PointCloudUtils.transferBox2Kitti(l),c=e===lbUtils.EPerspectiveView.Back?[{label:t("Width"),value:o},{label:t("Height"),value:r}]:[{label:t("Length"),value:i},{label:t("Height"),value:r}];return React__default.default.createElement(React__default.default.Fragment,null,c.map((u,s)=>React__default.default.createElement("span",{key:s,style:{marginRight:s===0?16:0,fontSize:12}},`${u.label}: ${u.value.toFixed(DECIMAL_PLACES)}`)))}return null},BoxInfos=()=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),{selectedBox:n}=useSingleBox.useSingleBox(),[a,l]=React.useState([]),d=reactI18next.useTranslation(),{t,i18n:i}=d;return React.useEffect(()=>{var o;if(!n)return;const{length:r,width:c,height:u,rotation_y:s}=lbUtils.PointCloudUtils.transferBox2Kitti(n.info);let f=[{label:t("Length"),value:r.toFixed(DECIMAL_PLACES)},{label:t("Width"),value:c.toFixed(DECIMAL_PLACES)},{label:t("Height"),value:u.toFixed(DECIMAL_PLACES)},{label:t("Rotation_y"),value:lbAnnotation.UnitUtils.rad2deg(s).toFixed(DECIMAL_PLACES)}];(o=e.mainViewInstance)==null||o.filterPointsByBox(n.info).then(x=>{if(!x){l(f);return}f.push({label:t("PointCount"),value:`${x.num}`}),l(f)})},[n,i.language]),n?React__default.default.createElement("div",{style:{position:"absolute",color:"white",backgroundColor:"rgba(153, 153, 153, 0.3)",right:8,top:8,fontSize:12,padding:8,zIndex:20}},a.map(o=>React__default.default.createElement("div",{key:o.label},`${o.label}: ${o.value}`))):null},PointCloudValidity=()=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),{t:n}=reactI18next.useTranslation();return e.valid===!1?React__default.default.createElement("div",{style:{position:"absolute",backgroundColor:"rgb(242, 101, 73)",color:"white",left:0,top:0,fontSize:20,padding:"8px 16px",zIndex:20}},n("Invalid")):null};exports.BoxInfos=BoxInfos,exports.PointCloudValidity=PointCloudValidity,exports.SizeInfoForView=SizeInfoForView;
@@ -1 +1 @@
1
- "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),dom=require("../../utils/dom.js"),PointCloudLayout=require("./PointCloudLayout.js"),React=require("react"),lbUtils=require("@labelbee/lb-utils"),PointCloudContext=require("./PointCloudContext.js"),PointCloudInfos=require("./PointCloudInfos.js"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSingleBox=require("./hooks/useSingleBox.js"),index=require("./components/EmptyPage/index.js"),useSize=require("../../hooks/useSize.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React);const TransferCanvas2WorldOffset=(o,e,s=1)=>{const{width:u,height:t}=e,i={x:o.x+u*s/2,y:o.y+t*s/2},n={x:e.width/2,y:e.height/2};return{offsetX:(n.x-i.x)/s,offsetY:-(n.y-i.y)/s}},updateSideViewByCanvas2D=(o,e,s,u,t)=>{const{offsetX:i,offsetY:n}=TransferCanvas2WorldOffset(o,s,e);if(t.camera.zoom=e,o){const l=Math.cos(u.rotation),r=Math.sin(u.rotation),a=i*l,c=i*r,{x:d,y:f,z:C}=t.initCameraPosition;t.camera.position.set(d-a,f-c,C+n)}t.camera.updateProjectionMatrix(),t.render()},PointCloudSideView=({currentData:o})=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),{sideViewUpdateBox:s}=usePointCloudViews.usePointCloudViews(),{selectedBox:u}=useSingleBox.useSingleBox(),t=React.useRef(null),i=useSize(t);return React.useEffect(()=>{if(t.current){const n={width:t.current.clientWidth,height:t.current.clientHeight},l=new lbAnnotation.PointCloudAnnotation({container:t.current,size:n,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0}});e.setSideViewInstance(l)}},[]),React.useEffect(()=>{if(!i||!e.sideViewInstance)return;const{pointCloud2dOperation:n,pointCloudInstance:l}=e.sideViewInstance;n.singleOn("renderZoom",(r,a)=>{!e.selectedPointCloudBox||updateSideViewByCanvas2D(a,r,i,e.selectedPointCloudBox,l)}),n.singleOn("dragMove",({currentPos:r,zoom:a})=>{!e.selectedPointCloudBox||updateSideViewByCanvas2D(r,a,i,e.selectedPointCloudBox,l)}),n.singleOn("updatePolygonByDrag",({newPolygon:r,originPolygon:a})=>{s(r,a)})},[e,i]),React.useEffect(()=>{var n;(n=e==null?void 0:e.sideViewInstance)==null||n.initSize(i)},[i]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","side-view"),title:"\u4FA7\u89C6\u56FE",toolbar:React__default.default.createElement(PointCloudInfos.SizeInfoForView,{perspectiveView:lbUtils.EPerspectiveView.Left})},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","bottom-view-content")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","core-instance"),ref:t}),!u&&React__default.default.createElement(index,null)))};var PointCloudSideView$1=reactRedux.connect(map.aMapStateToProps)(PointCloudSideView);module.exports=PointCloudSideView$1;
1
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),dom=require("../../utils/dom.js"),PointCloudLayout=require("./PointCloudLayout.js"),React=require("react"),lbUtils=require("@labelbee/lb-utils"),PointCloudContext=require("./PointCloudContext.js"),PointCloudInfos=require("./PointCloudInfos.js"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSingleBox=require("./hooks/useSingleBox.js"),index=require("./components/EmptyPage/index.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var React__default=_interopDefaultLegacy(React);const TransferCanvas2WorldOffset=(n,e,r=1)=>{const{width:u,height:t}=e,o={x:n.x+u*r/2,y:n.y+t*r/2},c={x:e.width/2,y:e.height/2};return{offsetX:(c.x-o.x)/r,offsetY:-(c.y-o.y)/r}},updateSideViewByCanvas2D=(n,e,r,u,t)=>{const{offsetX:o,offsetY:c}=TransferCanvas2WorldOffset(n,r,e);if(t.camera.zoom=e,n){const i=Math.cos(u.rotation),l=Math.sin(u.rotation),a=o*i,s=o*l,{x:d,y:f,z:C}=t.initCameraPosition;t.camera.position.set(d-a,f-s,C+c)}t.camera.updateProjectionMatrix(),t.render()},PointCloudSideView=({currentData:n})=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),{sideViewUpdateBox:r}=usePointCloudViews.usePointCloudViews(),{selectedBox:u}=useSingleBox.useSingleBox(),t=React.useRef(null),o=useSize(t),{t:c}=reactI18next.useTranslation();return React.useEffect(()=>{if(t.current){const i={width:t.current.clientWidth,height:t.current.clientHeight},l=new lbAnnotation.PointCloudAnnotation({container:t.current,size:i,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0}});e.setSideViewInstance(l)}},[]),React.useEffect(()=>{if(!o||!e.sideViewInstance)return;const{pointCloud2dOperation:i,pointCloudInstance:l}=e.sideViewInstance;i.singleOn("renderZoom",(a,s)=>{!e.selectedPointCloudBox||updateSideViewByCanvas2D(s,a,o,e.selectedPointCloudBox,l)}),i.singleOn("dragMove",({currentPos:a,zoom:s})=>{!e.selectedPointCloudBox||updateSideViewByCanvas2D(a,s,o,e.selectedPointCloudBox,l)}),i.singleOn("updatePolygonByDrag",({newPolygon:a,originPolygon:s})=>{r(a,s)})},[e,o]),React.useEffect(()=>{var i;(i=e==null?void 0:e.sideViewInstance)==null||i.initSize(o)},[o]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","side-view"),title:c("SideView"),toolbar:React__default.default.createElement(PointCloudInfos.SizeInfoForView,{perspectiveView:lbUtils.EPerspectiveView.Left})},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","bottom-view-content")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","core-instance"),ref:t}),!u&&React__default.default.createElement(index,null)))};var PointCloudSideView$1=reactRedux.connect(map.aMapStateToProps)(PointCloudSideView);module.exports=PointCloudSideView$1;
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),index=require("../../views/MainView/toolFooter/index.js"),index$1=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React);const{EPolygonPattern}=lbAnnotation.cTool,TransferCanvas2WorldOffset=(o,i,e=1)=>{const{width:l,height:c}=i,r={x:o.x+l*e/2,y:o.y+c*e/2},u={x:i.width/2,y:i.height/2};return{offsetX:(u.x-r.x)/e,offsetY:-(u.y-r.y)/e}},TopViewToolbar=({currentData:o})=>{const{zoom:i,zoomIn:e,zoomOut:l,initialPosition:c}=useZoom.useZoom(),{selectNextBox:r,selectPrevBox:u}=useSingleBox.useSingleBox(),{updateRotate:f}=useRotate.useRotate({currentData:o}),d=2,m=()=>{f(-d)},a=()=>{f(d)},t=()=>{f(180)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("span",{onClick:a,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:m,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:t,className:dom.getClassName("point-cloud","rotate-180")}),React__default.default.createElement(index.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{u()},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{r()},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index.FooterDivider,null),React__default.default.createElement(index$1.ZoomController,{initialPosition:c,zoomIn:e,zoomOut:l,zoom:i}))},ZAxisSlider=({setZAxisLimit:o,zAxisLimit:i})=>React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:i,onAfterChange:e=>{o(e)}})),PointCloudTopView=({currentData:o})=>{const i=React.useRef(null),e=React__default.default.useContext(PointCloudContext.PointCloudContext),l=useSize(i),{setZoom:c}=useZoom.useZoom(),{addPolygon:r,deletePolygon:u}=usePolygon.usePolygon(),{deletePointCloudBox:f}=useSingleBox.useSingleBox(),[d,m]=React.useState(10),a=usePointCloudViews.usePointCloudViews();return React.useLayoutEffect(()=>{if(i.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const t={width:i.current.clientWidth,height:i.current.clientHeight},n=new lbAnnotation.PointCloudAnnotation({container:i.current,size:t,pcdPath:o.url});e.setTopViewInstance(n)}},[]),React.useEffect(()=>{if(!l||!e.topViewInstance||!e.sideViewInstance)return;const{pointCloud2dOperation:t}=e.topViewInstance;t.singleOn("polygonCreated",n=>{if(t.pattern===EPolygonPattern.Normal||!(o==null?void 0:o.url)){r(n);return}a.topViewAddBox(n,l)}),t.singleOn("deletedObject",({id:n})=>{f(n),u(n)}),t.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),t.singleOn("addSelectedIDs",n=>{e.addSelectedID(n)}),t.singleOn("setSelectedIDs",n=>{e.setSelectedIDs(n)}),t.singleOn("updatePolygonByDrag",({newPolygon:n})=>{var s;(s=a.topViewUpdateBox)==null||s.call(a,n,l)})},[e,l,o,a]),React.useEffect(()=>{if(!(l==null?void 0:l.width)||!e.topViewInstance)return;e.topViewInstance.initSize(l),e.topViewInstance.updatePolygonList(e.pointCloudBoxList);const{topViewInstance:{pointCloudInstance:t,pointCloud2dOperation:n}}=e;n.singleOn("renderZoom",(s,p)=>{const{offsetX:C,offsetY:v}=TransferCanvas2WorldOffset(p,l,s);if(t.camera.zoom=s,p){const{x:g,y:x,z:w}=t.initCameraPosition;t.camera.position.set(g+v,x-C,w)}t.camera.updateProjectionMatrix(),t.render(),c(s)}),n.singleOn("dragMove",({currentPos:s,zoom:p})=>{const{offsetX:C,offsetY:v}=TransferCanvas2WorldOffset(s,l,p);t.camera.zoom=p;const{x:g,y:x,z:w}=t.initCameraPosition;t.camera.position.set(g+v,x-C,w),t.render()})},[l]),React.useEffect(()=>{var t,n;(n=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null||n.applyZAxisPoints(d)},[d]),React.useEffect(()=>{a.topViewSelectedChanged()},[e.selectedIDs]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:"\u4FEF\u89C6\u56FE",toolbar:React__default.default.createElement(TopViewToolbar,{currentData:o})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:i}),React__default.default.createElement(PointCloudInfos.BoxInfos,null),React__default.default.createElement(ZAxisSlider,{zAxisLimit:d,setZAxisLimit:m}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.aMapStateToProps)(PointCloudTopView);module.exports=PointCloudTopView$1;
1
+ "use strict";var dom=require("../../utils/dom.js"),index=require("../../views/MainView/toolFooter/index.js"),index$1=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React);const{EPolygonPattern}=lbAnnotation.cTool,TransferCanvas2WorldOffset=(t,i,e=1)=>{const{width:l,height:c}=i,r={x:t.x+l*e/2,y:t.y+c*e/2},u={x:i.width/2,y:i.height/2};return{offsetX:(u.x-r.x)/e,offsetY:-(u.y-r.y)/e}},TopViewToolbar=({currentData:t})=>{const{zoom:i,zoomIn:e,zoomOut:l,initialPosition:c}=useZoom.useZoom(),{selectNextBox:r,selectPrevBox:u}=useSingleBox.useSingleBox(),{updateRotate:f}=useRotate.useRotate({currentData:t}),d=2,m=()=>{f(-d)},C=()=>{f(d)},a=()=>{f(180)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("span",{onClick:C,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:m,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:a,className:dom.getClassName("point-cloud","rotate-180")}),React__default.default.createElement(index.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{u()},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{r()},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index.FooterDivider,null),React__default.default.createElement(index$1.ZoomController,{initialPosition:c,zoomIn:e,zoomOut:l,zoom:i}))},ZAxisSlider=({setZAxisLimit:t,zAxisLimit:i})=>React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:i,onAfterChange:e=>{t(e)}})),PointCloudTopView=({currentData:t})=>{const i=React.useRef(null),e=React__default.default.useContext(PointCloudContext.PointCloudContext),l=useSize(i),{setZoom:c}=useZoom.useZoom(),{addPolygon:r,deletePolygon:u}=usePolygon.usePolygon(),{deletePointCloudBox:f}=useSingleBox.useSingleBox(),[d,m]=React.useState(10),{t:C}=reactI18next.useTranslation(),a=usePointCloudViews.usePointCloudViews();return React.useLayoutEffect(()=>{if(i.current&&(t==null?void 0:t.url)&&(t==null?void 0:t.result)){const o={width:i.current.clientWidth,height:i.current.clientHeight},n=new lbAnnotation.PointCloudAnnotation({container:i.current,size:o,pcdPath:t.url});e.setTopViewInstance(n)}},[]),React.useEffect(()=>{if(!l||!e.topViewInstance||!e.sideViewInstance)return;const{pointCloud2dOperation:o}=e.topViewInstance;o.singleOn("polygonCreated",n=>{if(o.pattern===EPolygonPattern.Normal||!(t==null?void 0:t.url)){r(n);return}a.topViewAddBox(n,l)}),o.singleOn("deletedObject",({id:n})=>{f(n),u(n)}),o.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),o.singleOn("addSelectedIDs",n=>{e.addSelectedID(n)}),o.singleOn("setSelectedIDs",n=>{e.setSelectedIDs(n)}),o.singleOn("updatePolygonByDrag",({newPolygon:n})=>{var s;(s=a.topViewUpdateBox)==null||s.call(a,n,l)})},[e,l,t,a]),React.useEffect(()=>{if(!(l==null?void 0:l.width)||!e.topViewInstance)return;e.topViewInstance.initSize(l),e.topViewInstance.updatePolygonList(e.pointCloudBoxList);const{topViewInstance:{pointCloudInstance:o,pointCloud2dOperation:n}}=e;n.singleOn("renderZoom",(s,p)=>{const{offsetX:v,offsetY:x}=TransferCanvas2WorldOffset(p,l,s);if(o.camera.zoom=s,p){const{x:g,y:w,z:P}=o.initCameraPosition;o.camera.position.set(g+x,w-v,P)}o.camera.updateProjectionMatrix(),o.render(),c(s)}),n.singleOn("dragMove",({currentPos:s,zoom:p})=>{const{offsetX:v,offsetY:x}=TransferCanvas2WorldOffset(s,l,p);o.camera.zoom=p;const{x:g,y:w,z:P}=o.initCameraPosition;o.camera.position.set(g+x,w-v,P),o.render()})},[l]),React.useEffect(()=>{var o,n;(n=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null||n.applyZAxisPoints(d)},[d]),React.useEffect(()=>{a.topViewSelectedChanged()},[e.selectedIDs]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:C("TopView"),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:t})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:i}),React__default.default.createElement(PointCloudInfos.BoxInfos,null),React__default.default.createElement(ZAxisSlider,{zAxisLimit:d,setZAxisLimit:m}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.aMapStateToProps)(PointCloudTopView);module.exports=PointCloudTopView$1;
@@ -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"),_=require("lodash"),reactRedux=require("react-redux"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__async=(e,i,s)=>new Promise((d,t)=>{var n=r=>{try{c(s.next(r))}catch(h){t(h)}},u=r=>{try{c(s.throw(r))}catch(h){t(h)}},c=r=>r.done?d(r.value):Promise.resolve(r.value).then(n,u);c((s=s.apply(e,i)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},transferCanvas2World=(e,i)=>{const{width:s,height:d}=i,{x:t,y:n}=e;return{x:-n+d/2,y:-(t-s/2)}},topViewPolygon2PointCloud=(e,i,s,d,t)=>{const[n,u,c,r]=e.pointList.map(f=>transferCanvas2World(f,i)),h=lbAnnotation.MathUtils.getLineCenterPoint([n,c]),L=lbAnnotation.MathUtils.getLineLength(n,u),p=lbAnnotation.MathUtils.getLineLength(u,c),g=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);let y=0,P=1;if(s){const f=s.getSensesPointZAxisInPolygon([n,u,c,r]);y=(f.maxZ+f.minZ)/2,P=f.maxZ-f.minZ}d&&(y=d.center.z,P=d.depth);const v={center:{x:h.x,y:h.y,z:y},width:p,height:L,depth:P,rotation:g,id:e.id,attribute:"",valid:!0};return t&&Object.assign(v,t),v},sideViewPolygon2PointCloud=(e,i,s,d)=>{const[t,n,u]=e.pointList,[c,r,h]=i.pointList,L=lbAnnotation.MathUtils.getLineCenterPoint([t,u]),p=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),g={x:L.x-p.x,y:L.y-p.y},y=Math.cos(s.rotation),P=Math.sin(s.rotation),v={x:g.x,y:g.x*P+g.y*y,z:L.y-p.y},f=lbAnnotation.MathUtils.getLineLength(t,n),w=lbAnnotation.MathUtils.getLineLength(c,r),U=f-w,V=lbAnnotation.MathUtils.getLineLength(n,u),b=lbAnnotation.MathUtils.getLineLength(r,h),D=V-b,{newBoxParams:I}=d.getNewBoxBySideUpdate(v,D,U,s);return I},synchronizeSideView=(e,i,s,d)=>{if(!s)return;const{pointCloud2dOperation:t,pointCloudInstance:n}=s;n.loadPCDFileByBox(d,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:u}=n.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);n.setInitCameraPosition(u);const{polygon2d:c,zoom:r}=n.getBoxSidePolygon2DCoordinate(e);n.camera.zoom=r,n.camera.updateProjectionMatrix(),n.render(),t.initPosition(),t.zoomChangeOnCenter(r),t.setResultAndSelectedID([{id:i.id,pointList:c,textAttribute:"",isRect:!0}],i.id)},synchronizeBackView=(e,i,s,d)=>{if(!s)return;const{pointCloud2dOperation:t,pointCloudInstance:n}=s;n.loadPCDFileByBox(d,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:u}=n.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);n.setInitCameraPosition(u);const{polygon2d:c,zoom:r}=n.getBoxBackPolygon2DCoordinate(e);n.camera.zoom=r,n.camera.updateProjectionMatrix(),n.render(),t.initPosition(),t.zoomChangeOnCenter(r),t.setResultAndSelectedID([{id:i.id,pointList:c,textAttribute:"",isRect:!0}],i.id)},synchronizeTopView=(e,i,s,d)=>{if(!s||!d)return;d.generateBox(e,i.id),d.updateCameraByBox(e,lbUtils.EPerspectiveView.Top),d.render();const{pointCloud2dOperation:t,pointCloudInstance:n}=s,{polygon2d:u}=n.getBoxTopPolygon2DCoordinate(e),c=[...t.polygonList],r=c.find(h=>h.id===i.id);r?r.pointList=u:c.push({id:i.id,pointList:u,textAttribute:"",isRect:!0}),t.setResultAndSelectedID(c,i.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:i,sideViewInstance:s,backViewInstance:d,mainViewInstance:t,addPointCloudBox:n,setSelectedIDs:u,selectedIDs:c,pointCloudBoxList:r,setPointCloudResult:h}=e,{updateSelectedBox:L}=useSingleBox.useSingleBox(),{currentData:p,config:g}=reactRedux.useSelector(o=>{const{stepList:l,step:a,imgList:C,imgIndex:x}=o.annotation;return{currentData:C[x],config:index.jsonParser(StepUtils.getCurrentStepInfo(a,l).config)}}),y=reactRedux.useDispatch(),{selectedBox:P}=useSingleBox.useSingleBox(),v=P==null?void 0:P.info;if(!i||!s)return{topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{}};const{pointCloudInstance:f}=i,w=()=>{var o;return r.length>0?((o=r.sort((a,C)=>a.trackID-C.trackID).slice(-1)[0])==null?void 0:o.trackID)+1:1},U=o=>{t==null||t.generateBox(o),t==null||t.controls.update(),t==null||t.render()},V=(o,l)=>{var a,C,x;const m=topViewPolygon2PointCloud(o,l,f,void 0,{attribute:(x=(C=(a=g==null?void 0:g.attributeList)==null?void 0:a[0])==null?void 0:C.value)!=null?x:""}),O=i==null?void 0:i.pointCloud2dOperation,B=Object.assign(m,{trackID:w()});O.setSelectedIDs([o.id]),u(B.id),S(PointCloudView.Top,o,B),n(B)},b=()=>{const o=P==null?void 0:P.info,l=i==null?void 0:i.pointCloud2dOperation;if(l.setSelectedIDs(c),!o||!l)return;const a=l.selectedPolygon;S(PointCloudView.Top,a,o)},D=(o,l,a)=>{if(v){const C=sideViewPolygon2PointCloud(o,l,v,s.pointCloudInstance);L(C),S(a,o,C)}},I=(o,l)=>{D(o,l,PointCloudView.Side)},k=(o,l)=>{D(o,l,PointCloudView.Back)},R=(o,l)=>{if(v){const a=topViewPolygon2PointCloud(o,l,void 0,v);Object.assign(v,___default.default.pickBy(a,(C,x)=>["width","height","x","y"])),L(a),S(PointCloudView.Top,o,v)}},S=(o,l,a)=>{const C=p==null?void 0:p.url,x={[PointCloudView.Side]:()=>{synchronizeSideView(a,l,s,C)},[PointCloudView.Back]:()=>{d&&synchronizeBackView(a,l,d,C)},[PointCloudView.Top]:()=>{synchronizeTopView(a,l,i,t)}};Object.keys(x).forEach(m=>{m!==o&&x[m]()}),U(a),t==null||t.highlightOriginPointCloud(a)};return{topViewAddBox:V,topViewSelectedChanged:b,topViewUpdateBox:R,sideViewUpdateBox:I,backViewUpdateBox:k,pointCloudBoxListUpdated:o=>{i.updatePolygonList(o),t==null||t.generateBoxes(o)},clearAllResult:()=>{r.forEach(o=>{t==null||t.removeObjectByName(o.id)}),t==null||t.render(),h([]),i.pointCloud2dOperation.clearActiveStatus(),i.pointCloud2dOperation.clearResult()},initPointCloud3d:()=>{!t||(t.initPerspectiveCamera(),t.initRenderer(),t.render())},updatePointCloudData:()=>__async(void 0,null,function*(){var o,l,a,C,x,m;if(!(p==null?void 0:p.url)||!t)return;if(actionCreators.SetPointCloudLoading(y,!0),yield t.loadPCDFile(p.url,(o=g==null?void 0:g.radius)!=null?o:DEFAULT_RADIUS),r.forEach(B=>{t==null||t.removeObjectByName(B.id)}),p.result){const B=lbUtils.PointCloudUtils.getBoxParamsFromResultList(p.result),A=lbUtils.PointCloudUtils.getPolygonListFromResultList(p.result);B.forEach(j=>{t==null||t.generateBox(j)}),e.setPointCloudResult(B),e.setPolygonList(A)}else e.setPointCloudResult([]),e.setPolygonList([]);t.updateTopCamera();const O=(a=(l=index.jsonParser(p.result))==null?void 0:l.valid)!=null?a:!0;e.setPointCloudValid(O),(C=e.sideViewInstance)==null||C.clearAllData(),(x=e.backViewInstance)==null||x.clearAllData(),i.updateData(p.url,p.result,{radius:(m=g==null?void 0:g.radius)!=null?m:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(y,!1)})}};exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.transferCanvas2World=transferCanvas2World,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"),_=require("lodash"),reactRedux=require("react-redux"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__async=(e,o,s)=>new Promise((d,t)=>{var i=r=>{try{a(s.next(r))}catch(h){t(h)}},u=r=>{try{a(s.throw(r))}catch(h){t(h)}},a=r=>r.done?d(r.value):Promise.resolve(r.value).then(i,u);a((s=s.apply(e,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},transferCanvas2World=(e,o)=>{const{width:s,height:d}=o,{x:t,y:i}=e;return{x:-i+d/2,y:-(t-s/2)}},topViewPolygon2PointCloud=(e,o,s,d,t)=>{const[i,u,a,r]=e.pointList.map(f=>transferCanvas2World(f,o)),h=lbAnnotation.MathUtils.getLineCenterPoint([i,a]),L=lbAnnotation.MathUtils.getLineLength(i,u),p=lbAnnotation.MathUtils.getLineLength(u,a),g=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);let y=0,P=1;if(s){const f=s.getSensesPointZAxisInPolygon([i,u,a,r]);y=(f.maxZ+f.minZ)/2,P=f.maxZ-f.minZ}d&&(y=d.center.z,P=d.depth);const v={center:{x:h.x,y:h.y,z:y},width:p,height:L,depth:P,rotation:g,id:e.id,attribute:"",valid:!0};return t&&Object.assign(v,t),v},sideViewPolygon2PointCloud=(e,o,s,d)=>{const[t,i,u]=e.pointList,[a,r,h]=o.pointList,L=lbAnnotation.MathUtils.getLineCenterPoint([t,u]),p=lbAnnotation.MathUtils.getLineCenterPoint([a,h]),g={x:L.x-p.x,y:L.y-p.y},y=Math.cos(s.rotation),P=Math.sin(s.rotation),v={x:g.x,y:g.x*P+g.y*y,z:L.y-p.y},f=lbAnnotation.MathUtils.getLineLength(t,i),U=lbAnnotation.MathUtils.getLineLength(a,r),V=f-U,D=lbAnnotation.MathUtils.getLineLength(i,u),S=lbAnnotation.MathUtils.getLineLength(r,h),b=D-S,{newBoxParams:O}=d.getNewBoxBySideUpdate(v,b,V,s);return O},synchronizeSideView=(e,o,s,d)=>{if(!s)return;const{pointCloud2dOperation:t,pointCloudInstance:i}=s;i.loadPCDFileByBox(d,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:u}=i.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);i.setInitCameraPosition(u);const{polygon2d:a,zoom:r}=i.getBoxSidePolygon2DCoordinate(e);i.camera.zoom=r,i.camera.updateProjectionMatrix(),i.render(),t.initPosition(),t.zoomChangeOnCenter(r),t.setResultAndSelectedID([{id:o.id,pointList:a,textAttribute:"",isRect:!0}],o.id)},synchronizeBackView=(e,o,s,d)=>{if(!s)return;const{pointCloud2dOperation:t,pointCloudInstance:i}=s;i.loadPCDFileByBox(d,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:u}=i.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);i.setInitCameraPosition(u);const{polygon2d:a,zoom:r}=i.getBoxBackPolygon2DCoordinate(e);i.camera.zoom=r,i.camera.updateProjectionMatrix(),i.render(),t.initPosition(),t.zoomChangeOnCenter(r),t.setResultAndSelectedID([{id:o.id,pointList:a,textAttribute:"",isRect:!0}],o.id)},synchronizeTopView=(e,o,s,d)=>{if(!s||!d)return;d.generateBox(e,o.id),d.updateCameraByBox(e,lbUtils.EPerspectiveView.Top),d.render();const{pointCloud2dOperation:t,pointCloudInstance:i}=s,{polygon2d:u}=i.getBoxTopPolygon2DCoordinate(e),a=[...t.polygonList],r=a.find(h=>h.id===o.id);r?r.pointList=u:a.push({id:o.id,pointList:u,textAttribute:"",isRect:!0}),t.setResultAndSelectedID(a,o.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:s,backViewInstance:d,mainViewInstance:t,addPointCloudBox:i,setSelectedIDs:u,selectedIDs:a,pointCloudBoxList:r,setPointCloudResult:h}=e,{updateSelectedBox:L}=useSingleBox.useSingleBox(),{currentData:p,config:g}=reactRedux.useSelector(n=>{const{stepList:l,step:c,imgList:C,imgIndex:x}=n.annotation;return{currentData:C[x],config:index.jsonParser(StepUtils.getCurrentStepInfo(c,l).config)}}),y=reactRedux.useDispatch(),{selectedBox:P}=useSingleBox.useSingleBox(),v=P==null?void 0:P.info;if(!o||!s)return{topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{}};const{pointCloudInstance:f}=o,U=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},V=(n,l)=>{var c,C,x;const m=topViewPolygon2PointCloud(n,l,f,void 0,{attribute:(x=(C=(c=g==null?void 0:g.attributeList)==null?void 0:c[0])==null?void 0:C.value)!=null?x:""}),I=o==null?void 0:o.pointCloud2dOperation,B=m;I.setSelectedIDs([n.id]),u(B.id),w(PointCloudView.Top,n,B),i(B)},D=()=>{const n=P==null?void 0:P.info,l=o==null?void 0:o.pointCloud2dOperation;if(l.setSelectedIDs(a),!n||!l)return;const c=l.selectedPolygon;w(PointCloudView.Top,c,n)},S=(n,l,c)=>{if(v){const C=sideViewPolygon2PointCloud(n,l,v,s.pointCloudInstance);L(C),w(c,n,C)}},b=(n,l)=>{S(n,l,PointCloudView.Side)},O=(n,l)=>{S(n,l,PointCloudView.Back)},R=(n,l)=>{if(v){const c=topViewPolygon2PointCloud(n,l,void 0,v);Object.assign(v,___default.default.pickBy(c,(C,x)=>["width","height","x","y"])),L(c),w(PointCloudView.Top,n,v)}},w=(n,l,c)=>{const C=p==null?void 0:p.url,x={[PointCloudView.Side]:()=>{synchronizeSideView(c,l,s,C)},[PointCloudView.Back]:()=>{d&&synchronizeBackView(c,l,d,C)},[PointCloudView.Top]:()=>{synchronizeTopView(c,l,o,t)}};Object.keys(x).forEach(m=>{m!==n&&x[m]()}),U(c),t==null||t.highlightOriginPointCloud(c)};return{topViewAddBox:V,topViewSelectedChanged:D,topViewUpdateBox:R,sideViewUpdateBox:b,backViewUpdateBox:O,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),t==null||t.generateBoxes(n)},clearAllResult:()=>{r.forEach(n=>{t==null||t.removeObjectByName(n.id)}),t==null||t.render(),h([]),o.pointCloud2dOperation.clearActiveStatus(),o.pointCloud2dOperation.clearResult()},initPointCloud3d:()=>{!t||(t.initPerspectiveCamera(),t.initRenderer(),t.render())},updatePointCloudData:()=>__async(void 0,null,function*(){var n,l,c,C,x,m;if(!(p==null?void 0:p.url)||!t)return;if(actionCreators.SetPointCloudLoading(y,!0),yield t.loadPCDFile(p.url,(n=g==null?void 0:g.radius)!=null?n:DEFAULT_RADIUS),r.forEach(B=>{t==null||t.removeObjectByName(B.id)}),p.result){const B=lbUtils.PointCloudUtils.getBoxParamsFromResultList(p.result),A=lbUtils.PointCloudUtils.getPolygonListFromResultList(p.result);B.forEach(j=>{t==null||t.generateBox(j)}),e.setPointCloudResult(B),e.setPolygonList(A)}else e.setPointCloudResult([]),e.setPolygonList([]);t.updateTopCamera();const I=(c=(l=index.jsonParser(p.result))==null?void 0:l.valid)!=null?c:!0;e.setPointCloudValid(I),(C=e.sideViewInstance)==null||C.clearAllData(),(x=e.backViewInstance)==null||x.clearAllData(),o.updateData(p.url,p.result,{radius:(m=g==null?void 0:g.radius)!=null?m:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(y,!1)})}};exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.transferCanvas2World=transferCanvas2World,exports.usePointCloudViews=usePointCloudViews;
@@ -1 +1 @@
1
- "use strict";var icon_clear=require("../../../../assets/annotation/common/icon_clear.svg.js"),icon_clear_a=require("../../../../assets/annotation/common/icon_clear_a.svg.js"),icon_invalid=require("../../../../assets/annotation/common/icon_invalid.svg.js"),icon_invalid_a=require("../../../../assets/annotation/common/icon_invalid_a.svg.js"),icons=require("@ant-design/icons"),reactI18next=require("react-i18next"),React=require("react"),actionCreators=require("../../../../store/annotation/actionCreators.js"),index=require("../../../../index.js"),reactRedux=require("react-redux");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e};const useOperationList=e=>{const[r,t]=React.useState(0),{t:a}=reactI18next.useTranslation(),{currentData:o}=reactRedux.useSelector(i=>{const{imgList:u,imgIndex:v}=i.annotation;return{currentData:u[v]}}),n={height:"25px",lineHeight:"25px",display:"flex",justifyContent:"center",alignItems:"center"},s={name:a("ClearLabel"),key:"empty",imgSvg:icon_clear,hoverSvg:icon_clear_a,onClick:()=>{e==null||e.clearResult()}},c={name:a((e==null?void 0:e.valid)===!1?"SetAsValid":"SetAsInvalid"),key:"setValidity",imgSvg:React__default.default.createElement(icons.StopOutlined,{style:n}),hoverSvg:React__default.default.createElement(icons.StopOutlined,{style:__spreadValues({color:"#666fff"},n)}),onClick:()=>{e.setValid(!e.valid),setTimeout(()=>{t(i=>i+1)})}},l={name:a("CopyThePrevious"),key:"copyPrevious",imgSvg:icon_invalid,hoverSvg:icon_invalid_a,onClick:()=>{index.store.dispatch(actionCreators.CopyBackWordResult())}};return React.useMemo(()=>({empty:s,setValidity:c,copyPrevious:l}),[e,r,o])};module.exports=useOperationList;
1
+ "use strict";var icon_clear=require("../../../../assets/annotation/common/icon_clear.svg.js"),icon_clear_a=require("../../../../assets/annotation/common/icon_clear_a.svg.js"),icon_invalid=require("../../../../assets/annotation/common/icon_invalid.svg.js"),icon_invalid_a=require("../../../../assets/annotation/common/icon_invalid_a.svg.js"),icons=require("@ant-design/icons"),reactI18next=require("react-i18next"),React=require("react"),actionCreators=require("../../../../store/annotation/actionCreators.js"),index=require("../../../../index.js"),reactRedux=require("react-redux");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e};const useOperationList=e=>{const[r,t]=React.useState(0),{t:a,i18n:o}=reactI18next.useTranslation(),{currentData:s}=reactRedux.useSelector(i=>{const{imgList:v,imgIndex:d}=i.annotation;return{currentData:v[d]}}),n={height:"25px",lineHeight:"25px",display:"flex",justifyContent:"center",alignItems:"center"},c={name:a("ClearLabel"),key:"empty",imgSvg:icon_clear,hoverSvg:icon_clear_a,onClick:()=>{e==null||e.clearResult()}},l={name:a((e==null?void 0:e.valid)===!1?"SetAsValid":"SetAsInvalid"),key:"setValidity",imgSvg:React__default.default.createElement(icons.StopOutlined,{style:n}),hoverSvg:React__default.default.createElement(icons.StopOutlined,{style:__spreadValues({color:"#666fff"},n)}),onClick:()=>{e.setValid(!e.valid),setTimeout(()=>{t(i=>i+1)})}},u={name:a("CopyThePrevious"),key:"copyPrevious",imgSvg:icon_invalid,hoverSvg:icon_invalid_a,onClick:()=>{index.store.dispatch(actionCreators.CopyBackWordResult())}};return React.useMemo(()=>({empty:c,setValidity:l,copyPrevious:u}),[e,r,s,o.language])};module.exports=useOperationList;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),ToolIcons=require("../ToolIcons.js"),lbAnnotation=require("@labelbee/lb-annotation"),PointCloudContext=require("../../../../components/pointCloudView/PointCloudContext.js"),antd=require("antd"),StepUtils=require("../../../../utils/StepUtils.js"),reactRedux=require("react-redux"),index=require("../../../../utils/index.js"),useStatus=require("../../../../components/pointCloudView/hooks/useStatus.js"),useSingleBox=require("../../../../components/pointCloudView/hooks/useSingleBox.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React);const AttributeUpdater=({attributeList:t,subAttributeList:u,toolInstance:o})=>{var l;const r=React.useContext(PointCloudContext.PointCloudContext),a={fontWeight:400,fontSize:14,marginBottom:14},c=e=>{o.setDefaultAttribute(e)},n=(e,i)=>{o.setSubAttribute(e,i)};return React__default.default.createElement("div",{style:{padding:24,borderBottom:"1px solid #eee"}},React__default.default.createElement("div",{style:{marginBottom:20,fontSize:14,fontWeight:500}},"\u6807\u7B7E"),React__default.default.createElement(antd.Row,{style:{marginBottom:12}},React__default.default.createElement(antd.Col,{span:10,style:a},"\u4E3B\u5C5E\u6027"),React__default.default.createElement(antd.Col,{span:14},React__default.default.createElement(antd.Radio.Group,{style:{width:"100%"},value:(l=r.selectedPointCloudBox)==null?void 0:l.attribute,onChange:e=>c(e.target.value)},t.map(e=>React__default.default.createElement(antd.Radio,{key:e.value,value:e.value,style:{marginBottom:16}},e.key))))),React__default.default.createElement("div",{style:a},"\u526F\u5C5E\u6027"),u.map(e=>{var i,d;return React__default.default.createElement(antd.Row,{key:e.value,style:{marginBottom:18}},React__default.default.createElement(antd.Col,{span:10,style:{color:"#999999"}},e.key),React__default.default.createElement(antd.Col,{span:14},React__default.default.createElement(antd.Select,{style:{width:"100%"},bordered:!1,value:(d=(i=r.selectedPointCloudBox)==null?void 0:i.subAttribute)==null?void 0:d[e.value],placeholder:"\u8BF7\u586B\u5199~",onChange:s=>n(e.value,s)},e.subSelected.map(s=>React__default.default.createElement(antd.Select.Option,{key:s.value,value:s.value},s.key)))))}))},PointCloudToolSidebar=({stepInfo:t,toolInstance:u})=>{var o,l;const{selectedBox:r}=useSingleBox.useSingleBox(),{updatePointCloudPattern:a,pointCloudPattern:c}=useStatus.useStatus(),n=index.jsonParser(t.config),e=(o=n==null?void 0:n.attributeList)!=null?o:[],i=(n==null?void 0:n.secondaryAttributeConfigurable)===!0?(l=n==null?void 0:n.inputList)!=null?l:[]:[];return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(ToolIcons.ToolIcons,{toolName:lbAnnotation.cTool.EPointCloudName.PointCloud,selectedToolName:c,onChange:d=>a==null?void 0:a(d)}),r&&React__default.default.createElement(AttributeUpdater,{toolInstance:u,attributeList:e,subAttributeList:i}))},mapStateToProps=t=>{var u,o,l;const r=StepUtils.getCurrentStepInfo((u=t.annotation)==null?void 0:u.step,(o=t.annotation)==null?void 0:o.stepList),a=(l=t.annotation)==null?void 0:l.toolInstance;return{stepInfo:r,toolInstance:a}};var PointCloudToolSidebar$1=reactRedux.connect(mapStateToProps)(PointCloudToolSidebar);module.exports=PointCloudToolSidebar$1;
1
+ "use strict";var React=require("react"),ToolIcons=require("../ToolIcons.js"),lbAnnotation=require("@labelbee/lb-annotation"),PointCloudContext=require("../../../../components/pointCloudView/PointCloudContext.js"),antd=require("antd"),StepUtils=require("../../../../utils/StepUtils.js"),reactRedux=require("react-redux"),index=require("../../../../utils/index.js"),useStatus=require("../../../../components/pointCloudView/hooks/useStatus.js"),useSingleBox=require("../../../../components/pointCloudView/hooks/useSingleBox.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React);const AttributeUpdater=({attributeList:t,subAttributeList:r,toolInstance:l})=>{var n;const u=React.useContext(PointCloudContext.PointCloudContext),{t:o}=reactI18next.useTranslation(),d={fontWeight:400,fontSize:14,marginBottom:14},a=e=>{l.setDefaultAttribute(e)},c=(e,i)=>{l.setSubAttribute(e,i)};return React__default.default.createElement("div",{style:{padding:24,borderBottom:"1px solid #eee"}},React__default.default.createElement("div",{style:{marginBottom:20,fontSize:14,fontWeight:500}},o("Tag")),React__default.default.createElement(antd.Row,{style:{marginBottom:12}},React__default.default.createElement(antd.Col,{span:9,style:d},o("Attribute")),React__default.default.createElement(antd.Col,{span:15},React__default.default.createElement(antd.Radio.Group,{style:{width:"100%"},value:(n=u.selectedPointCloudBox)==null?void 0:n.attribute,onChange:e=>a(e.target.value)},t.map(e=>React__default.default.createElement(antd.Radio,{key:e.value,value:e.value,style:{marginBottom:16}},e.key))))),React__default.default.createElement("div",{style:d}," ",o("SubAttribute")),r.map(e=>{var i,v;return(e==null?void 0:e.subSelected)&&React__default.default.createElement(antd.Row,{key:e.value,style:{marginBottom:18}},React__default.default.createElement(antd.Col,{span:9,style:{color:"#999999",display:"flex",justifyContent:"flex-start",alignItems:"center"}},e.key),React__default.default.createElement(antd.Col,{span:15},React__default.default.createElement(antd.Select,{style:{width:"100%"},bordered:!1,value:(v=(i=u.selectedPointCloudBox)==null?void 0:i.subAttribute)==null?void 0:v[e.value],placeholder:o("PleaseSelect"),onChange:s=>c(e.value,s)},e.subSelected.map(s=>React__default.default.createElement(antd.Select.Option,{key:s.value,value:s.value},s.key)))))}))},PointCloudToolSidebar=({stepInfo:t,toolInstance:r})=>{var l,n;const{selectedBox:u}=useSingleBox.useSingleBox(),{updatePointCloudPattern:o,pointCloudPattern:d}=useStatus.useStatus(),a=index.jsonParser(t.config),c=(l=a==null?void 0:a.attributeList)!=null?l:[],e=(a==null?void 0:a.secondaryAttributeConfigurable)===!0?(n=a==null?void 0:a.inputList)!=null?n:[]:[];return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(ToolIcons.ToolIcons,{toolName:lbAnnotation.cTool.EPointCloudName.PointCloud,selectedToolName:d,onChange:i=>o==null?void 0:o(i)}),u&&React__default.default.createElement(AttributeUpdater,{toolInstance:r,attributeList:c,subAttributeList:e}))},mapStateToProps=t=>{var r,l,n;const u=StepUtils.getCurrentStepInfo((r=t.annotation)==null?void 0:r.step,(l=t.annotation)==null?void 0:l.stepList),o=(n=t.annotation)==null?void 0:n.toolInstance;return{stepInfo:u,toolInstance:o}};var PointCloudToolSidebar$1=reactRedux.connect(mapStateToProps)(PointCloudToolSidebar);module.exports=PointCloudToolSidebar$1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ToolType=require("../../../data/enums/ToolType.js"),React=require("react"),index=require("./index.js"),icon_line=require("../../../assets/annotation/lineTool/icon_line.svg.js"),icon_line_a=require("../../../assets/annotation/lineTool/icon_line_a.svg.js"),icon_point=require("../../../assets/annotation/pointTool/icon_point.svg.js"),icon_point_a=require("../../../assets/annotation/pointTool/icon_point_a.svg.js"),icon_polygon_a=require("../../../assets/annotation/polygonTool/icon_polygon_a.svg.js"),icon_polygon=require("../../../assets/annotation/polygonTool/icon_polygon.svg.js"),icon_rect=require("../../../assets/annotation/rectTool/icon_rect.svg.js"),icon_rect_a=require("../../../assets/annotation/rectTool/icon_rect_a.svg.js"),lbAnnotation=require("@labelbee/lb-annotation"),classNames=require("classnames");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const{EPointCloudName,TOOL_NAME}=lbAnnotation.cTool,toolList=[{toolName:ToolType.EToolName.Rect,commonSvg:icon_rect,selectedSvg:icon_rect_a},{toolName:ToolType.EToolName.Polygon,commonSvg:icon_polygon,selectedSvg:icon_polygon_a},{toolName:ToolType.EToolName.Line,commonSvg:icon_line,selectedSvg:icon_line_a},{toolName:ToolType.EToolName.Point,commonSvg:icon_point,selectedSvg:icon_point_a}],ToolIcons=({toolName:o,selectedToolName:l,onChange:n})=>{const a=toolList==null?void 0:toolList.filter(e=>o===EPointCloudName.PointCloud?[ToolType.EToolName.Polygon,ToolType.EToolName.Rect].includes(e==null?void 0:e.toolName):(e==null?void 0:e.toolName)===o),s=a.length>1;return React__default.default.createElement("div",{className:`${index.sidebarCls}__level`},a.map(e=>{const t=s&&l===e.toolName;return React__default.default.createElement("span",{className:`${index.sidebarCls}__toolOption`,key:e.toolName,onClick:()=>n==null?void 0:n(e.toolName)},React__default.default.createElement("img",{className:`${index.sidebarCls}__singleTool`,src:t?e==null?void 0:e.selectedSvg:e==null?void 0:e.commonSvg}),React__default.default.createElement("span",{className:classNames__default.default({[`${index.sidebarCls}__toolOption__selected`]:t})},TOOL_NAME[e.toolName]))}))};exports.ToolIcons=ToolIcons;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ToolType=require("../../../data/enums/ToolType.js"),React=require("react"),index=require("./index.js"),icon_line=require("../../../assets/annotation/lineTool/icon_line.svg.js"),icon_line_a=require("../../../assets/annotation/lineTool/icon_line_a.svg.js"),icon_point=require("../../../assets/annotation/pointTool/icon_point.svg.js"),icon_point_a=require("../../../assets/annotation/pointTool/icon_point_a.svg.js"),icon_polygon_a=require("../../../assets/annotation/polygonTool/icon_polygon_a.svg.js"),icon_polygon=require("../../../assets/annotation/polygonTool/icon_polygon.svg.js"),icon_rect=require("../../../assets/annotation/rectTool/icon_rect.svg.js"),icon_rect_a=require("../../../assets/annotation/rectTool/icon_rect_a.svg.js"),lbAnnotation=require("@labelbee/lb-annotation"),classNames=require("classnames"),reactI18next=require("react-i18next");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const{EPointCloudName,TOOL_NAME,TOOL_NAME_EN}=lbAnnotation.cTool,toolList=[{toolName:ToolType.EToolName.Rect,commonSvg:icon_rect,selectedSvg:icon_rect_a},{toolName:ToolType.EToolName.Polygon,commonSvg:icon_polygon,selectedSvg:icon_polygon_a},{toolName:ToolType.EToolName.Line,commonSvg:icon_line,selectedSvg:icon_line_a},{toolName:ToolType.EToolName.Point,commonSvg:icon_point,selectedSvg:icon_point_a}],getToolNameVersion=o=>o==="en"?TOOL_NAME_EN:TOOL_NAME,ToolIcons=({toolName:o,selectedToolName:l,onChange:n})=>{const{i18n:s}=reactI18next.useTranslation(),a=toolList==null?void 0:toolList.filter(e=>o===EPointCloudName.PointCloud?[ToolType.EToolName.Polygon,ToolType.EToolName.Rect].includes(e==null?void 0:e.toolName):(e==null?void 0:e.toolName)===o),r=a.length>1;return React__default.default.createElement("div",{className:`${index.sidebarCls}__level`},a.map(e=>{const t=r&&l===e.toolName;return React__default.default.createElement("span",{className:`${index.sidebarCls}__toolOption`,key:e.toolName,onClick:()=>n==null?void 0:n(e.toolName)},React__default.default.createElement("img",{className:`${index.sidebarCls}__singleTool`,src:t?e==null?void 0:e.selectedSvg:e==null?void 0:e.commonSvg}),React__default.default.createElement("span",{className:classNames__default.default({[`${index.sidebarCls}__toolOption__selected`]:t})},getToolNameVersion(s.language)[e.toolName]))}))};exports.ToolIcons=ToolIcons;
@@ -1 +1 @@
1
- import{PointCloud as f}from"@labelbee/lb-annotation";import{PointCloudUtils as b}from"@labelbee/lb-utils";import m,{useRef as s,useCallback as C,useEffect as r}from"react";const v=u=>{const{src:o,result:n,size:a}=u;let l=s();const e=s(),d=C(t=>{l.current=t},[]);return r(()=>{const t=new f({container:l.current,backgroundColor:"#ccc"});e.current=t},[]),r(()=>{var t;(t=e.current)==null||t.init()},[a]),r(()=>{var t;e.current&&o&&((t=e.current)==null||t.loadPCDFile(o))},[o]),r(()=>{n&&b.getBoxParamsFromResultList(n).forEach(i=>{var c;(c=e.current)==null||c.generateBox(i,i.id)})},[n]),m.createElement("div",{style:a,ref:d})};export{v as default};
1
+ import{PointCloud as f}from"@labelbee/lb-annotation";import{PointCloudUtils as u}from"@labelbee/lb-utils";import v,{useRef as m,useCallback as P,useEffect as a}from"react";const x=d=>{const{src:n,result:e,size:l}=d;let c=m();const t=m(),b=P(r=>{c.current=r},[]);return a(()=>{const r=new f({container:c.current,backgroundColor:"#ccc"});t.current=r},[]),a(()=>{var r;(r=t.current)==null||r.init()},[l]),a(()=>{var r;t.current&&n&&((r=t.current)==null||r.loadPCDFile(n))},[n]),a(()=>(e&&u.getBoxParamsFromResultList(e).forEach(i=>{var o;(o=t.current)==null||o.generateBox(i,i.id)}),()=>{var r;u.getBoxParamsFromResultList(e).forEach(o=>{var s;(s=t.current)==null||s.removeObjectByName(o.id)}),(r=t.current)==null||r.render()}),[e]),v.createElement("div",{style:l,ref:b})};export{x as default};
@@ -1 +1 @@
1
- {"version":3,"file":"pointCloudAnnotationView.js","sources":["../../../src/components/AnnotationView/pointCloudAnnotationView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-13 19:31:36\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-06-27 19:43:25\n */\n\nimport { PointCloud } from '@labelbee/lb-annotation';\nimport { IPointCloudBox, PointCloudUtils } from '@labelbee/lb-utils';\nimport React, { useCallback, useEffect, useRef } from 'react';\n\ninterface IProps {\n src: string; // 图片路径\n result: string;\n size: {\n width: number;\n height: number;\n };\n}\n\nconst PointCloudAnnotationView = (props: IProps) => {\n const { src, result, size } = props;\n let viewOperation = useRef<any>();\n const instance = useRef<any>();\n\n const refCallback = useCallback((node) => {\n viewOperation.current = node;\n }, []);\n\n useEffect(() => {\n const pointCloud = new PointCloud({\n container: viewOperation.current,\n backgroundColor: '#ccc',\n });\n instance.current = pointCloud;\n }, []);\n\n useEffect(() => {\n instance.current?.init();\n }, [size]);\n\n useEffect(() => {\n if (instance.current && src) {\n instance.current?.loadPCDFile(src);\n }\n }, [src]);\n\n useEffect(() => {\n if (result) {\n const boxParamsList = PointCloudUtils.getBoxParamsFromResultList(result);\n\n // Add Init Box\n boxParamsList.forEach((v: IPointCloudBox) => {\n instance.current?.generateBox(v, v.id);\n });\n }\n }, [result]);\n\n return <div style={size} ref={refCallback} />;\n};\n\nexport default PointCloudAnnotationView;\n"],"names":[],"mappings":";;;;AAoBM,MAAA,wBAAA,GAA2B,CAAC,KAAkB,KAAA;AAClD,EAAM,MAAA,CAAE,GAAK,EAAA,MAAA,EAAQ,IAAS,CAAA,GAAA,KAAA,CAAA;AAC9B,EAAA,IAAI,aAAgB,GAAA,MAAA,EAAA,CAAA;AACpB,EAAA,MAAM,QAAW,GAAA,MAAA,EAAA,CAAA;AAEjB,EAAM,MAAA,WAAA,GAAc,WAAY,CAAA,CAAC,IAAS,KAAA;AACxC,IAAA,aAAA,CAAc,OAAU,GAAA,IAAA,CAAA;AAAA,GACvB,EAAA,EAAA,CAAA,CAAA;AAEH,EAAA,SAAA,CAAU,MAAM;AACd,IAAM,MAAA,UAAA,GAAa,IAAI,UAAW,CAAA;AAAA,MAChC,WAAW,aAAc,CAAA,OAAA;AAAA,MACzB,e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otationView.js","sources":["../../../src/components/AnnotationView/pointCloudAnnotationView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-13 19:31:36\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-06-27 19:43:25\n */\n\nimport { PointCloud } from '@labelbee/lb-annotation';\nimport { IPointCloudBox, PointCloudUtils } from '@labelbee/lb-utils';\nimport React, { useCallback, useEffect, useRef } from 'react';\n\ninterface IProps {\n src: string; // 图片路径\n result: string;\n size: {\n width: number;\n height: number;\n };\n}\n\nconst PointCloudAnnotationView = (props: IProps) => {\n const { src, result, size } = props;\n let viewOperation = useRef<any>();\n const instance = useRef<any>();\n\n const refCallback = useCallback((node) => {\n viewOperation.current = node;\n }, []);\n\n useEffect(() => {\n const pointCloud = new PointCloud({\n container: viewOperation.current,\n backgroundColor: '#ccc',\n });\n instance.current = pointCloud;\n }, []);\n\n useEffect(() => {\n instance.current?.init();\n }, [size]);\n\n useEffect(() => {\n if (instance.current && src) {\n instance.current?.loadPCDFile(src);\n }\n }, [src]);\n\n useEffect(() => {\n if (result) {\n const boxParamsList = PointCloudUtils.getBoxParamsFromResultList(result);\n\n // Add Init Box\n boxParamsList.forEach((v: IPointCloudBox) => {\n instance.current?.generateBox(v, v.id);\n });\n }\n return () => {\n const boxParamsList = PointCloudUtils.getBoxParamsFromResultList(result);\n boxParamsList.forEach((v: IPointCloudBox) => {\n instance.current?.removeObjectByName(v.id);\n });\n instance.current?.render();\n };\n }, [result]);\n\n return <div style={size} ref={refCallback} />;\n};\n\nexport default PointCloudAnnotationView;\n"],"names":[],"mappings":";;;;AAoBM,MAAA,wBAAA,GAA2B,CAAC,KAAkB,KAAA;AAClD,EAAM,MAAA,CAAE,GAAK,EAAA,MAAA,EAAQ,IAAS,CAAA,GAAA,KAAA,CAAA;AAC9B,EAAA,IAAI,aAAgB,GAAA,MAAA,EAAA,CAAA;AACpB,EAAA,MAAM,QAAW,GAAA,MAAA,EA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A,EAAG,CAAE,CAAA,EAAA,CAAA,CAAA;AAAA,OAAA,CAAA,CAAA;AAAA,KAAA;AAGvC,IAAA,OAAO,MAAM;AAxDjB,MAAA,IAAA,EAAA,CAAA;AAyDM,MAAM,MAAA,aAAA,GAAgB,gBAAgB,0BAA2B,CAAA,MAAA,CAAA,CAAA;AACjE,MAAc,aAAA,CAAA,OAAA,CAAQ,CAAC,CAAsB,KAAA;AA1DnD,QAAA,IAAA,GAAA,CAAA;AA2DQ,QAAS,CAAA,GAAA,GAAA,QAAA,CAAA,OAAA,KAAT,IAAkB,GAAA,KAAA,CAAA,GAAA,GAAA,CAAA,kBAAA,CAAmB,CAAE,CAAA,EAAA,CAAA,CAAA;AAAA,OAAA,CAAA,CAAA;AAEzC,MAAA,CAAA,EAAA,GAAA,QAAA,CAAS,YAAT,IAAkB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAA,EAAA,CAAA;AAAA,KAAA,CAAA;AAAA,GAAA,EAEnB,CAAC,MAAA,CAAA,CAAA,CAAA;AAEJ,EAAA,2CAAQ,KAAD,EAAA;AAAA,IAAK,KAAO,EAAA,IAAA;AAAA,IAAM,GAAK,EAAA,WAAA;AAAA,GAAA,CAAA,CAAA;AAAA;;;;"}
@@ -1 +1 @@
1
- import{getClassName as E}from"../../utils/dom.js";import i,{useState as h,useContext as N,useRef as O,useEffect as _}from"react";import{PointCloudContainer as A}from"./PointCloudLayout.js";import B from"../AnnotationView/index.js";import{PointCloudContext as I}from"./PointCloudContext.js";import{connect as R}from"react-redux";import{LeftOutlined as k,RightOutlined as z}from"@ant-design/icons";import T from"../../hooks/useSize.js";import{useSingleBox as F}from"./hooks/useSingleBox.js";var M=Object.defineProperty,S=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,b=(t,n,e)=>n in t?M(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,G=(t,n)=>{for(var e in n||(n={}))$.call(n,e)&&b(t,e,n[e]);if(S)for(var e of S(n))q.call(n,e)&&b(t,e,n[e]);return t};const H=({onNext:t,onPrev:n,imgLength:e,imgIndex:s})=>i.createElement("div",null,i.createElement(k,{onClick:n}),i.createElement("span",null," ",s+1," / ",e," "),i.createElement(z,{onClick:t})),J=({imgInfo:t})=>{var n,e,s,L,P;const[p,j]=h([]),{pointCloudBoxList:C,topViewInstance:x}=N(I),[u,m]=h(0),y=O(null),v=O(),{selectedBox:f}=F(),V=T(y),a=(n=t==null?void 0:t.mappingImgList)==null?void 0:n[u];_(()=>{m(0)},[t]),_(()=>{if(x&&a){const{pointCloudInstance:o}=x,r={fill:"transparent",color:"green"},c=C.reduce((l,d)=>{const D=o.pointCloudLidar2image(d,a.calib);return[...l,...D.map(w=>({type:w.type,annotation:G({id:d.id,pointList:w.pointList},r)}))]},[]);j(c)}},[C,a]);const g=!t||!(t==null?void 0:t.mappingImgList)||!(((e=t==null?void 0:t.mappingImgList)==null?void 0:e.length)>0);return _(()=>{var o,r;const c=(o=v.current)==null?void 0:o.toolInstance;if(!f||!c)return;const l=p.find(d=>d.annotation.id===f.info.id);((r=l==null?void 0:l.annotation.pointList)==null?void 0:r.length)>0&&c.focusPositionByPointList(l==null?void 0:l.annotation.pointList)},[f,v.current,p]),i.createElement(A,{className:E("point-cloud-2d-container"),title:"2D\u89C6\u56FE",toolbar:g?void 0:i.createElement(H,{imgIndex:u,imgLength:(L=(s=t.mappingImgList)==null?void 0:s.length)!=null?L:0,onNext:()=>{var o;!t||!(t==null?void 0:t.mappingImgList)||u>=((o=t==null?void 0:t.mappingImgList)==null?void 0:o.length)-1||m(r=>r+1)},onPrev:()=>{u<=0||m(o=>o-1)}}),style:{display:g?"none":"flex"}},i.createElement("div",{className:E("point-cloud-2d-image"),ref:y},i.createElement(B,{src:(P=a==null?void 0:a.url)!=null?P:"",annotations:p,size:V,ref:v,globalStyle:{display:g?"none":"block"}})))},K=t=>{const{imgList:n,imgIndex:e}=t.annotation;return{imgInfo:n[e]}};var Q=R(K)(J);export{Q as default};
1
+ import{getClassName as h}from"../../utils/dom.js";import i,{useState as E,useContext as A,useRef as O,useEffect as _}from"react";import{PointCloudContainer as B}from"./PointCloudLayout.js";import I from"../AnnotationView/index.js";import{PointCloudContext as R}from"./PointCloudContext.js";import{connect as k}from"react-redux";import{LeftOutlined as z,RightOutlined as T}from"@ant-design/icons";import M from"../../hooks/useSize.js";import{useSingleBox as $}from"./hooks/useSingleBox.js";import{useTranslation as q}from"react-i18next";var F=Object.defineProperty,S=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable,b=(t,n,e)=>n in t?F(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,J=(t,n)=>{for(var e in n||(n={}))G.call(n,e)&&b(t,e,n[e]);if(S)for(var e of S(n))H.call(n,e)&&b(t,e,n[e]);return t};const K=({onNext:t,onPrev:n,imgLength:e,imgIndex:s})=>i.createElement("div",null,i.createElement(z,{onClick:n}),i.createElement("span",null," ",s+1," / ",e," "),i.createElement(T,{onClick:t})),Q=({imgInfo:t})=>{var n,e,s,L,P;const[p,j]=E([]),{pointCloudBoxList:x,topViewInstance:w}=A(R),[u,m]=E(0),y=O(null),v=O(),{selectedBox:f}=$(),V=M(y),{t:D}=q(),l=(n=t==null?void 0:t.mappingImgList)==null?void 0:n[u];_(()=>{m(0)},[t]),_(()=>{if(w&&l){const{pointCloudInstance:o}=w,r={fill:"transparent",color:"green"},c=x.reduce((a,d)=>{const N=o.pointCloudLidar2image(d,l.calib);return[...a,...N.map(C=>({type:C.type,annotation:J({id:d.id,pointList:C.pointList},r)}))]},[]);j(c)}},[x,l]);const g=!t||!(t==null?void 0:t.mappingImgList)||!(((e=t==null?void 0:t.mappingImgList)==null?void 0:e.length)>0);return _(()=>{var o,r;const c=(o=v.current)==null?void 0:o.toolInstance;if(!f||!c)return;const a=p.find(d=>d.annotation.id===f.info.id);((r=a==null?void 0:a.annotation.pointList)==null?void 0:r.length)>0&&c.focusPositionByPointList(a==null?void 0:a.annotation.pointList)},[f,v.current,p]),i.createElement(B,{className:h("point-cloud-2d-container"),title:D("2DView"),toolbar:g?void 0:i.createElement(K,{imgIndex:u,imgLength:(L=(s=t.mappingImgList)==null?void 0:s.length)!=null?L:0,onNext:()=>{var o;!t||!(t==null?void 0:t.mappingImgList)||u>=((o=t==null?void 0:t.mappingImgList)==null?void 0:o.length)-1||m(r=>r+1)},onPrev:()=>{u<=0||m(o=>o-1)}}),style:{display:g?"none":"flex"}},i.createElement("div",{className:h("point-cloud-2d-image"),ref:y},i.createElement(I,{src:(P=l==null?void 0:l.url)!=null?P:"",annotations:p,size:V,ref:v,globalStyle:{display:g?"none":"block"}})))},U=t=>{const{imgList:n,imgIndex:e}=t.annotation;return{imgInfo:n[e]}};var W=k(U)(Q);export{W as default};
@@ -1 +1 @@
1
- {"version":3,"file":"PointCloud2DView.js","sources":["../../../src/components/pointCloudView/PointCloud2DView.tsx"],"sourcesContent":["import { getClassName } from '@/utils/dom';\nimport React, { useContext, useEffect, useRef, useState } from 'react';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport AnnotationView from '@/components/AnnotationView';\nimport { PointCloudContext } from './PointCloudContext';\nimport { AppState } from '@/store';\nimport { connect } from 'react-redux';\nimport { IFileItem } from '@/types/data';\nimport { LeftOutlined, RightOutlined } from '@ant-design/icons';\nimport useSize from '@/hooks/useSize';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { ViewOperation } from '@labelbee/lb-annotation';\n\ninterface IProps {\n imgInfo: IFileItem;\n}\n\nconst Toolbar = ({\n onNext,\n onPrev,\n imgLength,\n imgIndex,\n}: {\n onNext: () => void;\n onPrev: () => void;\n imgLength: number;\n imgIndex: number;\n}) => {\n return (\n <div>\n <LeftOutlined onClick={onPrev} />\n <span>\n {' '}\n {imgIndex + 1} / {imgLength}{' '}\n </span>\n\n <RightOutlined onClick={onNext} />\n </div>\n );\n};\n\n// TODO, It will be deleted when the exported type of lb-annotation is work.\ninterface IAnnotationDataTemporarily {\n type: string;\n annotation: any;\n}\n\nconst PointCloud2DView = ({ imgInfo }: IProps) => {\n const [annotations2d, setAnnotations2d] = useState<IAnnotationDataTemporarily[]>([]);\n const { pointCloudBoxList, topViewInstance } = useContext(PointCloudContext);\n const [mappingIndex, setMappingIndex] = useState(0);\n const ref = useRef(null);\n const viewRef = useRef<{ toolInstance: ViewOperation }>();\n const { selectedBox } = useSingleBox();\n const size = useSize(ref);\n\n const mappingData = imgInfo?.mappingImgList?.[mappingIndex];\n\n useEffect(() => {\n setMappingIndex(0);\n }, [imgInfo]);\n\n useEffect(() => {\n if (topViewInstance && mappingData) {\n const { pointCloudInstance } = topViewInstance;\n const defaultViewStyle = {\n fill: 'transparent',\n color: 'green',\n };\n const newAnnotations2d: IAnnotationDataTemporarily[] = pointCloudBoxList.reduce(\n (acc: IAnnotationDataTemporarily[], pointCloudBox) => {\n const viewDataPointList = pointCloudInstance.pointCloudLidar2image(\n pointCloudBox,\n mappingData.calib,\n );\n return [\n ...acc,\n ...viewDataPointList.map((v: any) => {\n return {\n type: v.type,\n annotation: {\n id: pointCloudBox.id,\n pointList: v.pointList,\n ...defaultViewStyle,\n },\n };\n }),\n ];\n },\n [],\n );\n\n setAnnotations2d(newAnnotations2d);\n }\n }, [pointCloudBoxList, mappingData]);\n\n const hiddenData = !imgInfo || !imgInfo?.mappingImgList || !(imgInfo?.mappingImgList?.length > 0);\n\n useEffect(() => {\n const toolInstance = viewRef.current?.toolInstance;\n\n if (!selectedBox || !toolInstance) {\n return;\n }\n const selected2data = annotations2d.find((v) => v.annotation.id === selectedBox.info.id);\n\n if (selected2data?.annotation.pointList?.length > 0) {\n toolInstance.focusPositionByPointList(selected2data?.annotation.pointList);\n }\n }, [selectedBox, viewRef.current, annotations2d]);\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-2d-container')}\n title='2D视图'\n toolbar={\n hiddenData ? undefined : (\n <Toolbar\n imgIndex={mappingIndex}\n imgLength={imgInfo.mappingImgList?.length ?? 0}\n onNext={() => {\n if (!imgInfo || !imgInfo?.mappingImgList) {\n return;\n }\n\n if (mappingIndex >= imgInfo?.mappingImgList?.length - 1) {\n return;\n }\n setMappingIndex((v) => v + 1);\n }}\n onPrev={() => {\n if (mappingIndex <= 0) {\n return;\n }\n setMappingIndex((v) => v - 1);\n }}\n />\n )\n }\n style={{ display: hiddenData ? 'none' : 'flex' }}\n >\n <div className={getClassName('point-cloud-2d-image')} ref={ref}>\n <AnnotationView\n src={mappingData?.url ?? ''}\n annotations={annotations2d}\n size={size}\n ref={viewRef}\n globalStyle={{ display: hiddenData ? 'none' : 'block' }}\n />\n </div>\n </PointCloudContainer>\n );\n};\n\nconst mapStateToProps = (state: AppState) => {\n const { imgList, imgIndex } = state.annotation;\n\n return {\n imgInfo: imgList[imgIndex],\n };\n};\n\nexport default connect(mapStateToProps)(PointCloud2DView);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,UAAU,CAAC;AAAA,EACf,MAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,CAMI,KAAA;AACJ,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAD,IACE,kBAAA,KAAA,CAAA,aAAA,CAAC,YAAD,EAAA;AAAA,IAAc,OAAS,EAAA,MAAA;AAAA,GACvB,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,MAAD,EAAA,IAAA,EACG,GACA,EAAA,QAAA,GAAW,GAAE,KAAI,EAAA,SAAA,EAAW,GAG/B,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAD,EAAA;AAAA,IAAe,OAAS,EAAA,MAAA;AAAA,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAW9B,MAAM,gBAAA,GAAmB,CAAC,CAAE,OAAsB,CAAA,KAAA;AA/ClD,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA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AQ,MAAM;AACZ,QAAA,IAAI,gBAAgB,CAAG,EAAA;AACrB,UAAA,OAAA;AAAA,SAAA;AAEF,QAAgB,eAAA,CAAA,CAAC,MAAM,CAAI,GAAA,CAAA,CAAA,CAAA;AAAA,OAAA;AAAA,KAAA,CAAA;AAAA,IAKnC,KAAO,EAAA,CAAE,OAAS,EAAA,UAAA,GAAa,MAAS,GAAA,MAAA,CAAA;AAAA,GAAA,sCAEvC,KAAD,EAAA;AAAA,IAAK,WAAW,YAAa,CAAA,sBAAA,CAAA;AAAA,IAAyB,GAAA;AAAA,GAAA,sCACnD,cAAD,EAAA;AAAA,IACE,GAAA,EAAK,CAAa,EAAA,GAAA,WAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,WAAA,CAAA,GAAA,KAAb,IAAoB,GAAA,EAAA,GAAA,EAAA;AAAA,IACzB,WAAa,EAAA,aAAA;AAAA,IACb,IAAA;AAAA,IACA,GAAK,EAAA,OAAA;AAAA,IACL,WAAa,EAAA,CAAE,OAAS,EAAA,UAAA,GAAa,MAAS,GAAA,OAAA,CAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAOxD,MAAM,eAAA,GAAkB,CAAC,KAAoB,KAAA;AAC3C,EAAM,MAAA,CAAE,OAAS,EAAA,QAAA,CAAA,GAAa,KAAM,CAAA,UAAA,CAAA;AAEpC,EAAO,OAAA;AAAA,IACL,SAAS,OAAQ,CAAA,QAAA,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAIrB,yBAAe,QAAQ,eAAiB,CAAA,CAAA,gBAAA,CAAA;;;;"}
1
+ {"version":3,"file":"PointCloud2DView.js","sources":["../../../src/components/pointCloudView/PointCloud2DView.tsx"],"sourcesContent":["import { getClassName } from '@/utils/dom';\nimport React, { useContext, useEffect, useRef, useState } from 'react';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport AnnotationView from '@/components/AnnotationView';\nimport { PointCloudContext } from './PointCloudContext';\nimport { AppState } from '@/store';\nimport { connect } from 'react-redux';\nimport { IFileItem } from '@/types/data';\nimport { LeftOutlined, RightOutlined } from '@ant-design/icons';\nimport useSize from '@/hooks/useSize';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { ViewOperation } from '@labelbee/lb-annotation';\nimport { useTranslation } from 'react-i18next';\n\ninterface IProps {\n imgInfo: IFileItem;\n}\n\nconst Toolbar = ({\n onNext,\n onPrev,\n imgLength,\n imgIndex,\n}: {\n onNext: () => void;\n onPrev: () => void;\n imgLength: number;\n imgIndex: number;\n}) => {\n return (\n <div>\n <LeftOutlined onClick={onPrev} />\n <span>\n {' '}\n {imgIndex + 1} / {imgLength}{' '}\n </span>\n\n <RightOutlined onClick={onNext} />\n </div>\n );\n};\n\n// TODO, It will be deleted when the exported type of lb-annotation is work.\ninterface IAnnotationDataTemporarily {\n type: string;\n annotation: any;\n}\n\nconst PointCloud2DView = ({ imgInfo }: IProps) => {\n const [annotations2d, setAnnotations2d] = useState<IAnnotationDataTemporarily[]>([]);\n const { pointCloudBoxList, topViewInstance } = useContext(PointCloudContext);\n const [mappingIndex, setMappingIndex] = useState(0);\n const ref = useRef(null);\n const viewRef = useRef<{ toolInstance: ViewOperation }>();\n const { selectedBox } = useSingleBox();\n const size = useSize(ref);\n const { t } = useTranslation();\n\n const mappingData = imgInfo?.mappingImgList?.[mappingIndex];\n\n useEffect(() => {\n setMappingIndex(0);\n }, [imgInfo]);\n\n useEffect(() => {\n if (topViewInstance && mappingData) {\n const { pointCloudInstance } = topViewInstance;\n const defaultViewStyle = {\n fill: 'transparent',\n color: 'green',\n };\n const newAnnotations2d: IAnnotationDataTemporarily[] = pointCloudBoxList.reduce(\n (acc: IAnnotationDataTemporarily[], pointCloudBox) => {\n const viewDataPointList = pointCloudInstance.pointCloudLidar2image(\n pointCloudBox,\n mappingData.calib,\n );\n return [\n ...acc,\n ...viewDataPointList.map((v: any) => {\n return {\n type: v.type,\n annotation: {\n id: pointCloudBox.id,\n pointList: v.pointList,\n ...defaultViewStyle,\n },\n };\n }),\n ];\n },\n [],\n );\n\n setAnnotations2d(newAnnotations2d);\n }\n }, [pointCloudBoxList, mappingData]);\n\n const hiddenData = !imgInfo || !imgInfo?.mappingImgList || !(imgInfo?.mappingImgList?.length > 0);\n\n useEffect(() => {\n const toolInstance = viewRef.current?.toolInstance;\n\n if (!selectedBox || !toolInstance) {\n return;\n }\n const selected2data = annotations2d.find((v) => v.annotation.id === selectedBox.info.id);\n\n if (selected2data?.annotation.pointList?.length > 0) {\n toolInstance.focusPositionByPointList(selected2data?.annotation.pointList);\n }\n }, [selectedBox, viewRef.current, annotations2d]);\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-2d-container')}\n title={t('2DView')}\n toolbar={\n hiddenData ? undefined : (\n <Toolbar\n imgIndex={mappingIndex}\n imgLength={imgInfo.mappingImgList?.length ?? 0}\n onNext={() => {\n if (!imgInfo || !imgInfo?.mappingImgList) {\n return;\n }\n\n if (mappingIndex >= imgInfo?.mappingImgList?.length - 1) {\n return;\n }\n setMappingIndex((v) => v + 1);\n }}\n onPrev={() => {\n if (mappingIndex <= 0) {\n return;\n }\n setMappingIndex((v) => v - 1);\n }}\n />\n )\n }\n style={{ display: hiddenData ? 'none' : 'flex' }}\n >\n <div className={getClassName('point-cloud-2d-image')} ref={ref}>\n <AnnotationView\n src={mappingData?.url ?? ''}\n annotations={annotations2d}\n size={size}\n ref={viewRef}\n globalStyle={{ display: hiddenData ? 'none' : 'block' }}\n />\n </div>\n </PointCloudContainer>\n );\n};\n\nconst mapStateToProps = (state: AppState) => {\n const { imgList, imgIndex } = state.annotation;\n\n return {\n imgInfo: imgList[imgIndex],\n };\n};\n\nexport default connect(mapStateToProps)(PointCloud2DView);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,UAAU,CAAC;AAAA,EACf,MAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,CAMI,K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UAAA,GAAa,MAAS,GAAA,OAAA,CAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAOxD,MAAM,eAAA,GAAkB,CAAC,KAAoB,KAAA;AAC3C,EAAM,MAAA,CAAE,OAAS,EAAA,QAAA,CAAA,GAAa,KAAM,CAAA,UAAA,CAAA;AAEpC,EAAO,OAAA;AAAA,IACL,SAAS,OAAQ,CAAA,QAAA,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAIrB,yBAAe,QAAQ,eAAiB,CAAA,CAAA,gBAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- import{getClassName as r}from"../../utils/dom.js";import{PointCloud as B}from"@labelbee/lb-annotation";import{PointCloudUtils as D,EPerspectiveView as E}from"@labelbee/lb-utils";import L from"classnames";import e,{useContext as p,useState as b,useRef as I,useEffect as C,useMemo as T}from"react";import{PointCloudContainer as N}from"./PointCloudLayout.js";import{PointCloudContext as S}from"./PointCloudContext.js";import{aMapStateToProps as j}from"../../store/annotation/map.js";import{connect as k}from"react-redux";import{jsonParser as R}from"../../utils/index.js";import{useSingleBox as A}from"./hooks/useSingleBox.js";import{Switch as _}from"antd";import y from"../../hooks/useSize.js";import{usePointCloudViews as z}from"./hooks/usePointCloudViews.js";const F="LABELBEE-POINTCLOUD",v=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{}}),s=({perspectiveView:t})=>{const{isActive:c,setTarget3DView:i}=p(v),u=d=>L({[r("point-cloud-3d-view",d)]:!0,active:c});return e.createElement("span",{onClick:()=>{i(E[t])},className:u(t.toLocaleLowerCase())})},M=()=>{const{reset3DView:t}=p(v);return e.createElement("div",{className:r("point-cloud-3d-sidebar")},e.createElement(s,{perspectiveView:"Top"}),e.createElement(s,{perspectiveView:"Front"}),e.createElement(s,{perspectiveView:"Left"}),e.createElement(s,{perspectiveView:"Back"}),e.createElement(s,{perspectiveView:"Right"}),e.createElement(s,{perspectiveView:"LFT"}),e.createElement(s,{perspectiveView:"RBT"}),e.createElement("span",{onClick:()=>{t()},className:r("point-cloud-3d-view","reset")}))},O=({currentData:t})=>{var c;const i=p(S),[u,d]=b(!0),m=I(null),{initPointCloud3d:w}=z(),V=y(m);C(()=>{!i.mainViewInstance||w==null||w()},[V]);const{selectedBox:l}=A(),f=n=>{var o;const a=l==null?void 0:l.info;a&&((o=i.mainViewInstance)==null||o.updateCameraByBox(a,n))},P=()=>{var n;(n=i.mainViewInstance)==null||n.resetCamera()};C(()=>{var n;if(m.current&&(t==null?void 0:t.url)){let o=i.mainViewInstance;if(o||(o=new B({container:m.current,backgroundColor:"#4c4c4c"})),t.result){const a=D.getBoxParamsFromResultList(t.result);a.forEach(h=>{o==null||o.generateBox(h)}),i.setPointCloudResult(a),i.setPointCloudValid((n=R(t.result))==null?void 0:n.valid)}i.setMainViewInstance(o)}},[t]),C(()=>{l&&f(E.Top)},[l]);const g=T(()=>({reset3DView:P,setTarget3DView:f,isActive:!!l}),[l]),x=e.createElement("div",null,e.createElement("span",{style:{marginRight:8}},"\u663E\u793A\u7BAD\u5934"),e.createElement(_,{size:"small",checked:u,onChange:n=>{var o;d(n),(o=i.mainViewInstance)==null||o.setShowDirection(n)}}));return e.createElement(N,{className:r("point-cloud-3d-container"),title:"3D\u89C6\u56FE",toolbar:x,style:{height:t.mappingImgList&&((c=t.mappingImgList)==null?void 0:c.length)>0?"55%":"100%"}},e.createElement("div",{className:r("point-cloud-3d-content")},e.createElement(v.Provider,{value:g},e.createElement(M,null)),e.createElement("div",{className:r("point-cloud-3d-view"),id:F,ref:m})))};var U=k(j)(O);export{U as default};
1
+ import{getClassName as r}from"../../utils/dom.js";import{PointCloud as L}from"@labelbee/lb-annotation";import{PointCloudUtils as T,EPerspectiveView as E}from"@labelbee/lb-utils";import b from"classnames";import e,{useContext as p,useState as D,useRef as I,useEffect as C,useMemo as S}from"react";import{PointCloudContainer as N}from"./PointCloudLayout.js";import{PointCloudContext as j}from"./PointCloudContext.js";import{aMapStateToProps as k}from"../../store/annotation/map.js";import{connect as R}from"react-redux";import{jsonParser as A}from"../../utils/index.js";import{useSingleBox as _}from"./hooks/useSingleBox.js";import{Switch as y}from"antd";import z from"../../hooks/useSize.js";import{usePointCloudViews as F}from"./hooks/usePointCloudViews.js";import{useTranslation as M}from"react-i18next";const O="LABELBEE-POINTCLOUD",v=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{}}),s=({perspectiveView:t})=>{const{isActive:c,setTarget3DView:i}=p(v),u=d=>b({[r("point-cloud-3d-view",d)]:!0,active:c});return e.createElement("span",{onClick:()=>{i(E[t])},className:u(t.toLocaleLowerCase())})},U=()=>{const{reset3DView:t}=p(v);return e.createElement("div",{className:r("point-cloud-3d-sidebar")},e.createElement(s,{perspectiveView:"Top"}),e.createElement(s,{perspectiveView:"Front"}),e.createElement(s,{perspectiveView:"Left"}),e.createElement(s,{perspectiveView:"Back"}),e.createElement(s,{perspectiveView:"Right"}),e.createElement(s,{perspectiveView:"LFT"}),e.createElement(s,{perspectiveView:"RBT"}),e.createElement("span",{onClick:()=>{t()},className:r("point-cloud-3d-view","reset")}))},q=({currentData:t})=>{var c;const i=p(j),[u,d]=D(!0),m=I(null),{initPointCloud3d:w}=F(),P=z(m),{t:f}=M();C(()=>{!i.mainViewInstance||w==null||w()},[P]);const{selectedBox:l}=_(),V=n=>{var o;const a=l==null?void 0:l.info;a&&((o=i.mainViewInstance)==null||o.updateCameraByBox(a,n))},g=()=>{var n;(n=i.mainViewInstance)==null||n.resetCamera()};C(()=>{var n;if(m.current&&(t==null?void 0:t.url)){let o=i.mainViewInstance;if(o||(o=new L({container:m.current,backgroundColor:"#4c4c4c"})),t.result){const a=T.getBoxParamsFromResultList(t.result);a.forEach(B=>{o==null||o.generateBox(B)}),i.setPointCloudResult(a),i.setPointCloudValid((n=A(t.result))==null?void 0:n.valid)}i.setMainViewInstance(o)}},[t]),C(()=>{l&&V(E.Top)},[l]);const x=S(()=>({reset3DView:g,setTarget3DView:V,isActive:!!l}),[l]),h=e.createElement("div",null,e.createElement("span",{style:{marginRight:8}},f("ShowArrows")),e.createElement(y,{size:"small",checked:u,onChange:n=>{var o;d(n),(o=i.mainViewInstance)==null||o.setShowDirection(n)}}));return e.createElement(N,{className:r("point-cloud-3d-container"),title:f("3DView"),toolbar:h,style:{height:t.mappingImgList&&((c=t.mappingImgList)==null?void 0:c.length)>0?"55%":"100%"}},e.createElement("div",{className:r("point-cloud-3d-content")},e.createElement(v.Provider,{value:x},e.createElement(U,null)),e.createElement("div",{className:r("point-cloud-3d-view"),id:O,ref:m})))};var G=R(k)(q);export{G as default};
@@ -1 +1 @@
1
- {"version":3,"file":"PointCloud3DView.js","sources":["../../../src/components/pointCloudView/PointCloud3DView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-13 19:31:36\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-06-27 19:43:25\n */\n\nimport { getClassName } from '@/utils/dom';\nimport { PointCloud } from '@labelbee/lb-annotation';\nimport { EPerspectiveView, IPointCloudBox, PointCloudUtils } from '@labelbee/lb-utils';\nimport classNames from 'classnames';\nimport React, { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport { PointCloudContext } from './PointCloudContext';\nimport { aMapStateToProps, IAnnotationStateProps } from '@/store/annotation/map';\nimport { connect } from 'react-redux';\nimport { jsonParser } from '@/utils';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { Switch } from 'antd';\nimport useSize from '@/hooks/useSize';\nimport { usePointCloudViews } from './hooks/usePointCloudViews';\n\nconst pointCloudID = 'LABELBEE-POINTCLOUD';\nconst PointCloud3DContext = React.createContext<{\n isActive: boolean;\n setTarget3DView: (perspectiveView: EPerspectiveView) => void;\n reset3DView: () => void;\n}>({\n isActive: false,\n setTarget3DView: () => {},\n reset3DView: () => {},\n});\n\nconst PointCloudViewIcon = ({\n perspectiveView,\n}: {\n perspectiveView: keyof typeof EPerspectiveView;\n}) => {\n const { isActive, setTarget3DView } = useContext(PointCloud3DContext);\n\n const getTarget3DViewClassName = (position: string) => {\n return classNames({\n [getClassName('point-cloud-3d-view', position)]: true,\n active: isActive,\n });\n };\n\n return (\n <span\n onClick={() => {\n setTarget3DView(EPerspectiveView[perspectiveView]);\n }}\n className={getTarget3DViewClassName(perspectiveView.toLocaleLowerCase())}\n />\n );\n};\n\nconst PointCloud3DSideBar = () => {\n const { reset3DView } = useContext(PointCloud3DContext);\n return (\n <div className={getClassName('point-cloud-3d-sidebar')}>\n <PointCloudViewIcon perspectiveView='Top' />\n <PointCloudViewIcon perspectiveView='Front' />\n <PointCloudViewIcon perspectiveView='Left' />\n <PointCloudViewIcon perspectiveView='Back' />\n <PointCloudViewIcon perspectiveView='Right' />\n <PointCloudViewIcon perspectiveView='LFT' />\n <PointCloudViewIcon perspectiveView='RBT' />\n <span\n onClick={() => {\n reset3DView();\n }}\n className={getClassName('point-cloud-3d-view', 'reset')}\n />\n </div>\n );\n};\n\nconst PointCloud3D: React.FC<IAnnotationStateProps> = ({ currentData }) => {\n const ptCtx = useContext(PointCloudContext);\n const [showDirection, setShowDirection] = useState(true);\n const ref = useRef<HTMLDivElement>(null);\n const { initPointCloud3d } = usePointCloudViews();\n const size = useSize(ref);\n\n useEffect(() => {\n if (!ptCtx.mainViewInstance) {\n return;\n }\n initPointCloud3d?.();\n }, [size]);\n const { selectedBox } = useSingleBox();\n\n const setTarget3DView = (perspectiveView: EPerspectiveView) => {\n const box = selectedBox?.info;\n\n if (box) {\n ptCtx.mainViewInstance?.updateCameraByBox(box, perspectiveView);\n }\n };\n\n const reset3DView = () => {\n ptCtx.mainViewInstance?.resetCamera();\n };\n\n useEffect(() => {\n if (ref.current && currentData?.url) {\n let pointCloud = ptCtx.mainViewInstance;\n if (!pointCloud) {\n pointCloud = new PointCloud({\n container: ref.current,\n backgroundColor: '#4c4c4c',\n });\n }\n\n if (currentData.result) {\n const boxParamsList = PointCloudUtils.getBoxParamsFromResultList(currentData.result);\n\n // Add Init Box\n boxParamsList.forEach((v: IPointCloudBox) => {\n pointCloud?.generateBox(v);\n });\n\n ptCtx.setPointCloudResult(boxParamsList);\n ptCtx.setPointCloudValid(jsonParser(currentData.result)?.valid);\n }\n\n ptCtx.setMainViewInstance(pointCloud);\n }\n }, [currentData]);\n\n /**\n * Observe selectedID and reset camera to target top-view\n */\n useEffect(() => {\n if (selectedBox) {\n setTarget3DView(EPerspectiveView.Top);\n }\n }, [selectedBox]);\n\n const ptCloud3DCtx = useMemo(() => {\n return { reset3DView, setTarget3DView, isActive: !!selectedBox };\n }, [selectedBox]);\n\n const PointCloud3DTitle = (\n <div>\n <span style={{ marginRight: 8 }}>显示箭头</span>\n <Switch\n size='small'\n checked={showDirection}\n onChange={(showDirection) => {\n setShowDirection(showDirection);\n ptCtx.mainViewInstance?.setShowDirection(showDirection);\n }}\n />\n </div>\n );\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-3d-container')}\n title='3D视图'\n toolbar={PointCloud3DTitle}\n style={{\n height:\n currentData.mappingImgList && currentData.mappingImgList?.length > 0 ? '55%' : '100%',\n }}\n >\n <div className={getClassName('point-cloud-3d-content')}>\n <PointCloud3DContext.Provider value={ptCloud3DCtx}>\n <PointCloud3DSideBar />\n </PointCloud3DContext.Provider>\n <div className={getClassName('point-cloud-3d-view')} id={pointCloudID} ref={ref} />\n </div>\n </PointCloudContainer>\n );\n};\n\nexport default connect(aMapStateToProps)(PointCloud3D);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAM,YAAe,GAAA,qBAAA,CAAA;AACrB,MAAM,mBAAA,GAAsB,MAAM,aAI/B,CAAA;AAAA,EACD,QAAU,EAAA,KAAA;AAAA,EACV,iBAAiB,MAAM;AAAA,GAAA;AAAA,EACvB,aAAa,MAAM;AAAA,GAAA;AAAA,CAAA,CAAA,CAAA;AAGrB,MAAM,qBAAqB,CAAC;AAAA,EAC1B,eAAA;AAA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AAI,KAAQ,GAAA,MAAA;AAAA,KAAA;AAAA,GAAA,sCAGlF,KAAD,EAAA;AAAA,IAAK,WAAW,YAAa,CAAA,wBAAA,CAAA;AAAA,GAC3B,kBAAA,KAAA,CAAA,aAAA,CAAC,oBAAoB,QAArB,EAAA;AAAA,IAA8B,KAAO,EAAA,YAAA;AAAA,GAAA,kBAClC,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAD,IAEF,CAAA,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAD,EAAA;AAAA,IAAK,WAAW,YAAa,CAAA,qBAAA,CAAA;AAAA,IAAwB,EAAI,EAAA,YAAA;AAAA,IAAc,GAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAM/E,uBAAe,QAAQ,gBAAkB,CAAA,CAAA,YAAA,CAAA;;;;"}
1
+ {"version":3,"file":"PointCloud3DView.js","sources":["../../../src/components/pointCloudView/PointCloud3DView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-13 19:31:36\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-06-27 19:43:25\n */\n\nimport { getClassName } from '@/utils/dom';\nimport { PointCloud } from '@labelbee/lb-annotation';\nimport { EPerspectiveView, IPointCloudBox, PointCloudUtils } from '@labelbee/lb-utils';\nimport classNames from 'classnames';\nimport React, { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport { PointCloudContext } from './PointCloudContext';\nimport { aMapStateToProps, IAnnotationStateProps } from '@/store/annotation/map';\nimport { connect } from 'react-redux';\nimport { jsonParser } from '@/utils';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { Switch } from 'antd';\nimport useSize from '@/hooks/useSize';\nimport { usePointCloudViews } from './hooks/usePointCloudViews';\nimport { useTranslation } from 'react-i18next';\n\nconst pointCloudID = 'LABELBEE-POINTCLOUD';\nconst PointCloud3DContext = React.createContext<{\n isActive: boolean;\n setTarget3DView: (perspectiveView: EPerspectiveView) => void;\n reset3DView: () => void;\n}>({\n isActive: false,\n setTarget3DView: () => {},\n reset3DView: () => {},\n});\n\nconst PointCloudViewIcon = ({\n perspectiveView,\n}: {\n perspectiveView: keyof typeof EPerspectiveView;\n}) => {\n const { isActive, setTarget3DView } = useContext(PointCloud3DContext);\n\n const getTarget3DViewClassName = (position: string) => {\n return classNames({\n [getClassName('point-cloud-3d-view', position)]: true,\n active: isActive,\n });\n };\n\n return (\n <span\n onClick={() => {\n setTarget3DView(EPerspectiveView[perspectiveView]);\n }}\n className={getTarget3DViewClassName(perspectiveView.toLocaleLowerCase())}\n />\n );\n};\n\nconst PointCloud3DSideBar = () => {\n const { reset3DView } = useContext(PointCloud3DContext);\n return (\n <div className={getClassName('point-cloud-3d-sidebar')}>\n <PointCloudViewIcon perspectiveView='Top' />\n <PointCloudViewIcon perspectiveView='Front' />\n <PointCloudViewIcon perspectiveView='Left' />\n <PointCloudViewIcon perspectiveView='Back' />\n <PointCloudViewIcon perspectiveView='Right' />\n <PointCloudViewIcon perspectiveView='LFT' />\n <PointCloudViewIcon perspectiveView='RBT' />\n <span\n onClick={() => {\n reset3DView();\n }}\n className={getClassName('point-cloud-3d-view', 'reset')}\n />\n </div>\n );\n};\n\nconst PointCloud3D: React.FC<IAnnotationStateProps> = ({ currentData }) => {\n const ptCtx = useContext(PointCloudContext);\n const [showDirection, setShowDirection] = useState(true);\n const ref = useRef<HTMLDivElement>(null);\n const { initPointCloud3d } = usePointCloudViews();\n const size = useSize(ref);\n const { t } = useTranslation();\n\n useEffect(() => {\n if (!ptCtx.mainViewInstance) {\n return;\n }\n initPointCloud3d?.();\n }, [size]);\n const { selectedBox } = useSingleBox();\n\n const setTarget3DView = (perspectiveView: EPerspectiveView) => {\n const box = selectedBox?.info;\n\n if (box) {\n ptCtx.mainViewInstance?.updateCameraByBox(box, perspectiveView);\n }\n };\n\n const reset3DView = () => {\n ptCtx.mainViewInstance?.resetCamera();\n };\n\n useEffect(() => {\n if (ref.current && currentData?.url) {\n let pointCloud = ptCtx.mainViewInstance;\n if (!pointCloud) {\n pointCloud = new PointCloud({\n container: ref.current,\n backgroundColor: '#4c4c4c',\n });\n }\n\n if (currentData.result) {\n const boxParamsList = PointCloudUtils.getBoxParamsFromResultList(currentData.result);\n\n // Add Init Box\n boxParamsList.forEach((v: IPointCloudBox) => {\n pointCloud?.generateBox(v);\n });\n\n ptCtx.setPointCloudResult(boxParamsList);\n ptCtx.setPointCloudValid(jsonParser(currentData.result)?.valid);\n }\n\n ptCtx.setMainViewInstance(pointCloud);\n }\n }, [currentData]);\n\n /**\n * Observe selectedID and reset camera to target top-view\n */\n useEffect(() => {\n if (selectedBox) {\n setTarget3DView(EPerspectiveView.Top);\n }\n }, [selectedBox]);\n\n const ptCloud3DCtx = useMemo(() => {\n return { reset3DView, setTarget3DView, isActive: !!selectedBox };\n }, [selectedBox]);\n\n const PointCloud3DTitle = (\n <div>\n <span style={{ marginRight: 8 }}>{t('ShowArrows')}</span>\n <Switch\n size='small'\n checked={showDirection}\n onChange={(showDirection) => {\n setShowDirection(showDirection);\n ptCtx.mainViewInstance?.setShowDirection(showDirection);\n }}\n />\n </div>\n );\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-3d-container')}\n title={t('3DView')}\n toolbar={PointCloud3DTitle}\n style={{\n height:\n currentData.mappingImgList && currentData.mappingImgList?.length > 0 ? '55%' : '100%',\n }}\n >\n <div className={getClassName('point-cloud-3d-content')}>\n <PointCloud3DContext.Provider value={ptCloud3DCtx}>\n <PointCloud3DSideBar />\n </PointCloud3DContext.Provider>\n <div className={getClassName('point-cloud-3d-view')} id={pointCloudID} ref={ref} />\n </div>\n </PointCloudContainer>\n );\n};\n\nexport default connect(aMapStateToProps)(PointCloud3D);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuBA,MAAM,YAAe,GAAA,qBAAA,CAAA;AACrB,MAAM,mBAAA,GAAsB,MAAM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EAAA,2CACG,mBAAD,EAAA;AAAA,IACE,WAAW,YAAa,CAAA,0BAAA,CAAA;AAAA,IACxB,OAAO,CAAE,CAAA,QAAA,CAAA;AAAA,IACT,OAAS,EAAA,iBAAA;AAAA,IACT,KAAO,EAAA;AAAA,MACL,MAAA,EACE,YAAY,cAAkB,IAAA,CAAA,CAAA,EAAA,GAAA,WAAA,CAAY,mBAAZ,IAA4B,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAA,IAAS,IAAI,KAAQ,GAAA,MAAA;AAAA,KAAA;AAAA,GAAA,sCAGlF,KAAD,EAAA;AAAA,IAAK,WAAW,YAAa,CAAA,wBAAA,CAAA;AAAA,GAC3B,kBAAA,KAAA,CAAA,aAAA,CAAC,oBAAoB,QAArB,EAAA;AAAA,IAA8B,KAAO,EAAA,YAAA;AAAA,GAAA,kBAClC,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAD,IAEF,CAAA,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAD,EAAA;AAAA,IAAK,WAAW,YAAa,CAAA,qBAAA,CAAA;AAAA,IAAwB,EAAI,EAAA,YAAA;AAAA,IAAc,GAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAM/E,uBAAe,QAAQ,gBAAkB,CAAA,CAAA,YAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- import{PointCloudAnnotation as S,MathUtils as d}from"@labelbee/lb-annotation";import{getClassName as x}from"../../utils/dom.js";import{PointCloudContainer as O}from"./PointCloudLayout.js";import f,{useRef as z,useEffect as P}from"react";import{PointCloudContext as M}from"./PointCloudContext.js";import{useSingleBox as N}from"./hooks/useSingleBox.js";import{EPerspectiveView as X}from"@labelbee/lb-utils";import{SizeInfoForView as W}from"./PointCloudInfos.js";import{connect as A}from"react-redux";import{aMapStateToProps as H}from"../../store/annotation/map.js";import{synchronizeTopView as T,synchronizeSideView as Y}from"./hooks/usePointCloudViews.js";import D from"../../hooks/useSize.js";import F from"./components/EmptyPage/index.js";const R=(r,t,e=1)=>{const{width:n,height:i}=t,c={x:r.x+n*e/2,y:r.y+i*e/2},o={x:t.width/2,y:t.height/2};return{offsetX:(o.x-c.x)/e,offsetY:-(o.y-c.y)/e}},V=(r,t,e,n,i)=>{const{offsetX:c,offsetY:o}=R(r,e,t);if(i.camera.zoom=t,r){const a=Math.cos(n.rotation),s=Math.sin(n.rotation),l=c*a,u=c*s,{x:p,y:m,z:h}=i.initCameraPosition;i.camera.position.set(p+u,m-l,h+o)}i.camera.updateProjectionMatrix(),i.render()},U=({currentData:r})=>{const t=f.useContext(M),e=z(null),n=D(e),{updateSelectedBox:i,selectedBox:c}=N();return P(()=>{if(e.current){const o={width:e.current.clientWidth,height:e.current.clientHeight},a=new S({container:e.current,size:o,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0}});t.setBackViewInstance(a)}},[]),P(()=>{if(!n||!t.backViewInstance)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=t.backViewInstance;o.singleOn("renderZoom",(s,l)=>{!t.selectedPointCloudBox||V(l,s,n,t.selectedPointCloudBox,a)}),o.singleOn("dragMove",({currentPos:s,zoom:l})=>{!t.selectedPointCloudBox||V(s,l,n,t.selectedPointCloudBox,a)}),o.singleOn("updatePolygonByDrag",({newPolygon:s,originPolygon:l})=>{if(!t.selectedPointCloudBox||!t.mainViewInstance||!r.url)return;const[u,p,m]=s.pointList,[h,y,B]=l.pointList,g=d.getLineCenterPoint([u,m]),w=d.getLineCenterPoint([h,B]),v={x:{x:g.x-w.x,y:g.y-w.y}.x,y:0,z:g.y-w.y},L=d.getLineLength(u,p),I=d.getLineLength(h,y),b=L-I,j=d.getLineLength(p,m),k=d.getLineLength(y,B),E=j-k,{newBoxParams:C}=a.getNewBoxByBackUpdate(v,E,b,t.selectedPointCloudBox);T(C,s,t.topViewInstance,t.mainViewInstance),Y(C,s,t.sideViewInstance,r.url),t.mainViewInstance.highlightOriginPointCloud(C),i(C)})},[t,n]),P(()=>{var o;(o=t==null?void 0:t.backViewInstance)==null||o.initSize(n)},[n]),f.createElement(O,{className:x("point-cloud-container","back-view"),title:"\u80CC\u89C6\u56FE",toolbar:f.createElement(W,{perspectiveView:X.Back})},f.createElement("div",{className:x("point-cloud-container","bottom-view-content")},f.createElement("div",{className:x("point-cloud-container","core-instance"),ref:e}),!c&&f.createElement(F,null)))};var Z=A(H)(U);export{Z as default};
1
+ import{PointCloudAnnotation as O,MathUtils as f}from"@labelbee/lb-annotation";import{getClassName as x}from"../../utils/dom.js";import{PointCloudContainer as z}from"./PointCloudLayout.js";import p,{useRef as M,useEffect as P}from"react";import{PointCloudContext as N}from"./PointCloudContext.js";import{useSingleBox as X}from"./hooks/useSingleBox.js";import{EPerspectiveView as T}from"@labelbee/lb-utils";import{SizeInfoForView as W}from"./PointCloudInfos.js";import{connect as A}from"react-redux";import{aMapStateToProps as H}from"../../store/annotation/map.js";import{synchronizeTopView as Y,synchronizeSideView as D}from"./hooks/usePointCloudViews.js";import R from"../../hooks/useSize.js";import U from"./components/EmptyPage/index.js";import{useTranslation as F}from"react-i18next";const Z=(r,t,e=1)=>{const{width:o,height:i}=t,a={x:r.x+o*e/2,y:r.y+i*e/2},d={x:t.width/2,y:t.height/2};return{offsetX:(d.x-a.x)/e,offsetY:-(d.y-a.y)/e}},v=(r,t,e,o,i)=>{const{offsetX:a,offsetY:d}=Z(r,e,t);if(i.camera.zoom=t,r){const n=Math.cos(o.rotation),c=Math.sin(o.rotation),s=a*n,l=a*c,{x:u,y:m,z:h}=i.initCameraPosition;i.camera.position.set(u+l,m-s,h+d)}i.camera.updateProjectionMatrix(),i.render()},_=({currentData:r})=>{const t=p.useContext(N),e=M(null),o=R(e),{updateSelectedBox:i,selectedBox:a}=X(),{t:d}=F();return P(()=>{if(e.current){const n={width:e.current.clientWidth,height:e.current.clientHeight},c=new O({container:e.current,size:n,polygonOperationProps:{showDirectionLine:!1,forbidAddNew:!0}});t.setBackViewInstance(c)}},[]),P(()=>{if(!o||!t.backViewInstance)return;const{pointCloud2dOperation:n,pointCloudInstance:c}=t.backViewInstance;n.singleOn("renderZoom",(s,l)=>{!t.selectedPointCloudBox||v(l,s,o,t.selectedPointCloudBox,c)}),n.singleOn("dragMove",({currentPos:s,zoom:l})=>{!t.selectedPointCloudBox||v(s,l,o,t.selectedPointCloudBox,c)}),n.singleOn("updatePolygonByDrag",({newPolygon:s,originPolygon:l})=>{if(!t.selectedPointCloudBox||!t.mainViewInstance||!r.url)return;const[u,m,h]=s.pointList,[y,B,V]=l.pointList,C=f.getLineCenterPoint([u,h]),w=f.getLineCenterPoint([y,V]),L={x:{x:C.x-w.x,y:C.y-w.y}.x,y:0,z:C.y-w.y},I=f.getLineLength(u,m),b=f.getLineLength(y,B),k=I-b,j=f.getLineLength(m,h),S=f.getLineLength(B,V),E=j-S,{newBoxParams:g}=c.getNewBoxByBackUpdate(L,E,k,t.selectedPointCloudBox);Y(g,s,t.topViewInstance,t.mainViewInstance),D(g,s,t.sideViewInstance,r.url),t.mainViewInstance.highlightOriginPointCloud(g),i(g)})},[t,o]),P(()=>{var n;(n=t==null?void 0:t.backViewInstance)==null||n.initSize(o)},[o]),p.createElement(z,{className:x("point-cloud-container","back-view"),title:d("BackView"),toolbar:p.createElement(W,{perspectiveView:T.Back})},p.createElement("div",{className:x("point-cloud-container","bottom-view-content")},p.createElement("div",{className:x("point-cloud-container","core-instance"),ref:e}),!a&&p.createElement(U,null)))};var q=A(H)(_);export{q as default};
@@ -1 +1 @@
1
- {"version":3,"file":"PointCloudBackView.js","sources":["../../../src/components/pointCloudView/PointCloudBackView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-22 11:08:31\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-07-08 11:08:02\n */\nimport { PointCloud, MathUtils, PointCloudAnnotation } from '@labelbee/lb-annotation';\nimport { getClassName } from '@/utils/dom';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport React, { useEffect, useRef } from 'react';\nimport { PointCloudContext } from './PointCloudContext';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { EPerspectiveView, IPointCloudBox } from '@labelbee/lb-utils';\nimport { SizeInfoForView } from './PointCloudInfos';\nimport { connect } from 'react-redux';\nimport { aMapStateToProps, IAnnotationStateProps } from '@/store/annotation/map';\nimport { synchronizeSideView, synchronizeTopView } from './hooks/usePointCloudViews';\nimport useSize from '@/hooks/useSize';\nimport EmptyPage from './components/EmptyPage';\n\n/**\n * 统一一下,将其拓展为 二维转换为 三维坐标的转换\n * Get the offset from canvas2d-coordinate to world coordinate\n * @param currentPos\n * @param size\n * @param zoom\n * @returns\n */\nconst TransferCanvas2WorldOffset = (\n currentPos: { x: number; y: number },\n size: { width: number; height: number },\n zoom = 1,\n) => {\n const { width: w, height: h } = size;\n\n const canvasCenterPoint = {\n x: currentPos.x + (w * zoom) / 2,\n y: currentPos.y + (h * zoom) / 2,\n };\n\n const worldCenterPoint = {\n x: size.width / 2,\n y: size.height / 2,\n };\n\n return {\n offsetX: (worldCenterPoint.x - canvasCenterPoint.x) / zoom,\n offsetY: -(worldCenterPoint.y - canvasCenterPoint.y) / zoom,\n };\n};\nconst updateBackViewByCanvas2D = (\n currentPos: { x: number; y: number },\n zoom: number,\n size: { width: number; height: number },\n selectedPointCloudBox: IPointCloudBox,\n backPointCloud: PointCloud,\n) => {\n const { offsetX, offsetY } = TransferCanvas2WorldOffset(currentPos, size, zoom);\n backPointCloud.camera.zoom = zoom;\n if (currentPos) {\n const cos = Math.cos(selectedPointCloudBox.rotation);\n const sin = Math.sin(selectedPointCloudBox.rotation);\n const offsetXX = offsetX * cos;\n const offsetXY = offsetX * sin;\n const { x, y, z } = backPointCloud.initCameraPosition;\n backPointCloud.camera.position.set(x + offsetXY, y - offsetXX, z + offsetY);\n }\n backPointCloud.camera.updateProjectionMatrix();\n backPointCloud.render();\n};\n\nconst PointCloudSideView = ({ currentData }: IAnnotationStateProps) => {\n const ptCtx = React.useContext(PointCloudContext);\n const ref = useRef<HTMLDivElement>(null);\n const size = useSize(ref);\n const { updateSelectedBox, selectedBox } = useSingleBox();\n\n useEffect(() => {\n if (ref.current) {\n const size = {\n width: ref.current.clientWidth,\n height: ref.current.clientHeight,\n };\n\n const pointCloudAnnotation = new PointCloudAnnotation({\n container: ref.current,\n size,\n polygonOperationProps: { showDirectionLine: false, forbidAddNew: true },\n });\n ptCtx.setBackViewInstance(pointCloudAnnotation);\n }\n }, []);\n\n useEffect(() => {\n // By the way as an initialization judgment\n if (!size || !ptCtx.backViewInstance) {\n return;\n }\n\n const {\n pointCloud2dOperation: backPointCloudPolygonOperation,\n pointCloudInstance: backPointCloud,\n } = ptCtx.backViewInstance;\n\n /**\n * Synchronized 3d point cloud view displacement operations\n *\n * Change Orthographic Camera size\n */\n backPointCloudPolygonOperation.singleOn('renderZoom', (zoom: number, currentPos: any) => {\n if (!ptCtx.selectedPointCloudBox) {\n return;\n }\n updateBackViewByCanvas2D(currentPos, zoom, size, ptCtx.selectedPointCloudBox, backPointCloud);\n });\n\n // Synchronized 3d point cloud view displacement operations\n backPointCloudPolygonOperation.singleOn('dragMove', ({ currentPos, zoom }: any) => {\n if (!ptCtx.selectedPointCloudBox) {\n return;\n }\n updateBackViewByCanvas2D(currentPos, zoom, size, ptCtx.selectedPointCloudBox, backPointCloud);\n });\n\n backPointCloudPolygonOperation.singleOn(\n 'updatePolygonByDrag',\n ({ newPolygon, originPolygon }: any) => {\n if (!ptCtx.selectedPointCloudBox || !ptCtx.mainViewInstance || !currentData.url) {\n return;\n }\n\n // Notice. The sort of polygon is important.\n const [point1, point2, point3] = newPolygon.pointList;\n const [op1, op2, op3] = originPolygon.pointList;\n\n // 2D centerPoint => 3D x & z\n const newCenterPoint = MathUtils.getLineCenterPoint([point1, point3]);\n const oldCenterPoint = MathUtils.getLineCenterPoint([op1, op3]);\n\n const offset = {\n x: newCenterPoint.x - oldCenterPoint.x,\n y: newCenterPoint.y - oldCenterPoint.y,\n };\n\n const offsetCenterPoint = {\n x: offset.x,\n y: 0, // Not be used.\n z: newCenterPoint.y - oldCenterPoint.y,\n };\n\n // 2D height => 3D depth\n const height = MathUtils.getLineLength(point1, point2);\n const oldHeight = MathUtils.getLineLength(op1, op2);\n const offsetHeight = height - oldHeight; // 3D depth\n\n // 2D width => 3D width\n const width = MathUtils.getLineLength(point2, point3);\n const oldWidth = MathUtils.getLineLength(op2, op3);\n const offsetWidth = width - oldWidth; // 3D width\n\n const { newBoxParams } = backPointCloud.getNewBoxByBackUpdate(\n offsetCenterPoint,\n offsetWidth,\n offsetHeight,\n ptCtx.selectedPointCloudBox,\n );\n\n synchronizeTopView(newBoxParams, newPolygon, ptCtx.topViewInstance, ptCtx.mainViewInstance);\n synchronizeSideView(newBoxParams, newPolygon, ptCtx.sideViewInstance, currentData.url);\n ptCtx.mainViewInstance.highlightOriginPointCloud(newBoxParams);\n updateSelectedBox(newBoxParams);\n },\n );\n }, [ptCtx, size]);\n\n useEffect(() => {\n // Update Size\n ptCtx?.backViewInstance?.initSize(size);\n }, [size]);\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-container', 'back-view')}\n title='背视图'\n toolbar={<SizeInfoForView perspectiveView={EPerspectiveView.Back} />}\n >\n <div className={getClassName('point-cloud-container', 'bottom-view-content')}>\n <div className={getClassName('point-cloud-container', 'core-instance')} ref={ref} />\n {!selectedBox && <EmptyPage />}\n </div>\n </PointCloudContainer>\n );\n};\n\nexport default connect(aMapStateToProps)(PointCloudSideView);\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA4BA,MAAM,0BAA6B,GAAA,CACjC,UACA,EAAA,IAAA,EACA,OAAO,CACJ,KAAA;AACH,EAAA,MAAM,CAAE,KAAA,EAAO,CAAG,EAAA,MAAA,EAAQ,CAAM,CAAA,GAAA,IAAA,CAAA;AAEhC,EAAA,MAAM,iBAAoB,GAAA;AAAA,IACxB,CAAG,EAAA,UAAA,CAAW,CAAK,GAAA,CAAA,GAAI,IA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A;AAAA,KAAA,CAAA,CAAA;AAAA,GAAA,EAGrB,CAAC,KAAO,EAAA,IAAA,CAAA,CAAA,CAAA;AAEX,EAAA,SAAA,CAAU,MAAM;AA/KlB,IAAA,IAAA,EAAA,CAAA;AAiLI,IAAO,CAAA,EAAA,GAAA,KAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,gBAAA,KAAP,mBAAyB,QAAS,CAAA,IAAA,CAAA,CAAA;AAAA,GAAA,EACjC,CAAC,IAAA,CAAA,CAAA,CAAA;AAEJ,EAAA,2CACG,mBAAD,EAAA;AAAA,IACE,SAAA,EAAW,aAAa,uBAAyB,EAAA,WAAA,CAAA;AAAA,IACjD,KAAM,EAAA,oBAAA;AAAA,IACN,OAAA,sCAAU,eAAD,EAAA;AAAA,MAAiB,iBAAiB,gBAAiB,CAAA,IAAA;AAAA,KAAA,CAAA;AAAA,GAAA,sCAE3D,KAAD,EAAA;AAAA,IAAK,SAAA,EAAW,aAAa,uBAAyB,EAAA,qBAAA,CAAA;AAAA,GAAA,sCACnD,KAAD,EAAA;AAAA,IAAK,SAAA,EAAW,aAAa,uBAAyB,EAAA,eAAA,CAAA;AAAA,IAAkB,GAAA;AAAA,GACvE,CAAA,EAAA,CAAC,WAAe,oBAAA,KAAA,CAAA,aAAA,CAAC,SAAD,EAAA,IAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAMzB,yBAAe,QAAQ,gBAAkB,CAAA,CAAA,kBAAA,CAAA;;;;"}
1
+ {"version":3,"file":"PointCloudBackView.js","sources":["../../../src/components/pointCloudView/PointCloudBackView.tsx"],"sourcesContent":["/*\n * @Author: Laoluo luozefeng@sensetime.com\n * @Date: 2022-06-22 11:08:31\n * @LastEditors: Laoluo luozefeng@sensetime.com\n * @LastEditTime: 2022-07-08 11:08:02\n */\nimport { PointCloud, MathUtils, PointCloudAnnotation } from '@labelbee/lb-annotation';\nimport { getClassName } from '@/utils/dom';\nimport { PointCloudContainer } from './PointCloudLayout';\nimport React, { useEffect, useRef } from 'react';\nimport { PointCloudContext } from './PointCloudContext';\nimport { useSingleBox } from './hooks/useSingleBox';\nimport { EPerspectiveView, IPointCloudBox } from '@labelbee/lb-utils';\nimport { SizeInfoForView } from './PointCloudInfos';\nimport { connect } from 'react-redux';\nimport { aMapStateToProps, IAnnotationStateProps } from '@/store/annotation/map';\nimport { synchronizeSideView, synchronizeTopView } from './hooks/usePointCloudViews';\nimport useSize from '@/hooks/useSize';\nimport EmptyPage from './components/EmptyPage';\nimport { useTranslation } from 'react-i18next';\n\n/**\n * 统一一下,将其拓展为 二维转换为 三维坐标的转换\n * Get the offset from canvas2d-coordinate to world coordinate\n * @param currentPos\n * @param size\n * @param zoom\n * @returns\n */\nconst TransferCanvas2WorldOffset = (\n currentPos: { x: number; y: number },\n size: { width: number; height: number },\n zoom = 1,\n) => {\n const { width: w, height: h } = size;\n\n const canvasCenterPoint = {\n x: currentPos.x + (w * zoom) / 2,\n y: currentPos.y + (h * zoom) / 2,\n };\n\n const worldCenterPoint = {\n x: size.width / 2,\n y: size.height / 2,\n };\n\n return {\n offsetX: (worldCenterPoint.x - canvasCenterPoint.x) / zoom,\n offsetY: -(worldCenterPoint.y - canvasCenterPoint.y) / zoom,\n };\n};\nconst updateBackViewByCanvas2D = (\n currentPos: { x: number; y: number },\n zoom: number,\n size: { width: number; height: number },\n selectedPointCloudBox: IPointCloudBox,\n backPointCloud: PointCloud,\n) => {\n const { offsetX, offsetY } = TransferCanvas2WorldOffset(currentPos, size, zoom);\n backPointCloud.camera.zoom = zoom;\n if (currentPos) {\n const cos = Math.cos(selectedPointCloudBox.rotation);\n const sin = Math.sin(selectedPointCloudBox.rotation);\n const offsetXX = offsetX * cos;\n const offsetXY = offsetX * sin;\n const { x, y, z } = backPointCloud.initCameraPosition;\n backPointCloud.camera.position.set(x + offsetXY, y - offsetXX, z + offsetY);\n }\n backPointCloud.camera.updateProjectionMatrix();\n backPointCloud.render();\n};\n\nconst PointCloudSideView = ({ currentData }: IAnnotationStateProps) => {\n const ptCtx = React.useContext(PointCloudContext);\n const ref = useRef<HTMLDivElement>(null);\n const size = useSize(ref);\n const { updateSelectedBox, selectedBox } = useSingleBox();\n const { t } = useTranslation();\n\n useEffect(() => {\n if (ref.current) {\n const size = {\n width: ref.current.clientWidth,\n height: ref.current.clientHeight,\n };\n\n const pointCloudAnnotation = new PointCloudAnnotation({\n container: ref.current,\n size,\n polygonOperationProps: { showDirectionLine: false, forbidAddNew: true },\n });\n ptCtx.setBackViewInstance(pointCloudAnnotation);\n }\n }, []);\n\n useEffect(() => {\n // By the way as an initialization judgment\n if (!size || !ptCtx.backViewInstance) {\n return;\n }\n\n const {\n pointCloud2dOperation: backPointCloudPolygonOperation,\n pointCloudInstance: backPointCloud,\n } = ptCtx.backViewInstance;\n\n /**\n * Synchronized 3d point cloud view displacement operations\n *\n * Change Orthographic Camera size\n */\n backPointCloudPolygonOperation.singleOn('renderZoom', (zoom: number, currentPos: any) => {\n if (!ptCtx.selectedPointCloudBox) {\n return;\n }\n updateBackViewByCanvas2D(currentPos, zoom, size, ptCtx.selectedPointCloudBox, backPointCloud);\n });\n\n // Synchronized 3d point cloud view displacement operations\n backPointCloudPolygonOperation.singleOn('dragMove', ({ currentPos, zoom }: any) => {\n if (!ptCtx.selectedPointCloudBox) {\n return;\n }\n updateBackViewByCanvas2D(currentPos, zoom, size, ptCtx.selectedPointCloudBox, backPointCloud);\n });\n\n backPointCloudPolygonOperation.singleOn(\n 'updatePolygonByDrag',\n ({ newPolygon, originPolygon }: any) => {\n if (!ptCtx.selectedPointCloudBox || !ptCtx.mainViewInstance || !currentData.url) {\n return;\n }\n\n // Notice. The sort of polygon is important.\n const [point1, point2, point3] = newPolygon.pointList;\n const [op1, op2, op3] = originPolygon.pointList;\n\n // 2D centerPoint => 3D x & z\n const newCenterPoint = MathUtils.getLineCenterPoint([point1, point3]);\n const oldCenterPoint = MathUtils.getLineCenterPoint([op1, op3]);\n\n const offset = {\n x: newCenterPoint.x - oldCenterPoint.x,\n y: newCenterPoint.y - oldCenterPoint.y,\n };\n\n const offsetCenterPoint = {\n x: offset.x,\n y: 0, // Not be used.\n z: newCenterPoint.y - oldCenterPoint.y,\n };\n\n // 2D height => 3D depth\n const height = MathUtils.getLineLength(point1, point2);\n const oldHeight = MathUtils.getLineLength(op1, op2);\n const offsetHeight = height - oldHeight; // 3D depth\n\n // 2D width => 3D width\n const width = MathUtils.getLineLength(point2, point3);\n const oldWidth = MathUtils.getLineLength(op2, op3);\n const offsetWidth = width - oldWidth; // 3D width\n\n const { newBoxParams } = backPointCloud.getNewBoxByBackUpdate(\n offsetCenterPoint,\n offsetWidth,\n offsetHeight,\n ptCtx.selectedPointCloudBox,\n );\n\n synchronizeTopView(newBoxParams, newPolygon, ptCtx.topViewInstance, ptCtx.mainViewInstance);\n synchronizeSideView(newBoxParams, newPolygon, ptCtx.sideViewInstance, currentData.url);\n ptCtx.mainViewInstance.highlightOriginPointCloud(newBoxParams);\n updateSelectedBox(newBoxParams);\n },\n );\n }, [ptCtx, size]);\n\n useEffect(() => {\n // Update Size\n ptCtx?.backViewInstance?.initSize(size);\n }, [size]);\n\n return (\n <PointCloudContainer\n className={getClassName('point-cloud-container', 'back-view')}\n title={t('BackView')}\n toolbar={<SizeInfoForView perspectiveView={EPerspectiveView.Back} />}\n >\n <div className={getClassName('point-cloud-container', 'bottom-view-content')}>\n <div className={getClassName('point-cloud-container', 'core-instance')} ref={ref} />\n {!selectedBox && <EmptyPage />}\n </div>\n </PointCloudContainer>\n );\n};\n\nexport default connect(aMapStateToProps)(PointCloudSideView);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,0BAA6B,GAAA,CACjC,UACA,EAAA,IAAA,EACA,OAAO,CACJ,KAAA;AACH,EAAA,MAAM,CAAE,KAAA,EAAO,CAAG,EAAA,MAAA,EAAQ,CAAM,CAAA,GAAA,IAAA,CAAA;AAEhC,EAAA,MAAM,iBAAoB,GAAA;AAAA,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AA,CAAA;AAClF,MAAA,KAAA,CAAM,iBAAiB,yBAA0B,CAAA,YAAA,CAAA,CAAA;AACjD,MAAkB,iBAAA,CAAA,YAAA,CAAA,CAAA;AAAA,KAAA,CAAA,CAAA;AAAA,GAAA,EAGrB,CAAC,KAAO,EAAA,IAAA,CAAA,CAAA,CAAA;AAEX,EAAA,SAAA,CAAU,MAAM;AAjLlB,IAAA,IAAA,EAAA,CAAA;AAmLI,IAAO,CAAA,EAAA,GAAA,KAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,gBAAA,KAAP,mBAAyB,QAAS,CAAA,IAAA,CAAA,CAAA;AAAA,GAAA,EACjC,CAAC,IAAA,CAAA,CAAA,CAAA;AAEJ,EAAA,2CACG,mBAAD,EAAA;AAAA,IACE,SAAA,EAAW,aAAa,uBAAyB,EAAA,WAAA,CAAA;AAAA,IACjD,OAAO,CAAE,CAAA,UAAA,CAAA;AAAA,IACT,OAAA,sCAAU,eAAD,EAAA;AAAA,MAAiB,iBAAiB,gBAAiB,CAAA,IAAA;AAAA,KAAA,CAAA;AAAA,GAAA,sCAE3D,KAAD,EAAA;AAAA,IAAK,SAAA,EAAW,aAAa,uBAAyB,EAAA,qBAAA,CAAA;AAAA,GAAA,sCACnD,KAAD,EAAA;AAAA,IAAK,SAAA,EAAW,aAAa,uBAAyB,EAAA,eAAA,CAAA;AAAA,IAAkB,GAAA;AAAA,GACvE,CAAA,EAAA,CAAC,WAAe,oBAAA,KAAA,CAAA,aAAA,CAAC,SAAD,EAAA,IAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA;AAMzB,yBAAe,QAAQ,gBAAkB,CAAA,CAAA,kBAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- import{PointCloudUtils as b,EPerspectiveView as p}from"@labelbee/lb-utils";import t,{useState as m,useEffect as v}from"react";import{PointCloudContext as f}from"./PointCloudContext.js";import{UnitUtils as g}from"@labelbee/lb-annotation";import{useSingleBox as B}from"./hooks/useSingleBox.js";const i=2,C=({perspectiveView:a})=>{const{pointCloudBoxList:o,selectedID:u}=t.useContext(f),n=o.find(e=>e.id===u);if(u&&n){const{length:e,width:r,height:c}=b.transferBox2Kitti(n),d=a===p.Back?[{label:"\u5BBD",value:r},{label:"\u9AD8",value:c}]:[{label:"\u957F",value:e},{label:"\u5BBD",value:r}];return t.createElement(t.Fragment,null,d.map((s,l)=>t.createElement("span",{key:l,style:{marginRight:l===0?16:0,fontSize:12}},`${s.label}: ${s.value.toFixed(i)}`)))}return null},h=()=>{const a=t.useContext(f),{selectedBox:o}=B(),[u,n]=m([]);return v(()=>{var e;if(!o)return;const{length:r,width:c,height:d,rotation_y:s}=b.transferBox2Kitti(o.info);let l=[{label:"\u957F",value:r.toFixed(i)},{label:"\u5BBD",value:c.toFixed(i)},{label:"\u9AD8",value:d.toFixed(i)},{label:"\u671D\u5411\u89D2",value:g.rad2deg(s).toFixed(i)}];(e=a.mainViewInstance)==null||e.filterPointsByBox(o.info).then(x=>{if(!x){n(l);return}l.push({label:"\u70B9\u6570",value:`${x.num}`}),n(l)})},[o]),o?t.createElement("div",{style:{position:"absolute",color:"white",backgroundColor:"rgba(153, 153, 153, 0.3)",right:8,top:8,fontSize:12,padding:8,zIndex:20}},u.map(e=>t.createElement("div",{key:e.label},`${e.label}: ${e.value}`))):null},E=()=>t.useContext(f).valid===!1?t.createElement("div",{style:{position:"absolute",backgroundColor:"rgb(242, 101, 73)",color:"white",left:0,top:0,fontSize:20,padding:"8px 16px",zIndex:20}},"\u65E0\u6548"):null;export{h as BoxInfos,E as PointCloudValidity,C as SizeInfoForView};
1
+ import{PointCloudUtils as h,EPerspectiveView as v}from"@labelbee/lb-utils";import o,{useState as C,useEffect as B}from"react";import{PointCloudContext as g}from"./PointCloudContext.js";import{UnitUtils as y}from"@labelbee/lb-annotation";import{useSingleBox as E}from"./hooks/useSingleBox.js";import{useTranslation as m}from"react-i18next";const r=2,I=({perspectiveView:l})=>{const{pointCloudBoxList:e,selectedID:s}=o.useContext(g),i=e.find(a=>a.id===s),f=m(),{t}=f;if(s&&i){const{length:a,width:n,height:u}=h.transferBox2Kitti(i),x=l===v.Back?[{label:t("Width"),value:n},{label:t("Height"),value:u}]:[{label:t("Length"),value:a},{label:t("Height"),value:u}];return o.createElement(o.Fragment,null,x.map((c,d)=>o.createElement("span",{key:d,style:{marginRight:d===0?16:0,fontSize:12}},`${c.label}: ${c.value.toFixed(r)}`)))}return null},P=()=>{const l=o.useContext(g),{selectedBox:e}=E(),[s,i]=C([]),f=m(),{t,i18n:a}=f;return B(()=>{var n;if(!e)return;const{length:u,width:x,height:c,rotation_y:d}=h.transferBox2Kitti(e.info);let b=[{label:t("Length"),value:u.toFixed(r)},{label:t("Width"),value:x.toFixed(r)},{label:t("Height"),value:c.toFixed(r)},{label:t("Rotation_y"),value:y.rad2deg(d).toFixed(r)}];(n=l.mainViewInstance)==null||n.filterPointsByBox(e.info).then(p=>{if(!p){i(b);return}b.push({label:t("PointCount"),value:`${p.num}`}),i(b)})},[e,a.language]),e?o.createElement("div",{style:{position:"absolute",color:"white",backgroundColor:"rgba(153, 153, 153, 0.3)",right:8,top:8,fontSize:12,padding:8,zIndex:20}},s.map(n=>o.createElement("div",{key:n.label},`${n.label}: ${n.value}`))):null},S=()=>{const l=o.useContext(g),{t:e}=m();return l.valid===!1?o.createElement("div",{style:{position:"absolute",backgroundColor:"rgb(242, 101, 73)",color:"white",left:0,top:0,fontSize:20,padding:"8px 16px",zIndex:20}},e("Invalid")):null};export{P as BoxInfos,S as PointCloudValidity,I as SizeInfoForView};