@labelbee/lb-components 1.12.0-alpha.8 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var React__default=_interopDefaultLegacy(React);function getDefaultOrthographicParams(r){return{left:-r.width/2,right:r.width/2,top:r.height/2,bottom:-r.height/2,near:100,far:-100}}const PointCloudAnnotationView=r=>{const{src:l,result:o,size:i,isOrthographicCamera:u=!1,backgroundColor:f="#ccc"}=r;let c=React.useRef();const e=React.useRef(),d=React.useCallback(t=>{c.current=t},[]);return React.useEffect(()=>{let t={container:c.current,backgroundColor:f,isOrthographicCamera:u};u&&Object.assign(t,{orthographicParams:getDefaultOrthographicParams(i)});const n=new lbAnnotation.PointCloud(t);return e.current=n,()=>{var a;(a=e.current.renderer)==null||a.forceContextLoss()}},[]),React.useEffect(()=>{var t,n,a;e.current&&((t=e.current)==null||t.init(),(n=e.current)==null||n.initOrthographicCamera(getDefaultOrthographicParams(i)),(a=e.current)==null||a.render())},[i]),React.useEffect(()=>{var t;e.current&&l&&((t=e.current)==null||t.loadPCDFile(l))},[l]),React.useEffect(()=>(o&&lbUtils.PointCloudUtils.getBoxParamsFromResultList(o).forEach(n=>{var a;(a=e.current)==null||a.generateBox(n,n.id)}),()=>{var t;lbUtils.PointCloudUtils.getBoxParamsFromResultList(o).forEach(a=>{var s;(s=e.current)==null||s.removeObjectByName(a.id,"box")}),(t=e.current)==null||t.render()}),[o]),React__default.default.createElement("div",{style:i,ref:d})};module.exports=PointCloudAnnotationView;
1
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React);const PointCloudAnnotationView=o=>{const{src:l,result:n,size:i,isOrthographicCamera:u=!1,backgroundColor:d="#ccc"}=o;let c=React.useRef();const r=React.useRef(),f=React.useCallback(e=>{c.current=e},[]);return React.useEffect(()=>{let e={container:c.current,backgroundColor:d,isOrthographicCamera:u};u&&Object.assign(e,{orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(i)});const a=new lbAnnotation.PointCloud(e);return r.current=a,()=>{var t;(t=r.current.renderer)==null||t.forceContextLoss()}},[]),React.useEffect(()=>{var e,a,t;r.current&&((e=r.current)==null||e.init(),(a=r.current)==null||a.initOrthographicCamera(lbUtils.PointCloudUtils.getDefaultOrthographicParams(i)),(t=r.current)==null||t.render())},[i]),React.useEffect(()=>{var e;r.current&&l&&((e=r.current)==null||e.loadPCDFile(l))},[l]),React.useEffect(()=>(n&&lbUtils.PointCloudUtils.getBoxParamsFromResultList(n).forEach(a=>{var t;(t=r.current)==null||t.generateBox(a,a.id)}),()=>{var e;lbUtils.PointCloudUtils.getBoxParamsFromResultList(n).forEach(t=>{var s;(s=r.current)==null||s.removeObjectByName(t.id,"box")}),(e=r.current)==null||e.render()}),[n]),React__default.default.createElement("div",{style:i,ref:f})};module.exports=PointCloudAnnotationView;
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,n,e)=>n in t?__defProp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,__spreadValues=(t,n)=>{for(var e in n||(n={}))__hasOwnProp.call(n,e)&&__defNormalProp(t,e,n[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(n))__propIsEnum.call(n,e)&&__defNormalProp(t,e,n[e]);return t},__spreadProps=(t,n)=>__defProps(t,__getOwnPropDescs(n));const pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:n,setTarget3DView:e}=React.useContext(PointCloud3DContext),m=p=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",p)]:!0,active:n});return React__default.default.createElement("span",{onClick:()=>{e(lbUtils.EPerspectiveView[t])},className:m(t.toLocaleLowerCase())})},PointCloud3DSideBar=()=>{const{reset3DView:t,followTopView:n}=React.useContext(PointCloud3DContext),{t:e}=reactI18next.useTranslation();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(antd.Tooltip,{title:e("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{n()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{t()},className:dom.getClassName("point-cloud-3d-view","reset")}))},PointCloud3D=({currentData:t,config:n})=>{const e=React.useContext(PointCloudContext.PointCloudContext),[m,p]=React.useState(!0),c=React.useRef(null),{initPointCloud3d:w}=usePointCloudViews.usePointCloudViews(),s=useSize(c),{t:C}=reactI18next.useTranslation();React.useEffect(()=>{!e.mainViewInstance||w==null||w(s)},[s]);const{selectedBox:u}=useSingleBox.useSingleBox(),{selectedSphere:d}=useSphere.useSphere(),v=o=>{var a,i;const r=u==null?void 0:u.info;if(r){const l=__spreadValues({},r.center);l.x=l.x-.01,l.z=10;const f=o===lbUtils.EPerspectiveView.Top;(a=e.mainViewInstance)==null||a.updateCameraByBox(r,o,f?l:void 0)}d&&((i=e.mainViewInstance)==null||i.updateCameraBySphere(d,o))},V=()=>{var o;(o=e.mainViewInstance)==null||o.resetCamera()},P=()=>{var o,a;const i=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance.camera;i&&((a=e.mainViewInstance)==null||a.applyCameraTarget(i))};React.useEffect(()=>{if(c.current&&(t==null?void 0:t.url)){let o=e.mainViewInstance;if(!o&&s.width){const a={left:-s.width/2,right:s.width/2,top:s.height/2,bottom:-s.height/2,near:100,far:-100};o=new lbAnnotation.PointCloud({container:c.current,isOrthographicCamera:!0,orthographicParams:a,config:n}),e.setMainViewInstance(o)}}},[s]),React.useEffect(()=>{var o;if(c.current&&(t==null?void 0:t.url)&&t.result&&e.mainViewInstance){let a=e.mainViewInstance;const i=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t.result);i.forEach(r=>{var l;const f=(l=lbUtils.toolStyleConverter.getColorFromConfig({attribute:r.attribute},__spreadProps(__spreadValues({},n),{attributeConfigurable:!0}),{}))==null?void 0:l.hex;a==null||a.generateBox(r,f)}),e.setPointCloudResult(i),e.setPointCloudValid((o=index.jsonParser(t.result))==null?void 0:o.valid)}},[t,e.mainViewInstance]),React.useEffect(()=>{var o,a,i,r;if(u){v(lbUtils.EPerspectiveView.Top);const l=(i=(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?i:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(l)}},[u]),React.useEffect(()=>{var o,a,i,r;if(d){v(lbUtils.EPerspectiveView.Top);const l=(i=(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?i:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(l)}},[d]);const _=React.useMemo(()=>({reset3DView:V,setTarget3DView:v,isActive:!!u,followTopView:P}),[u,e.mainViewInstance]),g=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:o=>{var a;(a=e.mainViewInstance)==null||a.updatePointSize({customSize:o})}}),React__default.default.createElement("span",{style:{marginRight:8}},C("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:m,onChange:o=>{var a;p(o),(a=e.mainViewInstance)==null||a.setShowDirection(o)}}));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-3d-container"),title:C("3DView"),toolbar:g},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},React__default.default.createElement(PointCloud3DContext.Provider,{value:_},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:c})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
1
+ "use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,a,e)=>a in t?__defProp(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e,__spreadValues=(t,a)=>{for(var e in a||(a={}))__hasOwnProp.call(a,e)&&__defNormalProp(t,e,a[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(a))__propIsEnum.call(a,e)&&__defNormalProp(t,e,a[e]);return t},__spreadProps=(t,a)=>__defProps(t,__getOwnPropDescs(a));const pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:a,setTarget3DView:e}=React.useContext(PointCloud3DContext),m=p=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",p)]:!0,active:a});return React__default.default.createElement("span",{onClick:()=>{e(lbUtils.EPerspectiveView[t])},className:m(t.toLocaleLowerCase())})},PointCloud3DSideBar=()=>{const{reset3DView:t,followTopView:a}=React.useContext(PointCloud3DContext),{t:e}=reactI18next.useTranslation();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(antd.Tooltip,{title:e("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{a()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{t()},className:dom.getClassName("point-cloud-3d-view","reset")}))},PointCloud3D=({currentData:t,config:a})=>{const e=React.useContext(PointCloudContext.PointCloudContext),[m,p]=React.useState(!0),u=React.useRef(null),{initPointCloud3d:w}=usePointCloudViews.usePointCloudViews(),c=useSize(u),{t:C}=reactI18next.useTranslation();React.useEffect(()=>{!e.mainViewInstance||w==null||w(c)},[c]);const{selectedBox:s}=useSingleBox.useSingleBox(),{selectedSphere:d}=useSphere.useSphere(),v=o=>{var n,i;const r=s==null?void 0:s.info;if(r){const l=__spreadValues({},r.center);l.x=l.x-.01,l.z=10;const f=o===lbUtils.EPerspectiveView.Top;(n=e.mainViewInstance)==null||n.updateCameraByBox(r,o,f?l:void 0)}d&&((i=e.mainViewInstance)==null||i.updateCameraBySphere(d,o))},V=()=>{var o;(o=e.mainViewInstance)==null||o.resetCamera()},P=()=>{var o,n;const i=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance.camera;i&&((n=e.mainViewInstance)==null||n.applyCameraTarget(i))};React.useEffect(()=>{if(u.current&&(t==null?void 0:t.url)){let o=e.mainViewInstance;!o&&c.width&&(o=new lbAnnotation.PointCloud({container:u.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(c),config:a}),e.setMainViewInstance(o))}},[c,t]),React.useEffect(()=>{var o;if(u.current&&(t==null?void 0:t.url)&&t.result&&e.mainViewInstance){let n=e.mainViewInstance;const i=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t.result);i.forEach(r=>{var l;const f=(l=lbUtils.toolStyleConverter.getColorFromConfig({attribute:r.attribute},__spreadProps(__spreadValues({},a),{attributeConfigurable:!0}),{}))==null?void 0:l.hex;n==null||n.generateBox(r,f)}),e.setPointCloudResult(i),e.setPointCloudValid((o=index.jsonParser(t.result))==null?void 0:o.valid)}},[t,e.mainViewInstance]),React.useEffect(()=>{var o,n,i,r;if(s){v(lbUtils.EPerspectiveView.Top);const l=(i=(n=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:n.camera.zoom)!=null?i:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(l)}},[s]),React.useEffect(()=>{var o,n,i,r;if(d){v(lbUtils.EPerspectiveView.Top);const l=(i=(n=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:n.camera.zoom)!=null?i:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(l)}},[d]);const _=React.useMemo(()=>({reset3DView:V,setTarget3DView:v,isActive:!!s,followTopView:P}),[s,e.mainViewInstance]),g=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:o=>{var n;(n=e.mainViewInstance)==null||n.updatePointSize({customSize:o})}}),React__default.default.createElement("span",{style:{marginRight:8}},C("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:m,onChange:o=>{var n;p(o),(n=e.mainViewInstance)==null||n.setShowDirection(o)}}));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-3d-container"),title:C("3DView"),toolbar:g},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},React__default.default.createElement(PointCloud3DContext.Provider,{value:_},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:u})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
@@ -1 +1 @@
1
- "use strict";var useSize=require("../../hooks/useSize.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),React=require("react"),reactRedux=require("react-redux"),PointCloudContext=require("./PointCloudContext.js"),lbUtils=require("@labelbee/lb-utils");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const PointCloudSegment=({currentData:e,config:a,checkMode:c})=>{var o,u;const n=React.useRef(null),{setPtSegmentInstance:d,setDefaultAttribute:v,ptSegmentInstance:r}=React.useContext(PointCloudContext.PointCloudContext),t=useSize(n),i=(u=(o=a==null?void 0:a.attributeList)==null?void 0:o[0])==null?void 0:u.value;return React.useEffect(()=>{var l;if(!(t==null?void 0:t.width)||!n.current||r)return;const f={left:-t.width/2,right:t.width/2,top:t.height/2,bottom:-t.height/2,near:1e3,far:-1e3},s=new lbAnnotation.PointCloud({container:n.current,isOrthographicCamera:!0,isSegment:!0,orthographicParams:f,config:a,checkMode:c});(l=s.store)==null||l.setAttribute(i),v(i),d(s)},[t]),React.useEffect(()=>{r&&(r.initRenderer(),r.initOrthographicCamera(lbUtils.PointCloudUtils.getDefaultOrthographic(t)),r.render())},[t]),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-layout"),ref:n})};var PointCloudSegment$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudSegment);module.exports=PointCloudSegment$1;
1
+ "use strict";var useSize=require("../../hooks/useSize.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),React=require("react"),reactRedux=require("react-redux"),PointCloudContext=require("./PointCloudContext.js"),lbUtils=require("@labelbee/lb-utils");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const PointCloudSegment=({currentData:e,config:n,checkMode:c})=>{var o,u;const a=React.useRef(null),{setPtSegmentInstance:d,setDefaultAttribute:m,ptSegmentInstance:r}=React.useContext(PointCloudContext.PointCloudContext),t=useSize(a),i=(u=(o=n==null?void 0:n.attributeList)==null?void 0:o[0])==null?void 0:u.value;return React.useEffect(()=>{var l;if(!(t==null?void 0:t.width)||!a.current||r)return;const s=new lbAnnotation.PointCloud({container:a.current,isOrthographicCamera:!0,isSegment:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(t),config:n,checkMode:c});(l=s.store)==null||l.setAttribute(i),m(i),d(s)},[t]),React.useEffect(()=>{r&&(r.initRenderer(),r.initOrthographicCamera(lbUtils.PointCloudUtils.getDefaultOrthographicParams(t)),r.render())},[t]),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-layout"),ref:a})};var PointCloudSegment$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudSegment);module.exports=PointCloudSegment$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"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,o,i)=>o in e?__defProp(e,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[o]=i,__spreadValues=(e,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(e,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(e,i,o[i]);return e},__spreadProps=(e,o)=>__defProps(e,__getOwnPropDescs(o)),__async=(e,o,i)=>new Promise((l,t)=>{var a=d=>{try{r(i.next(d))}catch(g){t(g)}},p=d=>{try{r(i.throw(d))}catch(g){t(g)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((i=i.apply(e,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,o,i,l,t)=>{const{x:a,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(e,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:a,y:p,z:r},id:e.id},g=l?__spreadValues(__spreadValues({},l),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},topViewPolygon2PointCloud=(e,o,i,l,t,a)=>{let p=e.pointList.map(v=>lbUtils.PointCloudUtils.transferCanvas2World(v,o)),r=0,d=1,g={};if(i){const v=i.getSensesPointZAxisInPolygon(p,void 0,a);a&&v.fittedCoordinates.length>0&&(p=v.fittedCoordinates),r=(v.maxZ+v.minZ)/2,d=v.maxZ-v.minZ,g={count:v.zCount}}const[f,x,V]=p,b=lbAnnotation.MathUtils.getLineCenterPoint([f,V]),I=lbAnnotation.MathUtils.getLineLength(f,x),_=lbAnnotation.MathUtils.getLineLength(x,V),D=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);l&&(r=l.center.z,d=l.depth);const U={center:{x:b.x,y:b.y,z:r},width:_,height:I,depth:d,rotation:D,id:e.id},S=__spreadValues(l?__spreadValues(__spreadValues({},l),U):__spreadProps(__spreadValues({},U),{attribute:"",valid:!0}),g);t&&Object.assign(S,t);const O=p.map(v=>lbUtils.PointCloudUtils.transferWorld2Canvas(v,o));return{boxParams:S,newPointList:O}},sideViewPoint2PointCloud=(e,o,i)=>{const l={x:e.x-o.x,y:e.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(e,o,i,l)=>{const[t,a,p]=e.pointList,[r,d,g]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([t,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,g]),b={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},I=lbAnnotation.MathUtils.getLineLength(t,a),_=lbAnnotation.MathUtils.getLineLength(r,d),D=I-_,U=lbAnnotation.MathUtils.getLineLength(a,p),S=lbAnnotation.MathUtils.getLineLength(d,g),O=U-S,{newBoxParams:v}=l.getNewBoxBySideUpdate(b,O,D,i);return v},backViewPoint2PointCloud=(e,o,i)=>{const l={x:e.x-o.x,y:e.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(e,o,i,l)=>{const[t,a,p]=e.pointList,[r,d,g]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([t,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,g]),b={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},I=lbAnnotation.MathUtils.getLineLength(t,a),_=lbAnnotation.MathUtils.getLineLength(r,d),D=I-_,U=lbAnnotation.MathUtils.getLineLength(a,p),S=lbAnnotation.MathUtils.getLineLength(d,g),O=U-S;let{newBoxParams:v}=l.getNewBoxByBackUpdate(b,O,D,i);return v},syncSideViewByPoint=(e,o,i,l,t)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(d);const{point2d:g,zoom:f}=r.getSphereSidePoint2DCoordinate(e);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),g),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(e,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:o.id,valid:e.valid,pointList:r,textAttribute:"",isRect:!0,attribute:e.attribute}],o.id)},syncBackViewByPoint=(e,o,i,l,t)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(d);const{point2d:g,zoom:f}=r.getSphereBackPoint2DCoordinate(e);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),g),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(e,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:o.id,valid:e.valid,pointList:r,textAttribute:"",isRect:!0,attribute:e.attribute}],o.id)},syncTopViewByPoint=(e,o,i,l)=>{if(!i||!l)return;l.generateSphere(e),l.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=i,{point2d:p}=a.getSphereTopPoint2DCoordinate(e),r=[...t.pointList].map(d=>d.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:e.valid,textAttribute:"",attribute:e.attribute}):d);t.setResult(r),t.setSelectedID(o.id)},synchronizeTopView=(e,o,i,l)=>{var t;if(!i||!l)return;l.generateBox(e,o.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(e),d=[...a.polygonList],g=d.find(f=>f.id===o.id);g?g.pointList=r:d.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(t=e.valid)!=null?t:!0}),a.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:g,pointCloudSphereList:f,hideAttributes:x}=e,{addHistory:V,initHistory:b,pushHistoryUnderUpdatePolygon:I,pushHistoryUnderUpdateLine:_}=useHistory.useHistory(),{selectedPolygon:D}=usePolygon.usePolygon(),{updateSelectedBox:U,updateSelectedBoxes:S,getPointCloudByID:O}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:v,updatePointCloudSphere:H,selectedSphere:z}=useSphere.useSphere(),{currentData:A,config:L}=ctx.useSelector(n=>{const{stepList:s,step:P,imgList:c,imgIndex:u}=n.annotation;return{currentData:c[u],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,s).config)}}),F=ctx.useDispatch(),{selectedBox:k}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),N=k==null?void 0:k.info;if(!o||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},X=n=>{t==null||t.generateSphere(n),t==null||t.controls.update(),t==null||t.render()},Y=({newPoint:n,size:s,zoom:P,trackConfigurable:c})=>{var u;const C={attribute:(u=o.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const h=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const y=p(h);M(PointCloudView.Top,n,h,P,y,L),V({newSphereParams:h})},J=({polygon:n,size:s,imgList:P,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var h,y;const m={attribute:(h=o.toolInstance.defaultAttribute)!=null?h:""};c===!0&&Object.assign(m,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:f})});const j=o==null?void 0:o.toolInstance,w=__spreadValues({},n),{boxParams:B,newPointList:T}=topViewPolygon2PointCloud(w,s,E,void 0,m,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),j.deletePolygon(B.id);return}C&&(T==null?void 0:T.length)&&(w.pointList=T);const rt=x.includes(w.attribute),q=a(B),lt=(y=e==null?void 0:e.polygonList)!=null?y:[];o==null||o.updatePolygonList(q!=null?q:[],lt),rt?r([]):(r(B.id),j.selection.setSelectedIDs(w.id),R(PointCloudView.Top,w,B,u,q),C&&synchronizeTopView(B,w,o,t)),V({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:c})=>{var u;const C=o==null?void 0:o.toolInstance;if(!(d.length===0||!C)){if(n||(k==null?void 0:k.info)){const h=n!=null?n:k==null?void 0:k.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const y=C.selectedPolygon;if(d.length===1&&h){R(PointCloudView.Top,y,h,void 0,s);return}}if((P||z)&&d.length===1){const h=P!=null?P:z;C.setSelectedID(d[0]);const y=C.selectedPoint;h&&M(PointCloudView.Top,y,h,void 0,c,L)}}},Z=(n,s,P)=>{if(N){let c,u;switch(P){case PointCloudView.Back:c=backViewPolygon2PointCloud;break;case PointCloudView.Side:c=sideViewPolygon2PointCloud;break;default:c=sideViewPolygon2PointCloud;break}if(u=c(n,s,N,i.pointCloudInstance),t){const{count:h}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=__spreadProps(__spreadValues({},u),{count:h})}const C=U(u);return R(P,n,u,void 0,C),C}},W=(n,s,P)=>{if(z){let c,u;switch(P){case PointCloudView.Back:c=backViewPoint2PointCloud;break;case PointCloudView.Side:c=sideViewPoint2PointCloud;break;default:c=sideViewPoint2PointCloud;break}u=c(n,s,z);const C=H(u);return M(P,n,u,void 0,C,L),C}},$=(n,s)=>{W(n,s,PointCloudView.Side)},tt=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},ot=(n,s)=>{Z(n,s,PointCloudView.Back)},it=(n,s)=>{_(n)},nt=(n,s)=>{const P=v(n.id),c=topViewPoint2PointCloud(n,s,E,P),u=H(c);M(PointCloudView.Top,n,c,void 0,u,L)},st=(n,s)=>{if(D){const c=n[0].newPolygon;c.pointList=c.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,s)),I(n[0].newPolygon);return}const P=n.map(({newPolygon:c})=>{const u=O(c.id),{boxParams:C}=topViewPolygon2PointCloud(c,s,o.pointCloudInstance,u);return C});if(P.length===1){const{newPolygon:c}=n[0],u=S(P);R(PointCloudView.Top,c,P[0],void 0,u)}else{const c=S(P);c&&e.syncAllViewPointCloudColor(c)}},M=(n,s,P,c,u,C)=>__async(void 0,null,function*(){const h=A==null?void 0:A.url,y={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,h,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,h,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,t)}};Object.keys(y).forEach(m=>{m!==n&&y[m]()}),c&&(t==null||t.updateCameraZoom(c)),X(P)}),R=(n,s,P,c,u)=>__async(void 0,null,function*(){const C=A==null?void 0:A.url;u&&(yield e.syncAllViewPointCloudColor(u));const h={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,t)}};Object.keys(h).forEach(y=>{y!==n&&h[y]()}),c&&(t==null||t.updateCameraZoom(c)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),t==null||t.generateBoxes(n)},initPointCloud3d:n=>{if(!t)return;const s={left:-n.width/2,right:n.width/2,top:n.height/2,bottom:-n.height/2,near:100,far:-100};t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=A){var P,c,u,C,h,y;if(!(s==null?void 0:s.url)||!t)return;actionCreators.SetPointCloudLoading(F,!0),yield t.loadPCDFile(s.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let m=[],j=[],w=[],B=[];s.result&&(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),w=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),j=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(m),t==null||t.generateSpheres(B),e.syncAllViewPointCloudColor(m)),b({pointCloudBoxList:m,polygonList:w,lineList:j,pointCloudSphereList:B}),t.updateTopCamera();const T=(u=(c=index.jsonParser(s.result))==null?void 0:c.valid)!=null?u:!0;e.setPointCloudValid(T),(C=e.sideViewInstance)==null||C.clearAllData(),(h=e.backViewInstance)==null||h.clearAllData(),o.updateData(s.url,s.result,{radius:(y=L==null?void 0:L.radius)!=null?y:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(F,!1)})}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,o,i)=>o in e?__defProp(e,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[o]=i,__spreadValues=(e,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(e,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(e,i,o[i]);return e},__spreadProps=(e,o)=>__defProps(e,__getOwnPropDescs(o)),__async=(e,o,i)=>new Promise((l,t)=>{var a=d=>{try{r(i.next(d))}catch(g){t(g)}},p=d=>{try{r(i.throw(d))}catch(g){t(g)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((i=i.apply(e,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,o,i,l,t)=>{const{x:a,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(e,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:a,y:p,z:r},id:e.id},g=l?__spreadValues(__spreadValues({},l),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},topViewPolygon2PointCloud=(e,o,i,l,t,a)=>{let p=e.pointList.map(v=>lbUtils.PointCloudUtils.transferCanvas2World(v,o)),r=0,d=1,g={};if(i){const v=i.getSensesPointZAxisInPolygon(p,void 0,a);a&&v.fittedCoordinates.length>0&&(p=v.fittedCoordinates),r=(v.maxZ+v.minZ)/2,d=v.maxZ-v.minZ,g={count:v.zCount}}const[f,x,V]=p,U=lbAnnotation.MathUtils.getLineCenterPoint([f,V]),I=lbAnnotation.MathUtils.getLineLength(f,x),_=lbAnnotation.MathUtils.getLineLength(x,V),D=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);l&&(r=l.center.z,d=l.depth);const b={center:{x:U.x,y:U.y,z:r},width:_,height:I,depth:d,rotation:D,id:e.id},S=__spreadValues(l?__spreadValues(__spreadValues({},l),b):__spreadProps(__spreadValues({},b),{attribute:"",valid:!0}),g);t&&Object.assign(S,t);const O=p.map(v=>lbUtils.PointCloudUtils.transferWorld2Canvas(v,o));return{boxParams:S,newPointList:O}},sideViewPoint2PointCloud=(e,o,i)=>{const l={x:e.x-o.x,y:e.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(e,o,i,l)=>{const[t,a,p]=e.pointList,[r,d,g]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([t,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,g]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},I=lbAnnotation.MathUtils.getLineLength(t,a),_=lbAnnotation.MathUtils.getLineLength(r,d),D=I-_,b=lbAnnotation.MathUtils.getLineLength(a,p),S=lbAnnotation.MathUtils.getLineLength(d,g),O=b-S,{newBoxParams:v}=l.getNewBoxBySideUpdate(U,O,D,i);return v},backViewPoint2PointCloud=(e,o,i)=>{const l={x:e.x-o.x,y:e.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(e,o,i,l)=>{const[t,a,p]=e.pointList,[r,d,g]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([t,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,g]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},I=lbAnnotation.MathUtils.getLineLength(t,a),_=lbAnnotation.MathUtils.getLineLength(r,d),D=I-_,b=lbAnnotation.MathUtils.getLineLength(a,p),S=lbAnnotation.MathUtils.getLineLength(d,g),O=b-S;let{newBoxParams:v}=l.getNewBoxByBackUpdate(U,O,D,i);return v},syncSideViewByPoint=(e,o,i,l,t)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(d);const{point2d:g,zoom:f}=r.getSphereSidePoint2DCoordinate(e);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),g),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(e,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:o.id,valid:e.valid,pointList:r,textAttribute:"",isRect:!0,attribute:e.attribute}],o.id)},syncBackViewByPoint=(e,o,i,l,t)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(d);const{point2d:g,zoom:f}=r.getSphereBackPoint2DCoordinate(e);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),g),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(e,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:o.id,valid:e.valid,pointList:r,textAttribute:"",isRect:!0,attribute:e.attribute}],o.id)},syncTopViewByPoint=(e,o,i,l)=>{if(!i||!l)return;l.generateSphere(e),l.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=i,{point2d:p}=a.getSphereTopPoint2DCoordinate(e),r=[...t.pointList].map(d=>d.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:e.valid,textAttribute:"",attribute:e.attribute}):d);t.setResult(r),t.setSelectedID(o.id)},synchronizeTopView=(e,o,i,l)=>{var t;if(!i||!l)return;l.generateBox(e,o.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(e),d=[...a.polygonList],g=d.find(f=>f.id===o.id);g?g.pointList=r:d.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(t=e.valid)!=null?t:!0}),a.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:g,pointCloudSphereList:f,hideAttributes:x}=e,{addHistory:V,initHistory:U,pushHistoryUnderUpdatePolygon:I,pushHistoryUnderUpdateLine:_}=useHistory.useHistory(),{selectedPolygon:D}=usePolygon.usePolygon(),{updateSelectedBox:b,updateSelectedBoxes:S,getPointCloudByID:O}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:v,updatePointCloudSphere:H,selectedSphere:T}=useSphere.useSphere(),{currentData:A,config:L}=ctx.useSelector(n=>{const{stepList:s,step:P,imgList:c,imgIndex:u}=n.annotation;return{currentData:c[u],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,s).config)}}),F=ctx.useDispatch(),{selectedBox:k}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),N=k==null?void 0:k.info;if(!o||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},X=n=>{t==null||t.generateSphere(n),t==null||t.controls.update(),t==null||t.render()},Y=({newPoint:n,size:s,zoom:P,trackConfigurable:c})=>{var u;const C={attribute:(u=o.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const h=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const y=p(h);M(PointCloudView.Top,n,h,P,y,L),V({newSphereParams:h})},J=({polygon:n,size:s,imgList:P,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var h,y;const m={attribute:(h=o.toolInstance.defaultAttribute)!=null?h:""};c===!0&&Object.assign(m,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:f})});const z=o==null?void 0:o.toolInstance,w=__spreadValues({},n),{boxParams:B,newPointList:j}=topViewPolygon2PointCloud(w,s,E,void 0,m,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),z.deletePolygon(B.id);return}C&&(j==null?void 0:j.length)&&(w.pointList=j);const rt=x.includes(w.attribute),q=a(B),lt=(y=e==null?void 0:e.polygonList)!=null?y:[];o==null||o.updatePolygonList(q!=null?q:[],lt),rt?r([]):(r(B.id),z.selection.setSelectedIDs(w.id),R(PointCloudView.Top,w,B,u,q),C&&synchronizeTopView(B,w,o,t)),V({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:c})=>{var u;const C=o==null?void 0:o.toolInstance;if(!(d.length===0||!C)){if(n||(k==null?void 0:k.info)){const h=n!=null?n:k==null?void 0:k.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const y=C.selectedPolygon;if(d.length===1&&h){R(PointCloudView.Top,y,h,void 0,s);return}}if((P||T)&&d.length===1){const h=P!=null?P:T;C.setSelectedID(d[0]);const y=C.selectedPoint;h&&M(PointCloudView.Top,y,h,void 0,c,L)}}},Z=(n,s,P)=>{if(N){let c,u;switch(P){case PointCloudView.Back:c=backViewPolygon2PointCloud;break;case PointCloudView.Side:c=sideViewPolygon2PointCloud;break;default:c=sideViewPolygon2PointCloud;break}if(u=c(n,s,N,i.pointCloudInstance),t){const{count:h}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=__spreadProps(__spreadValues({},u),{count:h})}const C=b(u);return R(P,n,u,void 0,C),C}},W=(n,s,P)=>{if(T){let c,u;switch(P){case PointCloudView.Back:c=backViewPoint2PointCloud;break;case PointCloudView.Side:c=sideViewPoint2PointCloud;break;default:c=sideViewPoint2PointCloud;break}u=c(n,s,T);const C=H(u);return M(P,n,u,void 0,C,L),C}},$=(n,s)=>{W(n,s,PointCloudView.Side)},tt=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},ot=(n,s)=>{Z(n,s,PointCloudView.Back)},it=(n,s)=>{_(n)},nt=(n,s)=>{const P=v(n.id),c=topViewPoint2PointCloud(n,s,E,P),u=H(c);M(PointCloudView.Top,n,c,void 0,u,L)},st=(n,s)=>{if(D){const c=n[0].newPolygon;c.pointList=c.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,s)),I(n[0].newPolygon);return}const P=n.map(({newPolygon:c})=>{const u=O(c.id),{boxParams:C}=topViewPolygon2PointCloud(c,s,o.pointCloudInstance,u);return C});if(P.length===1){const{newPolygon:c}=n[0],u=S(P);R(PointCloudView.Top,c,P[0],void 0,u)}else{const c=S(P);c&&e.syncAllViewPointCloudColor(c)}},M=(n,s,P,c,u,C)=>__async(void 0,null,function*(){const h=A==null?void 0:A.url,y={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,h,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,h,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,t)}};Object.keys(y).forEach(m=>{m!==n&&y[m]()}),c&&(t==null||t.updateCameraZoom(c)),X(P)}),R=(n,s,P,c,u)=>__async(void 0,null,function*(){const C=A==null?void 0:A.url;u&&(yield e.syncAllViewPointCloudColor(u));const h={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,t)}};Object.keys(h).forEach(y=>{y!==n&&h[y]()}),c&&(t==null||t.updateCameraZoom(c)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),t==null||t.generateBoxes(n)},initPointCloud3d:n=>{if(!t)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=A){var P,c,u,C,h,y;if(!(s==null?void 0:s.url)||!t)return;actionCreators.SetPointCloudLoading(F,!0),yield t.loadPCDFile(s.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let m=[],z=[],w=[],B=[];s.result&&(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),w=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),z=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(m),t==null||t.generateSpheres(B),e.syncAllViewPointCloudColor(m)),U({pointCloudBoxList:m,polygonList:w,lineList:z,pointCloudSphereList:B}),t.updateTopCamera();const j=(u=(c=index.jsonParser(s.result))==null?void 0:c.valid)!=null?u:!0;e.setPointCloudValid(j),(C=e.sideViewInstance)==null||C.clearAllData(),(h=e.backViewInstance)==null||h.clearAllData(),o.updateData(s.url,s.result,{radius:(y=L==null?void 0:L.radius)!=null?y:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(F,!1)})}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
@@ -1 +1 @@
1
- "use strict";var classNames=require("classnames"),React=require("react"),reactI18next=require("react-i18next"),reactRedux=require("react-redux"),PointCloudContext=require("../../pointCloudView/PointCloudContext.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),ctx=require("../../../store/ctx.js"),dom=require("../../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),util=require("./util.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,a)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,__spreadValues=(e,t)=>{for(var a in t||(t={}))__hasOwnProp.call(t,a)&&__defNormalProp(e,a,t[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(t))__propIsEnum.call(t,a)&&__defNormalProp(e,a,t[a]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,a)=>new Promise((c,n)=>{var o=l=>{try{i(a.next(l))}catch(s){n(s)}},r=l=>{try{i(a.throw(l))}catch(s){n(s)}},i=l=>l.done?c(l.value):Promise.resolve(l.value).then(o,r);i((a=a.apply(e,t)).next())});const PreviewResult=e=>{const{predictionResult:t,predictionResultVisible:a,imgList:c}=e,[n,o]=React.useState([]),r=ctx.useDispatch(),{t:i}=reactI18next.useTranslation(),l=()=>{actionCreators.SetPredictResultVisible(r,!1),actionCreators.SetPredictResult(r,[]),o([])},s=()=>__async(void 0,null,function*(){actionCreators.SetPointCloudLoading(r,!0),yield r(actionCreators.BatchUpdateImgListResultByPredictResult()),actionCreators.SetPointCloudLoading(r,!1),l()});return a?React__default.default.createElement(React__default.default.Fragment,null,n.length>0&&React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","bar")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","title")},React__default.default.createElement("div",null,i("ComplementaryTrackingPrediction"),n.length>0?`\uFF08${n.length}\uFF09`:""),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","option")},React__default.default.createElement("div",{className:classNames__default.default([dom.getClassName("point-cloud-predict-tracking-container","cancelOption"),dom.getClassName("point-cloud-predict-tracking-container","button")]),onClick:l},i("Cancel")),React__default.default.createElement("div",{className:classNames__default.default([dom.getClassName("point-cloud-predict-tracking-container","okOption"),dom.getClassName("point-cloud-predict-tracking-container","button")]),onClick:s},i("Apply")))),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","content")},React__default.default.createElement(Result,{list:n})))),t.length>0&&React__default.default.createElement(GenerateViewsDataUrl,{result:t,imgList:c,setList:o})):null},Result=e=>{const{list:t}=e,{t:a}=reactI18next.useTranslation(),c=[a("TopView"),a("SideView"),a("BackView")];return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","left")},c.map(n=>React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","title"),key:n},n))),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","right")},t.map(n=>React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","item"),key:n.id},util.views.map(o=>{const r=n[o];return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","view"),key:`${n.id}-${o}`},React__default.default.createElement("img",{src:r}))})))))},GenerateViewsDataUrl=e=>{const t=React__default.default.useContext(PointCloudContext.PointCloudContext),a=ctx.useDispatch(),{result:c,imgList:n,setList:o}=e,r=React.useRef(null),i={width:600,height:600};return React.useEffect(()=>{(()=>__async(void 0,null,function*(){var s,f,g,v,C,h;const p=(s=t.mainViewInstance)==null?void 0:s.config;if(p&&r.current){const P={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:200,far:-200},u=new lbAnnotation.PointCloud({container:r.current,isOrthographicCamera:!0,orthographicParams:P,config:p});u.setShowDirection(!1);for(const d of c){const{index:m}=d,y=n[m].url?n[m].url:(C=(v=(g=(f=n[m])==null?void 0:f.webPointCloudFile)==null?void 0:g.lidar)==null?void 0:v.url)!=null?C:"";yield u.loadPCDFileByBox(y,d,{width:2,height:2,depth:2}),yield u.updateCameraZoom(t.zoom);const N=(h=lbUtils.toolStyleConverter.getColorFromConfig({attribute:d.attribute},__spreadProps(__spreadValues({},p),{attributeConfigurable:!0}),{}))==null?void 0:h.fill;u.generateBox(d,N),yield util.sleep(500),yield util.getViewsDataUrl(u,d,t.zoom),yield u.removeObjectByName(d.id,"box"),yield u.clearPointCloudAndRender()}o(c),actionCreators.SetPointCloudLoading(a,!1)}}))()},[]),React__default.default.createElement("div",{style:i,ref:r,className:"generate-view"})},mapStateToProps=e=>({predictionResult:e.annotation.predictionResult,predictionResultVisible:e.annotation.predictionResultVisible,imgList:e.annotation.imgList});var PreviewResult$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(PreviewResult);module.exports=PreviewResult$1;
1
+ "use strict";var classNames=require("classnames"),React=require("react"),reactI18next=require("react-i18next"),reactRedux=require("react-redux"),PointCloudContext=require("../../pointCloudView/PointCloudContext.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),ctx=require("../../../store/ctx.js"),dom=require("../../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),util=require("./util.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,a)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,__spreadValues=(e,t)=>{for(var a in t||(t={}))__hasOwnProp.call(t,a)&&__defNormalProp(e,a,t[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(t))__propIsEnum.call(t,a)&&__defNormalProp(e,a,t[a]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,a)=>new Promise((c,n)=>{var o=i=>{try{l(a.next(i))}catch(s){n(s)}},r=i=>{try{l(a.throw(i))}catch(s){n(s)}},l=i=>i.done?c(i.value):Promise.resolve(i.value).then(o,r);l((a=a.apply(e,t)).next())});const PreviewResult=e=>{const{predictionResult:t,predictionResultVisible:a,imgList:c}=e,[n,o]=React.useState([]),r=ctx.useDispatch(),{t:l}=reactI18next.useTranslation(),i=()=>{actionCreators.SetPredictResultVisible(r,!1),actionCreators.SetPredictResult(r,[]),o([])},s=()=>__async(void 0,null,function*(){actionCreators.SetPointCloudLoading(r,!0),yield r(actionCreators.BatchUpdateImgListResultByPredictResult()),actionCreators.SetPointCloudLoading(r,!1),i()});return a?React__default.default.createElement(React__default.default.Fragment,null,n.length>0&&React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","bar")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","title")},React__default.default.createElement("div",null,l("ComplementaryTrackingPrediction"),n.length>0?`\uFF08${n.length}\uFF09`:""),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","option")},React__default.default.createElement("div",{className:classNames__default.default([dom.getClassName("point-cloud-predict-tracking-container","cancelOption"),dom.getClassName("point-cloud-predict-tracking-container","button")]),onClick:i},l("Cancel")),React__default.default.createElement("div",{className:classNames__default.default([dom.getClassName("point-cloud-predict-tracking-container","okOption"),dom.getClassName("point-cloud-predict-tracking-container","button")]),onClick:s},l("Apply")))),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","content")},React__default.default.createElement(Result,{list:n})))),t.length>0&&React__default.default.createElement(GenerateViewsDataUrl,{result:t,imgList:c,setList:o})):null},Result=e=>{const{list:t}=e,{t:a}=reactI18next.useTranslation(),c=[a("TopView"),a("SideView"),a("BackView")];return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","left")},c.map(n=>React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","title"),key:n},n))),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","right")},t.map(n=>React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","item"),key:n.id},util.views.map(o=>{const r=n[o];return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-predict-tracking-container","view"),key:`${n.id}-${o}`},React__default.default.createElement("img",{src:r}))})))))},GenerateViewsDataUrl=e=>{const t=React__default.default.useContext(PointCloudContext.PointCloudContext),a=ctx.useDispatch(),{result:c,imgList:n,setList:o}=e,r=React.useRef(null),l={width:600,height:600};return React.useEffect(()=>{(()=>__async(void 0,null,function*(){var s,f,g,v,C,P;const p=(s=t.mainViewInstance)==null?void 0:s.config;if(p&&r.current){const y=lbUtils.PointCloudUtils.getDefaultOrthographicParams(l),u=new lbAnnotation.PointCloud({container:r.current,isOrthographicCamera:!0,orthographicParams:y,config:p});u.setShowDirection(!1);for(const d of c){const{index:m}=d,N=n[m].url?n[m].url:(C=(v=(g=(f=n[m])==null?void 0:f.webPointCloudFile)==null?void 0:g.lidar)==null?void 0:v.url)!=null?C:"";yield u.loadPCDFileByBox(N,d,{width:2,height:2,depth:2}),yield u.updateCameraZoom(t.zoom);const _=(P=lbUtils.toolStyleConverter.getColorFromConfig({attribute:d.attribute},__spreadProps(__spreadValues({},p),{attributeConfigurable:!0}),{}))==null?void 0:P.fill;u.generateBox(d,_),yield util.sleep(500),yield util.getViewsDataUrl(u,d,t.zoom),yield u.removeObjectByName(d.id,"box"),yield u.clearPointCloudAndRender()}o(c),actionCreators.SetPointCloudLoading(a,!1)}}))()},[]),React__default.default.createElement("div",{style:l,ref:r,className:"generate-view"})},mapStateToProps=e=>({predictionResult:e.annotation.predictionResult,predictionResultVisible:e.annotation.predictionResultVisible,imgList:e.annotation.imgList});var PreviewResult$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(PreviewResult);module.exports=PreviewResult$1;
@@ -1 +1 @@
1
- import{PointCloud as g}from"@labelbee/lb-annotation";import{PointCloudUtils as m}from"@labelbee/lb-utils";import p,{useRef as f,useCallback as P,useEffect as l}from"react";function b(a){return{left:-a.width/2,right:a.width/2,top:a.height/2,bottom:-a.height/2,near:100,far:-100}}const C=a=>{const{src:c,result:n,size:i,isOrthographicCamera:u=!1,backgroundColor:h="#ccc"}=a;let s=f();const t=f(),v=P(r=>{s.current=r},[]);return l(()=>{let r={container:s.current,backgroundColor:h,isOrthographicCamera:u};u&&Object.assign(r,{orthographicParams:b(i)});const o=new g(r);return t.current=o,()=>{var e;(e=t.current.renderer)==null||e.forceContextLoss()}},[]),l(()=>{var r,o,e;t.current&&((r=t.current)==null||r.init(),(o=t.current)==null||o.initOrthographicCamera(b(i)),(e=t.current)==null||e.render())},[i]),l(()=>{var r;t.current&&c&&((r=t.current)==null||r.loadPCDFile(c))},[c]),l(()=>(n&&m.getBoxParamsFromResultList(n).forEach(o=>{var e;(e=t.current)==null||e.generateBox(o,o.id)}),()=>{var r;m.getBoxParamsFromResultList(n).forEach(e=>{var d;(d=t.current)==null||d.removeObjectByName(e.id,"box")}),(r=t.current)==null||r.render()}),[n]),p.createElement("div",{style:i,ref:v})};export{C as default};
1
+ import{PointCloud as P}from"@labelbee/lb-annotation";import{PointCloudUtils as i}from"@labelbee/lb-utils";import p,{useRef as m,useCallback as g,useEffect as l}from"react";const h=f=>{const{src:c,result:o,size:n,isOrthographicCamera:s=!1,backgroundColor:b="#ccc"}=f;let u=m();const e=m(),v=g(r=>{u.current=r},[]);return l(()=>{let r={container:u.current,backgroundColor:b,isOrthographicCamera:s};s&&Object.assign(r,{orthographicParams:i.getDefaultOrthographicParams(n)});const a=new P(r);return e.current=a,()=>{var t;(t=e.current.renderer)==null||t.forceContextLoss()}},[]),l(()=>{var r,a,t;e.current&&((r=e.current)==null||r.init(),(a=e.current)==null||a.initOrthographicCamera(i.getDefaultOrthographicParams(n)),(t=e.current)==null||t.render())},[n]),l(()=>{var r;e.current&&c&&((r=e.current)==null||r.loadPCDFile(c))},[c]),l(()=>(o&&i.getBoxParamsFromResultList(o).forEach(a=>{var t;(t=e.current)==null||t.generateBox(a,a.id)}),()=>{var r;i.getBoxParamsFromResultList(o).forEach(t=>{var d;(d=e.current)==null||d.removeObjectByName(t.id,"box")}),(r=e.current)==null||r.render()}),[o]),p.createElement("div",{style:n,ref:v})};export{h as default};
@@ -1 +1 @@
1
- import{getClassName as m}from"../../utils/dom.js";import{PointCloud as z}from"@labelbee/lb-annotation";import{PointCloudUtils as D,toolStyleConverter as N,EPerspectiveView as C}from"@labelbee/lb-utils";import L from"classnames";import n,{useContext as h,useState as k,useRef as R,useEffect as w,useMemo as F}from"react";import{PointCloudContainer as A}from"./PointCloudLayout.js";import{PointCloudContext as M}from"./PointCloudContext.js";import{a2MapStateToProps as U}from"../../store/annotation/map.js";import{connect as Z}from"react-redux";import{jsonParser as q}from"../../utils/index.js";import{useSingleBox as G}from"./hooks/useSingleBox.js";import{useSphere as H}from"./hooks/useSphere.js";import{Switch as J,Tooltip as K}from"antd";import Q from"../../hooks/useSize.js";import{usePointCloudViews as W}from"./hooks/usePointCloudViews.js";import{useTranslation as I}from"react-i18next";import{LabelBeeContext as X}from"../../store/ctx.js";import Y from"./components/PointCloudSizeSlider/index.js";var $=Object.defineProperty,ee=Object.defineProperties,te=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,S=(o,r,e)=>r in o?$(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,T=(o,r)=>{for(var e in r||(r={}))oe.call(r,e)&&S(o,e,r[e]);if(b)for(var e of b(r))ne.call(r,e)&&S(o,e,r[e]);return o},ie=(o,r)=>ee(o,te(r));const re="LABELBEE-POINTCLOUD",g=n.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),u=({perspectiveView:o})=>{const{isActive:r,setTarget3DView:e}=h(g),f=V=>L({[m("point-cloud-3d-view",V)]:!0,active:r});return n.createElement("span",{onClick:()=>{e(C[o])},className:f(o.toLocaleLowerCase())})},ae=()=>{const{reset3DView:o,followTopView:r}=h(g),{t:e}=I();return n.createElement("div",{className:m("point-cloud-3d-sidebar")},n.createElement(u,{perspectiveView:"Top"}),n.createElement(u,{perspectiveView:"Front"}),n.createElement(u,{perspectiveView:"Left"}),n.createElement(u,{perspectiveView:"Back"}),n.createElement(u,{perspectiveView:"Right"}),n.createElement(u,{perspectiveView:"LFT"}),n.createElement(u,{perspectiveView:"RBT"}),n.createElement(K,{title:e("CameraFollowTopView")},n.createElement("span",{onClick:()=>{r()},className:m("point-cloud-3d-view","followTop")})),n.createElement("span",{onClick:()=>{o()},className:m("point-cloud-3d-view","reset")}))},le=({currentData:o,config:r})=>{const e=h(M),[f,V]=k(!0),d=R(null),{initPointCloud3d:E}=W(),c=Q(d),{t:x}=I();w(()=>{!e.mainViewInstance||E==null||E(c)},[c]);const{selectedBox:p}=G(),{selectedSphere:v}=H(),P=t=>{var i,a;const l=p==null?void 0:p.info;if(l){const s=T({},l.center);s.x=s.x-.01,s.z=10;const _=t===C.Top;(i=e.mainViewInstance)==null||i.updateCameraByBox(l,t,_?s:void 0)}v&&((a=e.mainViewInstance)==null||a.updateCameraBySphere(v,t))},j=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},O=()=>{var t,i;const a=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;a&&((i=e.mainViewInstance)==null||i.applyCameraTarget(a))};w(()=>{if(d.current&&(o==null?void 0:o.url)){let t=e.mainViewInstance;if(!t&&c.width){const i={left:-c.width/2,right:c.width/2,top:c.height/2,bottom:-c.height/2,near:100,far:-100};t=new z({container:d.current,isOrthographicCamera:!0,orthographicParams:i,config:r}),e.setMainViewInstance(t)}}},[c]),w(()=>{var t;if(d.current&&(o==null?void 0:o.url)&&o.result&&e.mainViewInstance){let i=e.mainViewInstance;const a=D.getBoxParamsFromResultList(o.result);a.forEach(l=>{var s;const _=(s=N.getColorFromConfig({attribute:l.attribute},ie(T({},r),{attributeConfigurable:!0}),{}))==null?void 0:s.hex;i==null||i.generateBox(l,_)}),e.setPointCloudResult(a),e.setPointCloudValid((t=q(o.result))==null?void 0:t.valid)}},[o,e.mainViewInstance]),w(()=>{var t,i,a,l;if(p){P(C.Top);const s=(a=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?a:1;(l=e.mainViewInstance)==null||l.updateCameraZoom(s)}},[p]),w(()=>{var t,i,a,l;if(v){P(C.Top);const s=(a=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?a:1;(l=e.mainViewInstance)==null||l.updateCameraZoom(s)}},[v]);const B=F(()=>({reset3DView:j,setTarget3DView:P,isActive:!!p,followTopView:O}),[p,e.mainViewInstance]),y=n.createElement(n.Fragment,null,n.createElement(Y,{onChange:t=>{var i;(i=e.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),n.createElement("span",{style:{marginRight:8}},x("ShowArrows")),n.createElement(J,{size:"small",checked:f,onChange:t=>{var i;V(t),(i=e.mainViewInstance)==null||i.setShowDirection(t)}}));return n.createElement(A,{className:m("point-cloud-3d-container"),title:x("3DView"),toolbar:y},n.createElement("div",{className:m("point-cloud-3d-content")},n.createElement(g.Provider,{value:B},n.createElement(ae,null)),n.createElement("div",{className:m("point-cloud-3d-view"),id:re,ref:d})))};var se=Z(U,null,null,{context:X})(le);export{se as default};
1
+ import{getClassName as c}from"../../utils/dom.js";import{PointCloud as D}from"@labelbee/lb-annotation";import{PointCloudUtils as I,toolStyleConverter as N,EPerspectiveView as C}from"@labelbee/lb-utils";import L from"classnames";import n,{useContext as h,useState as k,useRef as R,useEffect as w,useMemo as F}from"react";import{PointCloudContainer as A}from"./PointCloudLayout.js";import{PointCloudContext as M}from"./PointCloudContext.js";import{a2MapStateToProps as U}from"../../store/annotation/map.js";import{connect as Z}from"react-redux";import{jsonParser as q}from"../../utils/index.js";import{useSingleBox as G}from"./hooks/useSingleBox.js";import{useSphere as H}from"./hooks/useSphere.js";import{Switch as J,Tooltip as K}from"antd";import Q from"../../hooks/useSize.js";import{usePointCloudViews as W}from"./hooks/usePointCloudViews.js";import{useTranslation as S}from"react-i18next";import{LabelBeeContext as X}from"../../store/ctx.js";import Y from"./components/PointCloudSizeSlider/index.js";var $=Object.defineProperty,ee=Object.defineProperties,te=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,T=(o,i,e)=>i in o?$(o,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[i]=e,j=(o,i)=>{for(var e in i||(i={}))oe.call(i,e)&&T(o,e,i[e]);if(b)for(var e of b(i))ne.call(i,e)&&T(o,e,i[e]);return o},ie=(o,i)=>ee(o,te(i));const re="LABELBEE-POINTCLOUD",E=n.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),m=({perspectiveView:o})=>{const{isActive:i,setTarget3DView:e}=h(E),f=V=>L({[c("point-cloud-3d-view",V)]:!0,active:i});return n.createElement("span",{onClick:()=>{e(C[o])},className:f(o.toLocaleLowerCase())})},ae=()=>{const{reset3DView:o,followTopView:i}=h(E),{t:e}=S();return n.createElement("div",{className:c("point-cloud-3d-sidebar")},n.createElement(m,{perspectiveView:"Top"}),n.createElement(m,{perspectiveView:"Front"}),n.createElement(m,{perspectiveView:"Left"}),n.createElement(m,{perspectiveView:"Back"}),n.createElement(m,{perspectiveView:"Right"}),n.createElement(m,{perspectiveView:"LFT"}),n.createElement(m,{perspectiveView:"RBT"}),n.createElement(K,{title:e("CameraFollowTopView")},n.createElement("span",{onClick:()=>{i()},className:c("point-cloud-3d-view","followTop")})),n.createElement("span",{onClick:()=>{o()},className:c("point-cloud-3d-view","reset")}))},le=({currentData:o,config:i})=>{const e=h(M),[f,V]=k(!0),p=R(null),{initPointCloud3d:g}=W(),d=Q(p),{t:x}=S();w(()=>{!e.mainViewInstance||g==null||g(d)},[d]);const{selectedBox:u}=G(),{selectedSphere:v}=H(),P=t=>{var r,a;const l=u==null?void 0:u.info;if(l){const s=j({},l.center);s.x=s.x-.01,s.z=10;const _=t===C.Top;(r=e.mainViewInstance)==null||r.updateCameraByBox(l,t,_?s:void 0)}v&&((a=e.mainViewInstance)==null||a.updateCameraBySphere(v,t))},O=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},B=()=>{var t,r;const a=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;a&&((r=e.mainViewInstance)==null||r.applyCameraTarget(a))};w(()=>{if(p.current&&(o==null?void 0:o.url)){let t=e.mainViewInstance;!t&&d.width&&(t=new D({container:p.current,isOrthographicCamera:!0,orthographicParams:I.getDefaultOrthographicParams(d),config:i}),e.setMainViewInstance(t))}},[d,o]),w(()=>{var t;if(p.current&&(o==null?void 0:o.url)&&o.result&&e.mainViewInstance){let r=e.mainViewInstance;const a=I.getBoxParamsFromResultList(o.result);a.forEach(l=>{var s;const _=(s=N.getColorFromConfig({attribute:l.attribute},ie(j({},i),{attributeConfigurable:!0}),{}))==null?void 0:s.hex;r==null||r.generateBox(l,_)}),e.setPointCloudResult(a),e.setPointCloudValid((t=q(o.result))==null?void 0:t.valid)}},[o,e.mainViewInstance]),w(()=>{var t,r,a,l;if(u){P(C.Top);const s=(a=(r=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:r.camera.zoom)!=null?a:1;(l=e.mainViewInstance)==null||l.updateCameraZoom(s)}},[u]),w(()=>{var t,r,a,l;if(v){P(C.Top);const s=(a=(r=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:r.camera.zoom)!=null?a:1;(l=e.mainViewInstance)==null||l.updateCameraZoom(s)}},[v]);const y=F(()=>({reset3DView:O,setTarget3DView:P,isActive:!!u,followTopView:B}),[u,e.mainViewInstance]),z=n.createElement(n.Fragment,null,n.createElement(Y,{onChange:t=>{var r;(r=e.mainViewInstance)==null||r.updatePointSize({customSize:t})}}),n.createElement("span",{style:{marginRight:8}},x("ShowArrows")),n.createElement(J,{size:"small",checked:f,onChange:t=>{var r;V(t),(r=e.mainViewInstance)==null||r.setShowDirection(t)}}));return n.createElement(A,{className:c("point-cloud-3d-container"),title:x("3DView"),toolbar:z},n.createElement("div",{className:c("point-cloud-3d-content")},n.createElement(E.Provider,{value:y},n.createElement(ae,null)),n.createElement("div",{className:c("point-cloud-3d-view"),id:re,ref:p})))};var se=Z(U,null,null,{context:X})(le);export{se as default};
@@ -1 +1 @@
1
- import p from"../../hooks/useSize.js";import{a2MapStateToProps as h}from"../../store/annotation/map.js";import{LabelBeeContext as b}from"../../store/ctx.js";import{getClassName as g}from"../../utils/dom.js";import{PointCloud as C}from"@labelbee/lb-annotation";import v,{useRef as P,useContext as S,useEffect as u}from"react";import{connect as x}from"react-redux";import{PointCloudContext as j}from"./PointCloudContext.js";import{PointCloudUtils as w}from"@labelbee/lb-utils";const R=({currentData:A,config:r,checkMode:m})=>{var n,i;const o=P(null),{setPtSegmentInstance:c,setDefaultAttribute:d,ptSegmentInstance:e}=S(j),t=p(o),a=(i=(n=r==null?void 0:r.attributeList)==null?void 0:n[0])==null?void 0:i.value;return u(()=>{var l;if(!(t==null?void 0:t.width)||!o.current||e)return;const f={left:-t.width/2,right:t.width/2,top:t.height/2,bottom:-t.height/2,near:1e3,far:-1e3},s=new C({container:o.current,isOrthographicCamera:!0,isSegment:!0,orthographicParams:f,config:r,checkMode:m});(l=s.store)==null||l.setAttribute(a),d(a),c(s)},[t]),u(()=>{e&&(e.initRenderer(),e.initOrthographicCamera(w.getDefaultOrthographic(t)),e.render())},[t]),v.createElement("div",{className:g("point-cloud-layout"),ref:o})};var z=x(h,null,null,{context:b})(R);export{z as default};
1
+ import f from"../../hooks/useSize.js";import{a2MapStateToProps as C}from"../../store/annotation/map.js";import{LabelBeeContext as b}from"../../store/ctx.js";import{getClassName as g}from"../../utils/dom.js";import{PointCloud as h}from"@labelbee/lb-annotation";import P,{useRef as v,useContext as S,useEffect as u}from"react";import{connect as x}from"react-redux";import{PointCloudContext as j}from"./PointCloudContext.js";import{PointCloudUtils as m}from"@labelbee/lb-utils";const D=({currentData:R,config:r,checkMode:c})=>{var n,a;const o=v(null),{setPtSegmentInstance:d,setDefaultAttribute:p,ptSegmentInstance:e}=S(j),t=f(o),i=(a=(n=r==null?void 0:r.attributeList)==null?void 0:n[0])==null?void 0:a.value;return u(()=>{var l;if(!(t==null?void 0:t.width)||!o.current||e)return;const s=new h({container:o.current,isOrthographicCamera:!0,isSegment:!0,orthographicParams:m.getDefaultOrthographicParams(t),config:r,checkMode:c});(l=s.store)==null||l.setAttribute(i),p(i),d(s)},[t]),u(()=>{e&&(e.initRenderer(),e.initOrthographicCamera(m.getDefaultOrthographicParams(t)),e.render())},[t]),P.createElement("div",{className:g("point-cloud-layout"),ref:o})};var O=x(C,null,null,{context:b})(D);export{O as default};
@@ -1 +1 @@
1
- import{MathUtils as x,getCuboidFromPointCloudBox as At}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as I,DEFAULT_SPHERE_PARAMS as Ut}from"@labelbee/lb-utils";import{useContext as kt}from"react";import{PointCloudContext as jt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as Tt}from"./useSphere.js";import{useSelector as zt,useDispatch as Rt}from"../../../store/ctx.js";import Ht from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as lt}from"../../../store/annotation/actionCreators.js";import{message as Et}from"antd";import{useTranslation as Ft}from"react-i18next";import{useHistory as Nt}from"./useHistory.js";import{usePolygon as Zt}from"./usePolygon.js";var Wt=Object.defineProperty,Mt=Object.defineProperties,Gt=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Qt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable,at=(o,e,n)=>e in o?Wt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,m=(o,e)=>{for(var n in e||(e={}))Qt.call(e,n)&&at(o,n,e[n]);if(dt)for(var n of dt(e))Xt.call(e,n)&&at(o,n,e[n]);return o},A=(o,e)=>Mt(o,Gt(e)),q=(o,e,n)=>new Promise((l,t)=>{var a=d=>{try{r(n.next(d))}catch(g){t(g)}},p=d=>{try{r(n.throw(d))}catch(g){t(g)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((n=n.apply(o,e)).next())});const G=5,Q=90,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(o,e,n,l,t)=>{const{x:a,y:p}=I.transferCanvas2World(o,e),{defaultZ:r}=Ut,d={center:{x:a,y:p,z:r},id:o.id},g=l?m(m({},l),d):A(m({},d),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},K=(o,e,n,l,t,a)=>{let p=o.pointList.map(L=>I.transferCanvas2World(L,e)),r=0,d=1,g={};if(n){const L=n.getSensesPointZAxisInPolygon(p,void 0,a);a&&L.fittedCoordinates.length>0&&(p=L.fittedCoordinates),r=(L.maxZ+L.minZ)/2,d=L.maxZ-L.minZ,g={count:L.zCount}}const[h,B,U]=p,V=x.getLineCenterPoint([h,U]),k=x.getLineLength(h,B),j=x.getLineLength(B,U),T=x.getRadiusFromQuadrangle(o.pointList);l&&(r=l.center.z,d=l.depth);const O={center:{x:V.x,y:V.y,z:r},width:j,height:k,depth:d,rotation:T,id:o.id},D=m(l?m(m({},l),O):A(m({},O),{attribute:"",valid:!0}),g);t&&Object.assign(D,t);const z=p.map(L=>I.transferWorld2Canvas(L,e));return{boxParams:D,newPointList:z}},ct=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return A(m({},n),{center:{x:n.center.x-l.x,y:n.center.y,z:n.center.z-l.y}})},ut=(o,e,n,l)=>{const[t,a,p]=o.pointList,[r,d,g]=e.pointList,h=x.getLineCenterPoint([t,p]),B=x.getLineCenterPoint([r,g]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},k=x.getLineLength(t,a),j=x.getLineLength(r,d),T=k-j,O=x.getLineLength(a,p),D=x.getLineLength(d,g),z=O-D,{newBoxParams:L}=l.getNewBoxBySideUpdate(V,z,T,n);return L},Yt=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return A(m({},n),{center:{x:n.center.x,y:n.center.y-l.x,z:n.center.z-l.y}})},qt=(o,e,n,l)=>{const[t,a,p]=o.pointList,[r,d,g]=e.pointList,h=x.getLineCenterPoint([t,p]),B=x.getLineCenterPoint([r,g]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},k=x.getLineLength(t,a),j=x.getLineLength(r,d),T=k-j,O=x.getLineLength(a,p),D=x.getLineLength(d,g),z=O-D;let{newBoxParams:L}=l.getNewBoxByBackUpdate(V,z,T,n);return L},pt=(o,e,n,l,t)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:Q);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(o,N.Left);r.setInitCameraPosition(d);const{point2d:g,zoom:h}=r.getSphereSidePoint2DCoordinate(o);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(m(m({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),p.setSelectedID(e.id)},ft=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=n;a.loadPCDFileByBox(l,o,{width:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(o,N.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(o);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:r,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},Ct=(o,e,n,l,t)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:Q);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(o,N.Back);r.setInitCameraPosition(d);const{point2d:g,zoom:h}=r.getSphereBackPoint2DCoordinate(o);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(m(m({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),p.setSelectedID(e.id)},gt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=n;a.loadPCDFileByBox(l,o,{height:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(o,N.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(o);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:r,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},Pt=(o,e,n,l)=>{if(!n||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,N.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=n,{point2d:p}=a.getSphereTopPoint2DCoordinate(o),r=[...t.pointList].map(d=>d.id===e.id?A(m(m({},e),p),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);t.setResult(r),t.setSelectedID(e.id)},$=(o,e,n,l)=>{var t;if(!n||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(o),d=[...a.polygonList],g=d.find(h=>h.id===e.id);g?g.pointList=r:d.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(t=o.valid)!=null?t:!0}),a.setResultAndSelectedID(d,e.id)},Jt=()=>{const o=kt(jt),{topViewInstance:e,sideViewInstance:n,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:g,pointCloudSphereList:h,hideAttributes:B}=o,{addHistory:U,initHistory:V,pushHistoryUnderUpdatePolygon:k,pushHistoryUnderUpdateLine:j}=Nt(),{selectedPolygon:T}=Zt(),{updateSelectedBox:O,updateSelectedBoxes:D,getPointCloudByID:z}=st(),{getPointCloudSphereByID:L,updatePointCloudSphere:tt,selectedSphere:Z}=Tt(),{currentData:H,config:S}=zt(i=>{const{stepList:s,step:f,imgList:c,imgIndex:u}=i.annotation;return{currentData:c[u],config:rt(Ht.getCurrentStepInfo(f,s).config)}}),ot=Rt(),{selectedBox:R}=st(),{t:ht}=Ft(),et=R==null?void 0:R.info;if(!e||!n||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,yt=i=>{t==null||t.generateBox(i),t==null||t.controls.update(),t==null||t.render()},mt=i=>{t==null||t.generateSphere(i),t==null||t.controls.update(),t==null||t.render()},Lt=({newPoint:i,size:s,zoom:f,trackConfigurable:c})=>{var u;const C={attribute:(u=e.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const P=J(i,s,X,void 0,C);r(i.id);const v=p(P);W(y.Top,i,P,f,v,S),U({newSphereParams:P})},vt=({polygon:i,size:s,imgList:f,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var P,v;const w={attribute:(P=e.toolInstance.defaultAttribute)!=null?P:""};c===!0&&Object.assign(w,{trackID:I.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:h})});const E=e==null?void 0:e.toolInstance,_=m({},i),{boxParams:b,newPointList:F}=K(_,s,X,void 0,w,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Et.info(ht("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),E.deletePolygon(b.id);return}C&&(F==null?void 0:F.length)&&(_.pointList=F);const Vt=B.includes(_.attribute),Y=a(b),Ot=(v=o==null?void 0:o.polygonList)!=null?v:[];e==null||e.updatePolygonList(Y!=null?Y:[],Ot),Vt?r([]):(r(b.id),E.selection.setSelectedIDs(_.id),M(y.Top,_,b,u,Y),C&&$(b,_,e,t)),U({newBoxParams:b})},xt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:c})=>{var u;const C=e==null?void 0:e.toolInstance;if(!(d.length===0||!C)){if(i||(R==null?void 0:R.info)){const P=i!=null?i:R==null?void 0:R.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const v=C.selectedPolygon;if(d.length===1&&P){M(y.Top,v,P,void 0,s);return}}if((f||Z)&&d.length===1){const P=f!=null?f:Z;C.setSelectedID(d[0]);const v=C.selectedPoint;P&&W(y.Top,v,P,void 0,c,S)}}},nt=(i,s,f)=>{if(et){let c,u;switch(f){case y.Back:c=qt;break;case y.Side:c=ut;break;default:c=ut;break}if(u=c(i,s,et,n.pointCloudInstance),t){const{count:P}=t.getSensesPointZAxisInPolygon(At(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=A(m({},u),{count:P})}const C=O(u);return M(f,i,u,void 0,C),C}},it=(i,s,f)=>{if(Z){let c,u;switch(f){case y.Back:c=Yt;break;case y.Side:c=ct;break;default:c=ct;break}u=c(i,s,Z);const C=tt(u);return W(f,i,u,void 0,C,S),C}},Bt=(i,s)=>{it(i,s,y.Side)},St=(i,s)=>{it(i,s,y.Back)},bt=(i,s)=>{nt(i,s,y.Side)},wt=(i,s)=>{nt(i,s,y.Back)},It=(i,s)=>{j(i)},Dt=(i,s)=>{const f=L(i.id),c=J(i,s,X,f),u=tt(c);W(y.Top,i,c,void 0,u,S)},_t=(i,s)=>{if(T){const c=i[0].newPolygon;c.pointList=c.pointList.map(u=>I.transferCanvas2World(u,s)),k(i[0].newPolygon);return}const f=i.map(({newPolygon:c})=>{const u=z(c.id),{boxParams:C}=K(c,s,e.pointCloudInstance,u);return C});if(f.length===1){const{newPolygon:c}=i[0],u=D(f);M(y.Top,c,f[0],void 0,u)}else{const c=D(f);c&&o.syncAllViewPointCloudColor(c)}},W=(i,s,f,c,u,C)=>q(void 0,null,function*(){const P=H==null?void 0:H.url,v={[y.Side]:()=>{pt(f,s,n,P,C)},[y.Back]:()=>{l&&Ct(f,s,l,P,C)},[y.Top]:()=>{Pt(f,s,e,t)}};Object.keys(v).forEach(w=>{w!==i&&v[w]()}),c&&(t==null||t.updateCameraZoom(c)),mt(f)}),M=(i,s,f,c,u)=>q(void 0,null,function*(){const C=H==null?void 0:H.url;u&&(yield o.syncAllViewPointCloudColor(u));const P={[y.Side]:()=>{ft(f,s,n,C)},[y.Back]:()=>{l&&gt(f,s,l,C)},[y.Top]:()=>{$(f,s,e,t)}};Object.keys(P).forEach(v=>{v!==i&&P[v]()}),c&&(t==null||t.updateCameraZoom(c)),yt(f)});return{topViewAddSphere:Lt,topViewAddBox:vt,topViewSelectedChanged:xt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:_t,topViewUpdateLine:It,sideViewUpdateBox:bt,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),t==null||t.generateBoxes(i)},initPointCloud3d:i=>{if(!t)return;const s={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(s=H){var f,c,u,C,P,v;if(!(s==null?void 0:s.url)||!t)return;lt(ot,!0),yield t.loadPCDFile(s.url,(f=S==null?void 0:S.radius)!=null?f:Q),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let w=[],E=[],_=[],b=[];s.result&&(w=I.getBoxParamsFromResultList(s.result),_=I.getPolygonListFromResultList(s.result),E=I.getLineListFromResultList(s.result),b=I.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(w),t==null||t.generateSpheres(b),o.syncAllViewPointCloudColor(w)),V({pointCloudBoxList:w,polygonList:_,lineList:E,pointCloudSphereList:b}),t.updateTopCamera();const F=(u=(c=rt(s.result))==null?void 0:c.valid)!=null?u:!0;o.setPointCloudValid(F),(C=o.sideViewInstance)==null||C.clearAllData(),(P=o.backViewInstance)==null||P.clearAllData(),e.updateData(s.url,s.result,{radius:(v=S==null?void 0:S.radius)!=null?v:Q}),lt(ot,!1)})}};export{Ct as syncBackViewByPoint,pt as syncSideViewByPoint,Pt as syncTopViewByPoint,gt as synchronizeBackView,ft as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Jt as usePointCloudViews};
1
+ import{MathUtils as x,getCuboidFromPointCloudBox as At}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as w,DEFAULT_SPHERE_PARAMS as Ut}from"@labelbee/lb-utils";import{useContext as kt}from"react";import{PointCloudContext as zt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as jt}from"./useSphere.js";import{useSelector as Tt,useDispatch as Rt}from"../../../store/ctx.js";import Ht from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as lt}from"../../../store/annotation/actionCreators.js";import{message as Et}from"antd";import{useTranslation as Ft}from"react-i18next";import{useHistory as Nt}from"./useHistory.js";import{usePolygon as Zt}from"./usePolygon.js";var Wt=Object.defineProperty,Mt=Object.defineProperties,Gt=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Qt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable,at=(o,e,n)=>e in o?Wt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,L=(o,e)=>{for(var n in e||(e={}))Qt.call(e,n)&&at(o,n,e[n]);if(dt)for(var n of dt(e))Xt.call(e,n)&&at(o,n,e[n]);return o},A=(o,e)=>Mt(o,Gt(e)),q=(o,e,n)=>new Promise((l,t)=>{var a=d=>{try{r(n.next(d))}catch(g){t(g)}},p=d=>{try{r(n.throw(d))}catch(g){t(g)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((n=n.apply(o,e)).next())});const G=5,Q=90,m={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(o,e,n,l,t)=>{const{x:a,y:p}=w.transferCanvas2World(o,e),{defaultZ:r}=Ut,d={center:{x:a,y:p,z:r},id:o.id},g=l?L(L({},l),d):A(L({},d),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},K=(o,e,n,l,t,a)=>{let p=o.pointList.map(h=>w.transferCanvas2World(h,e)),r=0,d=1,g={};if(n){const h=n.getSensesPointZAxisInPolygon(p,void 0,a);a&&h.fittedCoordinates.length>0&&(p=h.fittedCoordinates),r=(h.maxZ+h.minZ)/2,d=h.maxZ-h.minZ,g={count:h.zCount}}const[y,B,U]=p,O=x.getLineCenterPoint([y,U]),k=x.getLineLength(y,B),z=x.getLineLength(B,U),j=x.getRadiusFromQuadrangle(o.pointList);l&&(r=l.center.z,d=l.depth);const V={center:{x:O.x,y:O.y,z:r},width:z,height:k,depth:d,rotation:j,id:o.id},D=L(l?L(L({},l),V):A(L({},V),{attribute:"",valid:!0}),g);t&&Object.assign(D,t);const T=p.map(h=>w.transferWorld2Canvas(h,e));return{boxParams:D,newPointList:T}},ct=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return A(L({},n),{center:{x:n.center.x-l.x,y:n.center.y,z:n.center.z-l.y}})},ut=(o,e,n,l)=>{const[t,a,p]=o.pointList,[r,d,g]=e.pointList,y=x.getLineCenterPoint([t,p]),B=x.getLineCenterPoint([r,g]),O={x:{x:y.x-B.x,y:y.y-B.y}.x,y:0,z:y.y-B.y},k=x.getLineLength(t,a),z=x.getLineLength(r,d),j=k-z,V=x.getLineLength(a,p),D=x.getLineLength(d,g),T=V-D,{newBoxParams:h}=l.getNewBoxBySideUpdate(O,T,j,n);return h},Yt=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return A(L({},n),{center:{x:n.center.x,y:n.center.y-l.x,z:n.center.z-l.y}})},qt=(o,e,n,l)=>{const[t,a,p]=o.pointList,[r,d,g]=e.pointList,y=x.getLineCenterPoint([t,p]),B=x.getLineCenterPoint([r,g]),O={x:{x:y.x-B.x,y:y.y-B.y}.x,y:0,z:y.y-B.y},k=x.getLineLength(t,a),z=x.getLineLength(r,d),j=k-z,V=x.getLineLength(a,p),D=x.getLineLength(d,g),T=V-D;let{newBoxParams:h}=l.getNewBoxByBackUpdate(O,T,j,n);return h},pt=(o,e,n,l,t)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:Q);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(o,N.Left);r.setInitCameraPosition(d);const{point2d:g,zoom:y}=r.getSphereSidePoint2DCoordinate(o);r.camera.zoom=y,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(y),p.setResult([A(L(L({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),p.setSelectedID(e.id)},ft=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=n;a.loadPCDFileByBox(l,o,{width:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(o,N.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(o);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:r,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},Ct=(o,e,n,l,t)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:Q);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(o,N.Back);r.setInitCameraPosition(d);const{point2d:g,zoom:y}=r.getSphereBackPoint2DCoordinate(o);r.camera.zoom=y,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(y),p.setResult([A(L(L({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),p.setSelectedID(e.id)},gt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=n;a.loadPCDFileByBox(l,o,{height:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(o,N.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(o);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:r,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},Pt=(o,e,n,l)=>{if(!n||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,N.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=n,{point2d:p}=a.getSphereTopPoint2DCoordinate(o),r=[...t.pointList].map(d=>d.id===e.id?A(L(L({},e),p),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);t.setResult(r),t.setSelectedID(e.id)},$=(o,e,n,l)=>{var t;if(!n||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(o),d=[...a.polygonList],g=d.find(y=>y.id===e.id);g?g.pointList=r:d.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(t=o.valid)!=null?t:!0}),a.setResultAndSelectedID(d,e.id)},Jt=()=>{const o=kt(zt),{topViewInstance:e,sideViewInstance:n,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:g,pointCloudSphereList:y,hideAttributes:B}=o,{addHistory:U,initHistory:O,pushHistoryUnderUpdatePolygon:k,pushHistoryUnderUpdateLine:z}=Nt(),{selectedPolygon:j}=Zt(),{updateSelectedBox:V,updateSelectedBoxes:D,getPointCloudByID:T}=st(),{getPointCloudSphereByID:h,updatePointCloudSphere:tt,selectedSphere:Z}=jt(),{currentData:H,config:S}=Tt(i=>{const{stepList:s,step:f,imgList:c,imgIndex:u}=i.annotation;return{currentData:c[u],config:rt(Ht.getCurrentStepInfo(f,s).config)}}),ot=Rt(),{selectedBox:R}=st(),{t:yt}=Ft(),et=R==null?void 0:R.info;if(!e||!n||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,mt=i=>{t==null||t.generateBox(i),t==null||t.controls.update(),t==null||t.render()},Lt=i=>{t==null||t.generateSphere(i),t==null||t.controls.update(),t==null||t.render()},ht=({newPoint:i,size:s,zoom:f,trackConfigurable:c})=>{var u;const C={attribute:(u=e.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:w.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const P=J(i,s,X,void 0,C);r(i.id);const v=p(P);W(m.Top,i,P,f,v,S),U({newSphereParams:P})},vt=({polygon:i,size:s,imgList:f,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var P,v;const I={attribute:(P=e.toolInstance.defaultAttribute)!=null?P:""};c===!0&&Object.assign(I,{trackID:w.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:y})});const E=e==null?void 0:e.toolInstance,_=L({},i),{boxParams:b,newPointList:F}=K(_,s,X,void 0,I,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Et.info(yt("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),E.deletePolygon(b.id);return}C&&(F==null?void 0:F.length)&&(_.pointList=F);const Ot=B.includes(_.attribute),Y=a(b),Vt=(v=o==null?void 0:o.polygonList)!=null?v:[];e==null||e.updatePolygonList(Y!=null?Y:[],Vt),Ot?r([]):(r(b.id),E.selection.setSelectedIDs(_.id),M(m.Top,_,b,u,Y),C&&$(b,_,e,t)),U({newBoxParams:b})},xt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:c})=>{var u;const C=e==null?void 0:e.toolInstance;if(!(d.length===0||!C)){if(i||(R==null?void 0:R.info)){const P=i!=null?i:R==null?void 0:R.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const v=C.selectedPolygon;if(d.length===1&&P){M(m.Top,v,P,void 0,s);return}}if((f||Z)&&d.length===1){const P=f!=null?f:Z;C.setSelectedID(d[0]);const v=C.selectedPoint;P&&W(m.Top,v,P,void 0,c,S)}}},nt=(i,s,f)=>{if(et){let c,u;switch(f){case m.Back:c=qt;break;case m.Side:c=ut;break;default:c=ut;break}if(u=c(i,s,et,n.pointCloudInstance),t){const{count:P}=t.getSensesPointZAxisInPolygon(At(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=A(L({},u),{count:P})}const C=V(u);return M(f,i,u,void 0,C),C}},it=(i,s,f)=>{if(Z){let c,u;switch(f){case m.Back:c=Yt;break;case m.Side:c=ct;break;default:c=ct;break}u=c(i,s,Z);const C=tt(u);return W(f,i,u,void 0,C,S),C}},Bt=(i,s)=>{it(i,s,m.Side)},St=(i,s)=>{it(i,s,m.Back)},bt=(i,s)=>{nt(i,s,m.Side)},wt=(i,s)=>{nt(i,s,m.Back)},It=(i,s)=>{z(i)},Dt=(i,s)=>{const f=h(i.id),c=J(i,s,X,f),u=tt(c);W(m.Top,i,c,void 0,u,S)},_t=(i,s)=>{if(j){const c=i[0].newPolygon;c.pointList=c.pointList.map(u=>w.transferCanvas2World(u,s)),k(i[0].newPolygon);return}const f=i.map(({newPolygon:c})=>{const u=T(c.id),{boxParams:C}=K(c,s,e.pointCloudInstance,u);return C});if(f.length===1){const{newPolygon:c}=i[0],u=D(f);M(m.Top,c,f[0],void 0,u)}else{const c=D(f);c&&o.syncAllViewPointCloudColor(c)}},W=(i,s,f,c,u,C)=>q(void 0,null,function*(){const P=H==null?void 0:H.url,v={[m.Side]:()=>{pt(f,s,n,P,C)},[m.Back]:()=>{l&&Ct(f,s,l,P,C)},[m.Top]:()=>{Pt(f,s,e,t)}};Object.keys(v).forEach(I=>{I!==i&&v[I]()}),c&&(t==null||t.updateCameraZoom(c)),Lt(f)}),M=(i,s,f,c,u)=>q(void 0,null,function*(){const C=H==null?void 0:H.url;u&&(yield o.syncAllViewPointCloudColor(u));const P={[m.Side]:()=>{ft(f,s,n,C)},[m.Back]:()=>{l&&gt(f,s,l,C)},[m.Top]:()=>{$(f,s,e,t)}};Object.keys(P).forEach(v=>{v!==i&&P[v]()}),c&&(t==null||t.updateCameraZoom(c)),mt(f)});return{topViewAddSphere:ht,topViewAddBox:vt,topViewSelectedChanged:xt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:_t,topViewUpdateLine:It,sideViewUpdateBox:bt,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),t==null||t.generateBoxes(i)},initPointCloud3d:i=>{if(!t)return;const s=w.getDefaultOrthographicParams(i);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(s=H){var f,c,u,C,P,v;if(!(s==null?void 0:s.url)||!t)return;lt(ot,!0),yield t.loadPCDFile(s.url,(f=S==null?void 0:S.radius)!=null?f:Q),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let I=[],E=[],_=[],b=[];s.result&&(I=w.getBoxParamsFromResultList(s.result),_=w.getPolygonListFromResultList(s.result),E=w.getLineListFromResultList(s.result),b=w.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(I),t==null||t.generateSpheres(b),o.syncAllViewPointCloudColor(I)),O({pointCloudBoxList:I,polygonList:_,lineList:E,pointCloudSphereList:b}),t.updateTopCamera();const F=(u=(c=rt(s.result))==null?void 0:c.valid)!=null?u:!0;o.setPointCloudValid(F),(C=o.sideViewInstance)==null||C.clearAllData(),(P=o.backViewInstance)==null||P.clearAllData(),e.updateData(s.url,s.result,{radius:(v=S==null?void 0:S.radius)!=null?v:Q}),lt(ot,!1)})}};export{Ct as syncBackViewByPoint,pt as syncSideViewByPoint,Pt as syncTopViewByPoint,gt as synchronizeBackView,ft as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Jt as usePointCloudViews};
@@ -1 +1 @@
1
- import C from"classnames";import n,{useState as j,useRef as S,useEffect as F}from"react";import{useTranslation as _}from"react-i18next";import{connect as L}from"react-redux";import{PointCloudContext as B}from"../../pointCloudView/PointCloudContext.js";import{SetPredictResultVisible as D,SetPredictResult as T,SetPointCloudLoading as v,BatchUpdateImgListResultByPredictResult as I}from"../../../store/annotation/actionCreators.js";import{LabelBeeContext as $,useDispatch as E}from"../../../store/ctx.js";import{getClassName as o}from"../../../utils/dom.js";import{PointCloud as z}from"@labelbee/lb-annotation";import{toolStyleConverter as U}from"@labelbee/lb-utils";import{views as A,sleep as G,getViewsDataUrl as Z}from"./util.js";var q=Object.defineProperty,H=Object.defineProperties,J=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable,N=(i,e,t)=>e in i?q(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Q=(i,e)=>{for(var t in e||(e={}))K.call(e,t)&&N(i,t,e[t]);if(k)for(var t of k(e))M.call(e,t)&&N(i,t,e[t]);return i},W=(i,e)=>H(i,J(e)),O=(i,e,t)=>new Promise((d,r)=>{var s=c=>{try{a(t.next(c))}catch(u){r(u)}},l=c=>{try{a(t.throw(c))}catch(u){r(u)}},a=c=>c.done?d(c.value):Promise.resolve(c.value).then(s,l);a((t=t.apply(i,e)).next())});const X=i=>{const{predictionResult:e,predictionResultVisible:t,imgList:d}=i,[r,s]=j([]),l=E(),{t:a}=_(),c=()=>{D(l,!1),T(l,[]),s([])},u=()=>O(void 0,null,function*(){v(l,!0),yield l(I()),v(l,!1),c()});return t?n.createElement(n.Fragment,null,r.length>0&&n.createElement("div",{className:o("point-cloud-predict-tracking-container")},n.createElement("div",{className:o("point-cloud-predict-tracking-container","bar")},n.createElement("div",{className:o("point-cloud-predict-tracking-container","title")},n.createElement("div",null,a("ComplementaryTrackingPrediction"),r.length>0?`\uFF08${r.length}\uFF09`:""),n.createElement("div",{className:o("point-cloud-predict-tracking-container","option")},n.createElement("div",{className:C([o("point-cloud-predict-tracking-container","cancelOption"),o("point-cloud-predict-tracking-container","button")]),onClick:c},a("Cancel")),n.createElement("div",{className:C([o("point-cloud-predict-tracking-container","okOption"),o("point-cloud-predict-tracking-container","button")]),onClick:u},a("Apply")))),n.createElement("div",{className:o("point-cloud-predict-tracking-container","content")},n.createElement(Y,{list:r})))),e.length>0&&n.createElement(ee,{result:e,imgList:d,setList:s})):null},Y=i=>{const{list:e}=i,{t}=_(),d=[t("TopView"),t("SideView"),t("BackView")];return n.createElement(n.Fragment,null,n.createElement("div",{className:o("point-cloud-predict-tracking-container","left")},d.map(r=>n.createElement("div",{className:o("point-cloud-predict-tracking-container","title"),key:r},r))),n.createElement("div",{className:o("point-cloud-predict-tracking-container","right")},e.map(r=>n.createElement("div",{className:o("point-cloud-predict-tracking-container","item"),key:r.id},A.map(s=>{const l=r[s];return n.createElement("div",{className:o("point-cloud-predict-tracking-container","view"),key:`${r.id}-${s}`},n.createElement("img",{src:l}))})))))},ee=i=>{const e=n.useContext(B),t=E(),{result:d,imgList:r,setList:s}=i,l=S(null),a={width:600,height:600};return F(()=>{(()=>O(void 0,null,function*(){var u,h,y,P,w,b;const f=(u=e.mainViewInstance)==null?void 0:u.config;if(f&&l.current){const R={left:-a.width/2,right:a.width/2,top:a.height/2,bottom:-a.height/2,near:200,far:-200},p=new z({container:l.current,isOrthographicCamera:!0,orthographicParams:R,config:f});p.setShowDirection(!1);for(const m of d){const{index:g}=m,x=r[g].url?r[g].url:(w=(P=(y=(h=r[g])==null?void 0:h.webPointCloudFile)==null?void 0:y.lidar)==null?void 0:P.url)!=null?w:"";yield p.loadPCDFileByBox(x,m,{width:2,height:2,depth:2}),yield p.updateCameraZoom(e.zoom);const V=(b=U.getColorFromConfig({attribute:m.attribute},W(Q({},f),{attributeConfigurable:!0}),{}))==null?void 0:b.fill;p.generateBox(m,V),yield G(500),yield Z(p,m,e.zoom),yield p.removeObjectByName(m.id,"box"),yield p.clearPointCloudAndRender()}s(d),v(t,!1)}}))()},[]),n.createElement("div",{style:a,ref:l,className:"generate-view"})},te=i=>({predictionResult:i.annotation.predictionResult,predictionResultVisible:i.annotation.predictionResultVisible,imgList:i.annotation.imgList});var ne=L(te,null,null,{context:$})(X);export{ne as default};
1
+ import w from"classnames";import n,{useState as j,useRef as S,useEffect as F}from"react";import{useTranslation as _}from"react-i18next";import{connect as L}from"react-redux";import{PointCloudContext as B}from"../../pointCloudView/PointCloudContext.js";import{SetPredictResultVisible as D,SetPredictResult as T,SetPointCloudLoading as v,BatchUpdateImgListResultByPredictResult as I}from"../../../store/annotation/actionCreators.js";import{LabelBeeContext as U,useDispatch as E}from"../../../store/ctx.js";import{getClassName as o}from"../../../utils/dom.js";import{PointCloud as $}from"@labelbee/lb-annotation";import{PointCloudUtils as z,toolStyleConverter as A}from"@labelbee/lb-utils";import{views as G,sleep as Z,getViewsDataUrl as q}from"./util.js";var H=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,M=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,N=(i,e,t)=>e in i?H(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,W=(i,e)=>{for(var t in e||(e={}))M.call(e,t)&&N(i,t,e[t]);if(k)for(var t of k(e))Q.call(e,t)&&N(i,t,e[t]);return i},X=(i,e)=>J(i,K(e)),O=(i,e,t)=>new Promise((d,r)=>{var s=a=>{try{c(t.next(a))}catch(u){r(u)}},l=a=>{try{c(t.throw(a))}catch(u){r(u)}},c=a=>a.done?d(a.value):Promise.resolve(a.value).then(s,l);c((t=t.apply(i,e)).next())});const Y=i=>{const{predictionResult:e,predictionResultVisible:t,imgList:d}=i,[r,s]=j([]),l=E(),{t:c}=_(),a=()=>{D(l,!1),T(l,[]),s([])},u=()=>O(void 0,null,function*(){v(l,!0),yield l(I()),v(l,!1),a()});return t?n.createElement(n.Fragment,null,r.length>0&&n.createElement("div",{className:o("point-cloud-predict-tracking-container")},n.createElement("div",{className:o("point-cloud-predict-tracking-container","bar")},n.createElement("div",{className:o("point-cloud-predict-tracking-container","title")},n.createElement("div",null,c("ComplementaryTrackingPrediction"),r.length>0?`\uFF08${r.length}\uFF09`:""),n.createElement("div",{className:o("point-cloud-predict-tracking-container","option")},n.createElement("div",{className:w([o("point-cloud-predict-tracking-container","cancelOption"),o("point-cloud-predict-tracking-container","button")]),onClick:a},c("Cancel")),n.createElement("div",{className:w([o("point-cloud-predict-tracking-container","okOption"),o("point-cloud-predict-tracking-container","button")]),onClick:u},c("Apply")))),n.createElement("div",{className:o("point-cloud-predict-tracking-container","content")},n.createElement(ee,{list:r})))),e.length>0&&n.createElement(te,{result:e,imgList:d,setList:s})):null},ee=i=>{const{list:e}=i,{t}=_(),d=[t("TopView"),t("SideView"),t("BackView")];return n.createElement(n.Fragment,null,n.createElement("div",{className:o("point-cloud-predict-tracking-container","left")},d.map(r=>n.createElement("div",{className:o("point-cloud-predict-tracking-container","title"),key:r},r))),n.createElement("div",{className:o("point-cloud-predict-tracking-container","right")},e.map(r=>n.createElement("div",{className:o("point-cloud-predict-tracking-container","item"),key:r.id},G.map(s=>{const l=r[s];return n.createElement("div",{className:o("point-cloud-predict-tracking-container","view"),key:`${r.id}-${s}`},n.createElement("img",{src:l}))})))))},te=i=>{const e=n.useContext(B),t=E(),{result:d,imgList:r,setList:s}=i,l=S(null),c={width:600,height:600};return F(()=>{(()=>O(void 0,null,function*(){var u,P,h,y,C,b;const f=(u=e.mainViewInstance)==null?void 0:u.config;if(f&&l.current){const R=z.getDefaultOrthographicParams(c),p=new $({container:l.current,isOrthographicCamera:!0,orthographicParams:R,config:f});p.setShowDirection(!1);for(const m of d){const{index:g}=m,x=r[g].url?r[g].url:(C=(y=(h=(P=r[g])==null?void 0:P.webPointCloudFile)==null?void 0:h.lidar)==null?void 0:y.url)!=null?C:"";yield p.loadPCDFileByBox(x,m,{width:2,height:2,depth:2}),yield p.updateCameraZoom(e.zoom);const V=(b=A.getColorFromConfig({attribute:m.attribute},X(W({},f),{attributeConfigurable:!0}),{}))==null?void 0:b.fill;p.generateBox(m,V),yield Z(500),yield q(p,m,e.zoom),yield p.removeObjectByName(m.id,"box"),yield p.clearPointCloudAndRender()}s(d),v(t,!1)}}))()},[]),n.createElement("div",{style:c,ref:l,className:"generate-view"})},ne=i=>({predictionResult:i.annotation.predictionResult,predictionResultVisible:i.annotation.predictionResultVisible,imgList:i.annotation.imgList});var ie=L(ne,null,null,{context:U})(Y);export{ie as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.12.0-alpha.8",
3
+ "version": "1.12.0",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.16.0-alpha.6",
47
- "@labelbee/lb-utils": "1.8.0-alpha.5",
46
+ "@labelbee/lb-annotation": "1.16.0",
47
+ "@labelbee/lb-utils": "1.8.0",
48
48
  "ahooks": "^3.4.0",
49
49
  "classnames": "^2.3.0",
50
50
  "lodash": "^4.17.21",