@labelbee/lb-components 1.18.0-dev.2 → 1.18.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(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
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var React__default=_interopDefaultLegacy(React);const PointCloudAnnotationView=n=>{const{src:l,result:o,size:i,isOrthographicCamera:u=!1,backgroundColor:f="#ccc",getInstance:c}=n;let s=React.useRef();const r=React.useRef(),b=React.useCallback(e=>{s.current=e},[]);return React.useEffect(()=>{let e={container:s.current,backgroundColor:f,isOrthographicCamera:u};u&&Object.assign(e,{orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(i)});const a=new lbAnnotation.PointCloud(e);return r.current=a,c&&r.current.on("loadPCDFileEnd",()=>{c(r.current)}),()=>{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(()=>(o&&lbUtils.PointCloudUtils.getBoxParamsFromResultList(o).forEach(a=>{var t;(t=r.current)==null||t.generateBox(a,a.id)}),()=>{var e;lbUtils.PointCloudUtils.getBoxParamsFromResultList(o).forEach(t=>{var d;(d=r.current)==null||d.removeObjectByName(t.id,"box")}),(e=r.current)==null||e.render()}),[o]),React__default.default.createElement("div",{style:i,ref:b})};module.exports=PointCloudAnnotationView;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),Markdown=require("react-markdown"),remarkMath=require("remark-math"),rehypeKatex=require("rehype-katex"),SyntaxHighlighter=require("react-syntax-highlighter"),hljs=require("react-syntax-highlighter/dist/esm/styles/hljs"),remarkGfm=require("remark-gfm");require("github-markdown-css");var index_module=require("./index.module.scss.js"),index=require("../../utils/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),Markdown__default=_interopDefaultLegacy(Markdown),remarkMath__default=_interopDefaultLegacy(remarkMath),rehypeKatex__default=_interopDefaultLegacy(rehypeKatex),SyntaxHighlighter__default=_interopDefaultLegacy(SyntaxHighlighter),remarkGfm__default=_interopDefaultLegacy(remarkGfm),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,a)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,__spreadValues=(e,r)=>{for(var a in r||(r={}))__hasOwnProp.call(r,a)&&__defNormalProp(e,a,r[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(r))__propIsEnum.call(r,a)&&__defNormalProp(e,a,r[a]);return e},__spreadProps=(e,r)=>__defProps(e,__getOwnPropDescs(r)),__objRest=(e,r)=>{var a={};for(var t in e)__hasOwnProp.call(e,t)&&r.indexOf(t)<0&&(a[t]=e[t]);if(e!=null&&__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))r.indexOf(t)<0&&__propIsEnum.call(e,t)&&(a[t]=e[t]);return a};const MarkdownView=e=>{const{value:r,transformImageUri:a,transformLinkUri:t,components:d}=e,u=f=>{var n=f,{node:m,inline:c,className:l,children:i}=n,o=__objRest(n,["node","inline","className","children"]);const s=/language-(\w+)/.exec(l||"");return!c&&s?React__default.default.createElement(SyntaxHighlighter__default.default,__spreadProps(__spreadValues({},o),{className:"markdown-code-viewer",language:s[1],style:hljs.docco,PreTag:"div"}),String(i).replace(/\n$/,"")):React__default.default.createElement("code",__spreadProps(__spreadValues({},o),{className:l}),i)};return React__default.default.createElement(Markdown__default.default,{className:index.classnames({"markdown-body":!0,[index_module.markdownView]:!0}),remarkPlugins:[remarkGfm__default.default,remarkMath__default.default],rehypePlugins:[rehypeKatex__default.default],transformImageUri:a,transformLinkUri:t,components:__spreadValues({code:u},d)},r)};module.exports=MarkdownView;
1
+ "use strict";var React=require("react"),Markdown=require("react-markdown"),remarkMath=require("remark-math"),rehypeKatex=require("rehype-katex"),SyntaxHighlighter=require("react-syntax-highlighter"),hljs=require("react-syntax-highlighter/dist/esm/styles/hljs"),remarkGfm=require("remark-gfm");require("github-markdown-css");var index_module=require("./index.module.scss.js"),index=require("../../utils/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),Markdown__default=_interopDefaultLegacy(Markdown),remarkMath__default=_interopDefaultLegacy(remarkMath),rehypeKatex__default=_interopDefaultLegacy(rehypeKatex),SyntaxHighlighter__default=_interopDefaultLegacy(SyntaxHighlighter),remarkGfm__default=_interopDefaultLegacy(remarkGfm),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,a)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,__spreadValues=(e,r)=>{for(var a in r||(r={}))__hasOwnProp.call(r,a)&&__defNormalProp(e,a,r[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(r))__propIsEnum.call(r,a)&&__defNormalProp(e,a,r[a]);return e},__spreadProps=(e,r)=>__defProps(e,__getOwnPropDescs(r)),__objRest=(e,r)=>{var a={};for(var t in e)__hasOwnProp.call(e,t)&&r.indexOf(t)<0&&(a[t]=e[t]);if(e!=null&&__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))r.indexOf(t)<0&&__propIsEnum.call(e,t)&&(a[t]=e[t]);return a};const MarkdownView=e=>{const{value:r,transformImageUri:a,transformLinkUri:t,components:d}=e,u=f=>{var n=f,{node:m,inline:c,className:l,children:i}=n,o=__objRest(n,["node","inline","className","children"]);const s=/language-(\w+)/.exec(l||"");return!c&&s?React__default.default.createElement(SyntaxHighlighter__default.default,__spreadProps(__spreadValues({},o),{className:"markdown-code-viewer",language:s[1],style:hljs.docco,PreTag:"div"}),String(i).replace(/\n$/,"")):React__default.default.createElement("code",__spreadProps(__spreadValues({},o),{className:l}),i)};return React__default.default.createElement(Markdown__default.default,{className:index.classnames({"markdown-body":!0,[index_module.markdownView]:!0}),remarkPlugins:[remarkGfm__default.default,remarkMath__default.default],rehypePlugins:[[rehypeKatex__default.default,{output:"mathml"}]],transformImageUri:a,transformLinkUri:t,components:__spreadValues({code:u},d)},r)};module.exports=MarkdownView;
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),reactRedux=require("react-redux"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),map=require("../../store/annotation/map.js"),lbUtils=require("@labelbee/lb-utils"),PointCloud2DSingleView=require("./PointCloud2DSingleView.js"),index=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),classNames=require("classnames"),icon_esc=require("../../assets/annotation/common/icon_esc.svg.js"),icon_left_squareOutlined=require("../../assets/annotation/common/icon_left_squareOutlined.svg.js"),icon_right_squareOutlined=require("../../assets/annotation/common/icon_right_squareOutlined.svg.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,n,t)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,__spreadValues=(e,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(e,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(e,t,n[t]);return e},__spreadProps=(e,n)=>__defProps(e,__getOwnPropDescs(n));const EKeyCode=lbAnnotation.cKeyCode.default,ContainerTitle=({showEnlarge:e,isEnlargeTopView:n,data:t,setIsEnlarge:v,setCurIndex:u,curIndex:p=0,index:E,annotations2d:c})=>n?React__default.default.createElement(index,{title:t==null?void 0:t.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{v(!1),u(void 0)}}),React__default.default.createElement("span",null,t==null?void 0:t.calName),React__default.default.createElement("span",{style:{marginLeft:"8px"}},p+1,"/",c==null?void 0:c.length)):React__default.default.createElement(index,{title:t==null?void 0:t.calName,onClick:()=>{v(!0),u(E)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),PointCloud2DView=({currentData:e,config:n,thumbnailWidth:t,isEnlargeTopView:v,highlightAttribute:u,loadPCDFileLoading:p,checkMode:E})=>{var c;const[s,j]=React.useState([]),{topViewInstance:k,displayPointCloudList:w}=React.useContext(PointCloudContext.PointCloudContext),[_,I]=React.useState(""),[m,b]=React.useState(!1),[a,g]=React.useState(void 0);React.useEffect(()=>{var l;if(!p&&k&&(e==null?void 0:e.mappingImgList)&&((l=e==null?void 0:e.mappingImgList)==null?void 0:l.length)>0){const o={fill:"transparent",color:"green"};let i=[];e==null||e.mappingImgList.forEach(r=>{var d;const V=w.reduce((A,f)=>{var h,L;const T=f.id===_||u===f.attribute,{transferViewData:q,viewRangePointList:y}=(h=lbAnnotation.pointCloudLidar2image(f,r.calib,{createRange:T}))!=null?h:{};if(!q||!y)return[];const O=(L=lbUtils.toolStyleConverter.getColorFromConfig({attribute:f.attribute},__spreadProps(__spreadValues({},n),{attributeConfigurable:!0}),{}))==null?void 0:L.stroke,K=S({viewDataPointList:q,pointCloudBox:f,defaultViewStyle:o,stroke:O}),F=[...A,...K];return(y==null?void 0:y.length)>0&&F.unshift({type:"polygon",annotation:__spreadProps(__spreadValues({id:_,pointList:y},o),{stroke:O,fill:"rgba(255, 255, 255, 0.6)"})}),F},[]);i.push({annotations:V,url:r==null?void 0:r.url,calName:(d=r==null?void 0:r.calib)==null?void 0:d.calName,calib:r==null?void 0:r.calib,path:r==null?void 0:r.path})}),j(i)}},[w,e==null?void 0:e.mappingImgList,_,u,p]),React.useEffect(()=>(window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x)}),[a]);const x=l=>{const{keyCode:o}=l;switch(o){case EKeyCode.Esc:m&&b(!1);break;case EKeyCode.Left:C();break;case EKeyCode.Right:P();break}},C=()=>{a===void 0||!m||Number(a)>0&&g(a-1)},P=()=>{a===void 0||!m||Number(a)<(s==null?void 0:s.length)-1&&g(a+1)},S=({viewDataPointList:l,pointCloudBox:o,defaultViewStyle:i,stroke:r})=>l?l.map(d=>({type:d.type,annotation:__spreadProps(__spreadValues({id:o.id,pointList:d.pointList},i),{stroke:r})})):[],N=!e||!(e==null?void 0:e.mappingImgList)||!(((c=e==null?void 0:e.mappingImgList)==null?void 0:c.length)>0),R=React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},React__default.default.createElement("img",{src:icon_left_squareOutlined,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>C()}),React__default.default.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),React__default.default.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),React__default.default.createElement("img",{src:icon_right_squareOutlined,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>P()}),React__default.default.createElement("img",{src:icon_esc,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{b(!1),g(void 0)}}),React__default.default.createElement("span",null,"\u952E\u9000\u51FA"));return(s==null?void 0:s.length)>0?React__default.default.createElement(React__default.default.Fragment,null,s.map((l,o)=>{const i=m&&o===a;return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-2d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:i}),title:React__default.default.createElement(ContainerTitle,{showEnlarge:i,isEnlargeTopView:v,data:l,setIsEnlarge:b,setCurIndex:g,curIndex:a,index:o,annotations2d:s}),titleOnSurface:!i,style:{display:N?"none":"flex",width:i?"100%":t},key:o,toolbar:R},(l==null?void 0:l.annotations)&&(l==null?void 0:l.url)&&React__default.default.createElement(PointCloud2DSingleView,{currentData:e,view2dData:l,setSelectedID:I,showEnlarge:i,checkMode:E}))})):null};var PointCloud2DView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DView);module.exports=PointCloud2DView$1;
1
+ "use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),reactRedux=require("react-redux"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),map=require("../../store/annotation/map.js"),lbUtils=require("@labelbee/lb-utils"),PointCloud2DSingleView=require("./PointCloud2DSingleView.js"),index=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),classNames=require("classnames"),icon_esc=require("../../assets/annotation/common/icon_esc.svg.js"),icon_left_squareOutlined=require("../../assets/annotation/common/icon_left_squareOutlined.svg.js"),icon_right_squareOutlined=require("../../assets/annotation/common/icon_right_squareOutlined.svg.js"),_=require("lodash");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,l,t)=>l in e?__defProp(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,__spreadValues=(e,l)=>{for(var t in l||(l={}))__hasOwnProp.call(l,t)&&__defNormalProp(e,t,l[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(l))__propIsEnum.call(l,t)&&__defNormalProp(e,t,l[t]);return e},__spreadProps=(e,l)=>__defProps(e,__getOwnPropDescs(l));const EKeyCode=lbAnnotation.cKeyCode.default,ContainerTitle=({showEnlarge:e,isEnlargeTopView:l,data:t,setIsEnlarge:p,setCurIndex:f,curIndex:b=0,index:w,annotations2d:v})=>l?React__default.default.createElement(index,{title:t==null?void 0:t.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{p(!1),f(void 0)}}),React__default.default.createElement("span",null,t==null?void 0:t.calName),React__default.default.createElement("span",{style:{marginLeft:"8px"}},b+1,"/",v==null?void 0:v.length)):React__default.default.createElement(index,{title:t==null?void 0:t.calName,onClick:()=>{p(!0),f(w)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),PointCloud2DView=({currentData:e,config:l,thumbnailWidth:t,isEnlargeTopView:p,highlightAttribute:f,loadPCDFileLoading:b,checkMode:w})=>{var v;const[c,K]=React.useState([]),{topViewInstance:H,displayPointCloudList:L,polygonList:q,imageSizes:F,selectedIDs:O}=React.useContext(PointCloudContext.PointCloudContext),[x,M]=React.useState(""),[y,P]=React.useState(!1),[s,E]=React.useState(void 0);React.useEffect(()=>{var o;if(!b&&H&&(e==null?void 0:e.mappingImgList)&&((o=e==null?void 0:e.mappingImgList)==null?void 0:o.length)>0){const i={fill:"transparent",color:"green"};let r=[];e==null||e.mappingImgList.forEach(n=>{var m,j,N;const R=L.reduce((d,u)=>{var g,a;const C=u.id===x||f===u.attribute,{transferViewData:A,viewRangePointList:h}=(g=lbAnnotation.pointCloudLidar2image(u,n.calib,{createRange:C}))!=null?g:{};if(!A||!h)return[];const z=(a=lbUtils.toolStyleConverter.getColorFromConfig({attribute:u.attribute},__spreadProps(__spreadValues({},l),{attributeConfigurable:!0}),{}))==null?void 0:a.stroke,J=U({viewDataPointList:A,pointCloudBox:u,defaultViewStyle:i,stroke:z}),T=[...d,...J];return(h==null?void 0:h.length)>0&&T.unshift({type:"polygon",annotation:__spreadProps(__spreadValues({id:x,pointList:h},i),{stroke:z,fill:"rgba(255, 255, 255, 0.6)"})}),T},[]),V=F[(m=n==null?void 0:n.path)!=null?m:""];V&&_.isNumber((j=n==null?void 0:n.calib)==null?void 0:j.groundHeight)&&q.forEach(d=>{const u=d.pointList.map(a=>{var C;return __spreadProps(__spreadValues({},a),{z:(C=n==null?void 0:n.calib)==null?void 0:C.groundHeight})}),g=lbAnnotation.pointListLidar2Img(u,n==null?void 0:n.calib,V);if(g){const a=lbUtils.toolStyleConverter.getColorFromConfig({attribute:d.attribute},__spreadProps(__spreadValues({},l),{attributeConfigurable:!0}),{});R.push({type:"polygon",annotation:__spreadProps(__spreadValues({id:d.id,pointList:g},i),{stroke:a==null?void 0:a.stroke,fill:O.includes(d.id)?a==null?void 0:a.fill:"rgba(255, 255, 255, 0.6)"})})}}),r.push({annotations:R,url:n==null?void 0:n.url,calName:(N=n==null?void 0:n.calib)==null?void 0:N.calName,calib:n==null?void 0:n.calib,path:n==null?void 0:n.path})}),K(r)}},[L,e==null?void 0:e.mappingImgList,x,f,b,q,F,O]),React.useEffect(()=>(window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}),[s]);const S=o=>{const{keyCode:i}=o;switch(i){case EKeyCode.Esc:y&&P(!1);break;case EKeyCode.Left:k();break;case EKeyCode.Right:I();break}},k=()=>{s===void 0||!y||Number(s)>0&&E(s-1)},I=()=>{s===void 0||!y||Number(s)<(c==null?void 0:c.length)-1&&E(s+1)},U=({viewDataPointList:o,pointCloudBox:i,defaultViewStyle:r,stroke:n})=>o?o.map(m=>({type:m.type,annotation:__spreadProps(__spreadValues({id:i.id,pointList:m.pointList},r),{stroke:n})})):[],$=!e||!(e==null?void 0:e.mappingImgList)||!(((v=e==null?void 0:e.mappingImgList)==null?void 0:v.length)>0),G=React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},React__default.default.createElement("img",{src:icon_left_squareOutlined,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>k()}),React__default.default.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),React__default.default.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),React__default.default.createElement("img",{src:icon_right_squareOutlined,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>I()}),React__default.default.createElement("img",{src:icon_esc,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{P(!1),E(void 0)}}),React__default.default.createElement("span",null,"\u952E\u9000\u51FA"));return(c==null?void 0:c.length)>0?React__default.default.createElement(React__default.default.Fragment,null,c.map((o,i)=>{const r=y&&i===s;return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-2d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:r}),title:React__default.default.createElement(ContainerTitle,{showEnlarge:r,isEnlargeTopView:p,data:o,setIsEnlarge:P,setCurIndex:E,curIndex:s,index:i,annotations2d:c}),titleOnSurface:!r,style:{display:$?"none":"flex",width:r?"100%":t},key:i,toolbar:G},(o==null?void 0:o.annotations)&&(o==null?void 0:o.url)&&React__default.default.createElement(PointCloud2DSingleView,{currentData:e,view2dData:o,setSelectedID:M,showEnlarge:r,checkMode:w}))})):null};var PointCloud2DView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DView);module.exports=PointCloud2DView$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"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__spreadValues=(e,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(e,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(e,i,t[i]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,i)=>new Promise((a,o)=>{var d=u=>{try{c(i.next(u))}catch(h){o(h)}},P=u=>{try{c(i.throw(u))}catch(h){o(h)}},c=u=>u.done?a(u.value):Promise.resolve(u.value).then(d,P);c((i=i.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,i,a,o)=>{const{x:d,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,u={center:{x:d,y:P,z:c},id:e.id},h=a?__spreadValues(__spreadValues({},a),u):__spreadProps(__spreadValues({},u),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,i,a,o,d)=>{let P=e.pointList.map(L=>lbUtils.PointCloudUtils.transferCanvas2World(L,t)),c=0,u=1,h={};if(i){const L=i.getSensesPointZAxisInPolygon(P,void 0,d);d&&L.fittedCoordinates.length>0&&(P=L.fittedCoordinates),c=(L.maxZ+L.minZ)/2,u=L.maxZ-L.minZ,h={count:L.zCount}}const[v,b,T]=P,V=lbAnnotation.MathUtils.getLineCenterPoint([v,T]),_=lbAnnotation.MathUtils.getLineLength(v,b),D=lbAnnotation.MathUtils.getLineLength(b,T),A=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(c=a.center.z,u=a.depth);const k={center:{x:V.x,y:V.y,z:c},width:d?D+INTELLIGENT_FIT_MARGIN:D,height:d?_+INTELLIGENT_FIT_MARGIN:_,depth:u,rotation:A,id:e.id},O=__spreadValues(a?__spreadValues(__spreadValues({},a),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),h);o&&Object.assign(O,o);const z=P.map(L=>lbUtils.PointCloudUtils.transferWorld2Canvas(L,t));return{boxParams:O,newPointList:z}},sideViewPoint2PointCloud=(e,t,i)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-a.x,y:i.center.y,z:i.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,i,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),V={x:{x:v.x-b.x,y:v.y-b.y}.x,y:0,z:v.y-b.y},_=lbAnnotation.MathUtils.getLineLength(o,d),D=lbAnnotation.MathUtils.getLineLength(c,u),A=_-D,k=lbAnnotation.MathUtils.getLineLength(d,P),O=lbAnnotation.MathUtils.getLineLength(u,h),z=k-O,{newBoxParams:L}=a.getNewBoxBySideUpdate(V,z,A,i);return L},backViewPoint2PointCloud=(e,t,i)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-a.x,z:i.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,i,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),V={x:{x:v.x-b.x,y:v.y-b.y}.x,y:0,z:v.y-b.y},_=lbAnnotation.MathUtils.getLineLength(o,d),D=lbAnnotation.MathUtils.getLineLength(c,u),A=_-D,k=lbAnnotation.MathUtils.getLineLength(d,P),O=lbAnnotation.MathUtils.getLineLength(u,h),z=k-O;let{newBoxParams:L}=a.getNewBoxByBackUpdate(V,z,A,i);return L},syncSideViewByPoint=(e,t,i,a,o)=>{var d;if(!i)return;const{toolInstance:P,pointCloudInstance:c}=i;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(u);const{point2d:h,zoom:v}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,i,a)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=i;d.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxSidePolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,i,a,o)=>{var d;if(!i)return;const{toolInstance:P,pointCloudInstance:c}=i;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(u);const{point2d:h,zoom:v}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,i,a)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=i;d.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxBackPolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,i,a)=>{if(!i||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:d}=i,{point2d:P}=d.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,i,a)=>{var o,d;if(!i||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],v=h.find(b=>b.id===t.id);v?(v.pointList=u,v.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=e.valid)!=null?d:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:i,backViewInstance:a,mainViewInstance:o,addPointCloudBox:d,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:h,pointCloudSphereList:v,hideAttributes:b,setHighlight2DDataList:T,cuboidBoxIn2DView:V,imageSizes:_}=e,{addHistory:D,initHistory:A,pushHistoryUnderUpdatePolygon:k}=useHistory.useHistory(),{selectedPolygon:O}=usePolygon.usePolygon(),{getPointCloudSphereByID:z,updatePointCloudSphere:L,selectedSphere:q}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),R=ctx.useDispatch(),tt=ahooks.useLatest(V),W=n=>{if(!tt.current){const{mappingImgList:s=[]}=j,p=s.map(r=>index.getRectPointCloudBox({pointCloudBox:n,mappingData:r,imageSizes:_}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:I,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),{t:nt}=reactI18next.useTranslation(),X=I==null?void 0:I.info;if(!t||!i||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},st=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},rt=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const C={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const g=topViewPoint2PointCloud(n,s,G,void 0,C);c(n.id);const f=P(g);H(PointCloudView.Top,n,g,p,f,m),D({newSphereParams:g})},lt=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:C})=>{var g,f;const x={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};r===!0&&Object.assign(x,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:v})});const B=t==null?void 0:t.toolInstance,w=__spreadValues({},n);let{boxParams:y,newPointList:U}=topViewPolygon2PointCloud(w,s,G,void 0,x,C);if(y=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[y],stepConfig:m,action:"viewUpdateBox"}))[0],(m==null?void 0:m.lowerLimitPointsNumInBox)&&typeof y.count=="number"&&y.count<m.lowerLimitPointsNumInBox){antd.message.info(nt("LowerLimitPointsNumInBox",{num:m.lowerLimitPointsNumInBox})),B.deletePolygon(y.id);return}C&&(U==null?void 0:U.length)&&(w.pointList=U);const S=b.includes(w.attribute);W(y);const N=d(y),Q=(f=e==null?void 0:e.polygonList)!=null?f:[];t==null||t.updatePolygonList(N!=null?N:[],Q),S?c([]):(c(y.id),B.selection.setSelectedIDs(w.id),E({omitView:PointCloudView.Top,polygon:w,boxParams:y,zoom:l,newPointCloudBoxList:N}),C&&synchronizeTopView(y,w,t,o)),D({newBoxParams:y})},at=n=>{const{boxID:s,imageName:p,width:r,height:l,x:C,y:g}=n,f=h.find(x=>x.id===s);if(f==null?void 0:f.rects){const{rects:x=[]}=f,B=x.find(w=>w.imageName===p);if(B){let w=x;const y=__spreadProps(__spreadValues({},B),{width:r,height:l,x:C,y:g});w=x.map(S=>S===B?y:S);const U=__spreadProps(__spreadValues({},f),{rects:w}),M=h.map(S=>S===f?U:S);return t==null||t.updatePolygonList(M!=null?M:[]),M}}},dt=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const C=t==null?void 0:t.toolInstance;if(!(u.length===0||!C)){if(n||(I==null?void 0:I.info)){const g=n!=null?n:I==null?void 0:I.info;(l=C==null?void 0:C.selection)==null||l.setSelectedIDs(u[0]);const f=C.selectedPolygon;if(u.length===1&&g){E({omitView:PointCloudView.Top,polygon:f,boxParams:g,newPointCloudBoxList:s});return}}if((p||q)&&u.length===1){const g=p!=null?p:q;C.setSelectedID(u[0]);const f=C.selectedPoint;g&&H(PointCloudView.Top,f,g,void 0,r,m)}}},Y=(n,s,p)=>{if(X){let r,l;switch(p){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}l=r(n,s,X,i.pointCloudInstance);const g=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:m,action:"viewUpdateBox"}))[0],f=l.valid!==g.valid;if(l=g,o){const{count:B}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:B})}const x=ot(l);return l=x.find(B=>B.id===l.id),E({omitView:f?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:x}),x}},J=(n,s,p)=>{if(q){let r,l;switch(p){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(n,s,q);const C=L(l);return H(p,n,l,void 0,C,m),C}},ct=(n,s)=>{J(n,s,PointCloudView.Side)},ut=(n,s)=>{J(n,s,PointCloudView.Back)},pt=(n,s)=>{Y(n,s,PointCloudView.Side)},Pt=(n,s)=>{Y(n,s,PointCloudView.Back)},Ct=(n,s)=>{const p=z(n.id),r=topViewPoint2PointCloud(n,s,G,p),l=L(r);H(PointCloudView.Top,n,r,void 0,l,m)},gt=(n,s)=>{if(O){const r=n[0].newPolygon;r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,s)),k(n[0].newPolygon);return}let p=n.map(({newPolygon:r})=>{const l=et(r.id),{boxParams:C}=topViewPolygon2PointCloud(r,s,t.pointCloudInstance,l);return C});if(p=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:m,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=Z(p);E({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=Z(p);r&&e.syncAllViewPointCloudColor(r)}},ht=n=>{var s,p,r,l,C;if(I){const g=Number(n.widthDefault),f=Number(n.depthDefault),x=Number(n.heightDefault),B=I==null?void 0:I.info.trackID,y=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(F=>(F==null?void 0:F.trackID)===B),U={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(C=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:C.height},M=y.pointList.map(F=>lbUtils.PointCloudUtils.transferCanvas2World(F,U)),S=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(M,x,g),N=S[0],Q=S[2],K=lbAnnotation.MathUtils.getLineCenterPoint([N,Q]),ft=I.info.center.z-I.info.depth/2,$=__spreadProps(__spreadValues({},I.info),{center:{x:K.x,y:K.y,z:ft+f/2},width:g,height:x,depth:f,valid:!0}),xt=Z([$]);E({omitView:PointCloudView["3D"],polygon:y,boxParams:$,newPointCloudBoxList:xt})}},H=(n,s,p,r,l,C)=>__async(void 0,null,function*(){const g=j==null?void 0:j.url,f={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,i,g,C)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(p,s,a,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,t,o)}};Object.keys(f).forEach(x=>{x!==n&&f[x]()}),r&&(o==null||o.updateCameraZoom(r)),st(p)}),E=n=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:C}=n,g=j==null?void 0:j.url;C&&(yield e.syncAllViewPointCloudColor(C));const f={[PointCloudView.Side]:()=>{synchronizeSideView(r,p,i,g)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(r,p,a,g)},[PointCloudView.Top]:()=>{synchronizeTopView(r,p,t,o)}};Object.keys(f).forEach(x=>{x!==s&&f[x]()}),l&&(o==null||o.updateCameraZoom(l)),it(r)});return{topViewAddSphere:rt,topViewAddBox:lt,topViewSelectedChanged:dt,topViewUpdatePoint:Ct,sideViewUpdatePoint:ct,backViewUpdatePoint:ut,topViewUpdateBox:gt,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=j){var p,r,l,C,g,f;if(!(s==null?void 0:s.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(R,!0),actionCreators.SetLoadPCDFileLoading(R,!0),yield o.loadPCDFile(s.url,(p=m==null?void 0:m.radius)!=null?p:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],B=[],w=[],y=[];o.updateTopCamera();const U=(l=(r=index.jsonParser(s.result))==null?void 0:r.valid)!=null?l:!0;e.setPointCloudValid(U),(C=e.sideViewInstance)==null||C.clearAllData(),(g=e.backViewInstance)==null||g.clearAllData(),t.updateData(s.url,s.result,{radius:(f=m==null?void 0:m.radius)!=null?f:DEFAULT_RADIUS}),s.result&&(x=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),w=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),y=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),o==null||o.generateBoxes(x),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(x,[])),A({pointCloudBoxList:x,polygonList:w,lineList:B,pointCloudSphereList:y}),actionCreators.SetPointCloudLoading(R,!1),actionCreators.SetLoadPCDFileLoading(R,!1)}),updateViewsByDefaultSize:ht,generateRects:W,update2DViewRect:at}};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"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,n)=>new Promise((a,o)=>{var d=u=>{try{c(n.next(u))}catch(h){o(h)}},P=u=>{try{c(n.throw(u))}catch(h){o(h)}},c=u=>u.done?a(u.value):Promise.resolve(u.value).then(d,P);c((n=n.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,n,a,o)=>{const{x:d,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,u={center:{x:d,y:P,z:c},id:e.id},h=a?__spreadValues(__spreadValues({},a),u):__spreadProps(__spreadValues({},u),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,n,a,o,d)=>{let P=e.pointList.map(L=>lbUtils.PointCloudUtils.transferCanvas2World(L,t)),c=0,u=1,h={};if(n){const L=n.getSensesPointZAxisInPolygon(P,void 0,d);d&&L.fittedCoordinates.length>0&&(P=L.fittedCoordinates),c=(L.maxZ+L.minZ)/2,u=L.maxZ-L.minZ,h={count:L.zCount}}const[v,b,T]=P,V=lbAnnotation.MathUtils.getLineCenterPoint([v,T]),_=lbAnnotation.MathUtils.getLineLength(v,b),D=lbAnnotation.MathUtils.getLineLength(b,T),A=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(c=a.center.z,u=a.depth);const k={center:{x:V.x,y:V.y,z:c},width:d?D+INTELLIGENT_FIT_MARGIN:D,height:d?_+INTELLIGENT_FIT_MARGIN:_,depth:u,rotation:A,id:e.id},O=__spreadValues(a?__spreadValues(__spreadValues({},a),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),h);o&&Object.assign(O,o);const z=P.map(L=>lbUtils.PointCloudUtils.transferWorld2Canvas(L,t));return{boxParams:O,newPointList:z}},sideViewPoint2PointCloud=(e,t,n)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},n),{center:{x:n.center.x-a.x,y:n.center.y,z:n.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,n,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),V={x:{x:v.x-b.x,y:v.y-b.y}.x,y:0,z:v.y-b.y},_=lbAnnotation.MathUtils.getLineLength(o,d),D=lbAnnotation.MathUtils.getLineLength(c,u),A=_-D,k=lbAnnotation.MathUtils.getLineLength(d,P),O=lbAnnotation.MathUtils.getLineLength(u,h),z=k-O,{newBoxParams:L}=a.getNewBoxBySideUpdate(V,z,A,n);return L},backViewPoint2PointCloud=(e,t,n)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},n),{center:{x:n.center.x,y:n.center.y-a.x,z:n.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,n,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),V={x:{x:v.x-b.x,y:v.y-b.y}.x,y:0,z:v.y-b.y},_=lbAnnotation.MathUtils.getLineLength(o,d),D=lbAnnotation.MathUtils.getLineLength(c,u),A=_-D,k=lbAnnotation.MathUtils.getLineLength(d,P),O=lbAnnotation.MathUtils.getLineLength(u,h),z=k-O;let{newBoxParams:L}=a.getNewBoxByBackUpdate(V,z,A,n);return L},syncSideViewByPoint=(e,t,n,a,o)=>{var d;if(!n)return;const{toolInstance:P,pointCloudInstance:c}=n;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(u);const{point2d:h,zoom:v}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,n,a)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=n;d.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxSidePolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,n,a,o)=>{var d;if(!n)return;const{toolInstance:P,pointCloudInstance:c}=n;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(u);const{point2d:h,zoom:v}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,n,a)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=n;d.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxBackPolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,n,a)=>{if(!n||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:d}=n,{point2d:P}=d.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,n,a)=>{var o,d;if(!n||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=n,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],v=h.find(b=>b.id===t.id);v?(v.pointList=u,v.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=e.valid)!=null?d:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:n,backViewInstance:a,mainViewInstance:o,addPointCloudBox:d,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:h,pointCloudSphereList:v,hideAttributes:b,setHighlight2DDataList:T,cuboidBoxIn2DView:V,imageSizes:_}=e,{addHistory:D,initHistory:A,pushHistoryUnderUpdatePolygon:k}=useHistory.useHistory(),{selectedPolygon:O}=usePolygon.usePolygon(),{getPointCloudSphereByID:z,updatePointCloudSphere:L,selectedSphere:q}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(i=>{const{stepList:r,step:p,imgList:s,imgIndex:l}=i.annotation;return{currentData:s[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,r).config)}}),R=ctx.useDispatch(),tt=ahooks.useLatest(V),W=i=>{if(!tt.current){const{mappingImgList:r=[]}=j,p=r.map(s=>index.getRectPointCloudBox({pointCloudBox:i,mappingData:s,imageSizes:_}));Object.assign(i,{rects:p.filter(s=>s!==void 0)})}},{selectedBox:I,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),{t:it}=reactI18next.useTranslation(),X=I==null?void 0:I.info;if(!t||!n||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,nt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},st=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},rt=({newPoint:i,size:r,zoom:p,trackConfigurable:s})=>{var l;const C={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};s===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const g=topViewPoint2PointCloud(i,r,G,void 0,C);c(i.id);const f=P(g);H(PointCloudView.Top,i,g,p,f,m),D({newSphereParams:g})},lt=({polygon:i,size:r,imgList:p,trackConfigurable:s,zoom:l,intelligentFit:C})=>{var g,f;const x={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};s===!0&&Object.assign(x,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:v})});const B=t==null?void 0:t.toolInstance,w=__spreadValues({},i);let{boxParams:y,newPointList:U}=topViewPolygon2PointCloud(w,r,G,void 0,x,C);if(y=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[y],stepConfig:m,action:"viewUpdateBox"}))[0],(m==null?void 0:m.lowerLimitPointsNumInBox)&&typeof y.count=="number"&&y.count<m.lowerLimitPointsNumInBox){antd.message.info(it("LowerLimitPointsNumInBox",{num:m.lowerLimitPointsNumInBox})),B.deletePolygon(y.id);return}C&&(U==null?void 0:U.length)&&(w.pointList=U);const S=b.includes(w.attribute);W(y);const N=d(y),Q=(f=e==null?void 0:e.polygonList)!=null?f:[];t==null||t.updatePolygonList(N!=null?N:[],Q),S?c([]):(c(y.id),B.selection.setSelectedIDs(w.id),E({omitView:PointCloudView.Top,polygon:w,boxParams:y,zoom:l,newPointCloudBoxList:N}),C&&synchronizeTopView(y,w,t,o)),D({newBoxParams:y})},at=i=>{const{boxID:r,imageName:p,width:s,height:l,x:C,y:g}=i,f=h.find(x=>x.id===r);if(f==null?void 0:f.rects){const{rects:x=[]}=f,B=x.find(w=>w.imageName===p);if(B){let w=x;const y=__spreadProps(__spreadValues({},B),{width:s,height:l,x:C,y:g});w=x.map(S=>S===B?y:S);const U=__spreadProps(__spreadValues({},f),{rects:w}),M=h.map(S=>S===f?U:S);return t==null||t.updatePolygonList(M!=null?M:[]),M}}},dt=({newSelectedBox:i,newPointCloudList:r,newSelectedSphere:p,newSphereList:s})=>{var l;const C=t==null?void 0:t.toolInstance;if(!(u.length===0||!C)){if(i||(I==null?void 0:I.info)){const g=i!=null?i:I==null?void 0:I.info;(l=C==null?void 0:C.selection)==null||l.setSelectedIDs(u[0]);const f=C.selectedPolygon;if(u.length===1&&g){E({omitView:PointCloudView.Top,polygon:f,boxParams:g,newPointCloudBoxList:r});return}}if((p||q)&&u.length===1){const g=p!=null?p:q;C.setSelectedID(u[0]);const f=C.selectedPoint;g&&H(PointCloudView.Top,f,g,void 0,s,m)}}},Y=(i,r,p)=>{if(X){let s,l;switch(p){case PointCloudView.Back:s=backViewPolygon2PointCloud;break;case PointCloudView.Side:s=sideViewPolygon2PointCloud;break;default:s=sideViewPolygon2PointCloud;break}l=s(i,r,X,n.pointCloudInstance);const g=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:m,action:"viewUpdateBox"}))[0],f=l.valid!==g.valid;if(l=g,o){const{count:B}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:B})}const x=ot(l);return l=x.find(B=>B.id===l.id),E({omitView:f?void 0:p,polygon:i,boxParams:l,newPointCloudBoxList:x}),x}},J=(i,r,p)=>{if(q){let s,l;switch(p){case PointCloudView.Back:s=backViewPoint2PointCloud;break;case PointCloudView.Side:s=sideViewPoint2PointCloud;break;default:s=sideViewPoint2PointCloud;break}l=s(i,r,q);const C=L(l);return H(p,i,l,void 0,C,m),C}},ct=(i,r)=>{J(i,r,PointCloudView.Side)},ut=(i,r)=>{J(i,r,PointCloudView.Back)},pt=(i,r)=>{Y(i,r,PointCloudView.Side)},Pt=(i,r)=>{Y(i,r,PointCloudView.Back)},Ct=(i,r)=>{const p=z(i.id),s=topViewPoint2PointCloud(i,r,G,p),l=L(s);H(PointCloudView.Top,i,s,void 0,l,m)},gt=(i,r)=>{if(O){const s=__spreadValues({},i[0].newPolygon);s.pointList=s.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,r)),k(s);return}let p=i.map(({newPolygon:s})=>{const l=et(s.id),{boxParams:C}=topViewPolygon2PointCloud(s,r,t.pointCloudInstance,l);return C});if(p=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:m,action:"viewUpdateBox"})),p.length===1){const{newPolygon:s}=i[0],l=Z(p);E({polygon:s,boxParams:p[0],newPointCloudBoxList:l})}else{const s=Z(p);s&&e.syncAllViewPointCloudColor(s)}},ht=i=>{var r,p,s,l,C;if(I){const g=Number(i.widthDefault),f=Number(i.depthDefault),x=Number(i.heightDefault),B=I==null?void 0:I.info.trackID,y=((r=t==null?void 0:t.toolInstance)==null?void 0:r.polygonList).find(F=>(F==null?void 0:F.trackID)===B),U={width:(s=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:s.width,height:(C=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:C.height},M=y.pointList.map(F=>lbUtils.PointCloudUtils.transferCanvas2World(F,U)),S=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(M,x,g),N=S[0],Q=S[2],K=lbAnnotation.MathUtils.getLineCenterPoint([N,Q]),ft=I.info.center.z-I.info.depth/2,$=__spreadProps(__spreadValues({},I.info),{center:{x:K.x,y:K.y,z:ft+f/2},width:g,height:x,depth:f,valid:!0}),xt=Z([$]);E({omitView:PointCloudView["3D"],polygon:y,boxParams:$,newPointCloudBoxList:xt})}},H=(i,r,p,s,l,C)=>__async(void 0,null,function*(){const g=j==null?void 0:j.url,f={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,r,n,g,C)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(p,r,a,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,r,t,o)}};Object.keys(f).forEach(x=>{x!==i&&f[x]()}),s&&(o==null||o.updateCameraZoom(s)),st(p)}),E=i=>__async(void 0,null,function*(){const{omitView:r,polygon:p,boxParams:s,zoom:l,newPointCloudBoxList:C}=i,g=j==null?void 0:j.url;C&&(yield e.syncAllViewPointCloudColor(C));const f={[PointCloudView.Side]:()=>{synchronizeSideView(s,p,n,g)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(s,p,a,g)},[PointCloudView.Top]:()=>{synchronizeTopView(s,p,t,o)}};Object.keys(f).forEach(x=>{x!==r&&f[x]()}),l&&(o==null||o.updateCameraZoom(l)),nt(s)});return{topViewAddSphere:rt,topViewAddBox:lt,topViewSelectedChanged:dt,topViewUpdatePoint:Ct,sideViewUpdatePoint:ct,backViewUpdatePoint:ut,topViewUpdateBox:gt,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const r=lbUtils.PointCloudUtils.getDefaultOrthographicParams(i);o.initOrthographicCamera(r),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(r=j){var p,s,l,C,g,f;if(!(r==null?void 0:r.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(R,!0),actionCreators.SetLoadPCDFileLoading(R,!0),yield o.loadPCDFile(r.url,(p=m==null?void 0:m.radius)!=null?p:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],B=[],w=[],y=[];o.updateTopCamera();const U=(l=(s=index.jsonParser(r.result))==null?void 0:s.valid)!=null?l:!0;e.setPointCloudValid(U),(C=e.sideViewInstance)==null||C.clearAllData(),(g=e.backViewInstance)==null||g.clearAllData(),t.updateData(r.url,r.result,{radius:(f=m==null?void 0:m.radius)!=null?f:DEFAULT_RADIUS}),r.result&&(x=lbUtils.PointCloudUtils.getBoxParamsFromResultList(r.result),w=lbUtils.PointCloudUtils.getPolygonListFromResultList(r.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(r.result),y=lbUtils.PointCloudUtils.getSphereParamsFromResultList(r.result),o==null||o.generateBoxes(x),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(x,[])),A({pointCloudBoxList:x,polygonList:w,lineList:B,pointCloudSphereList:y}),actionCreators.SetPointCloudLoading(R,!1),actionCreators.SetLoadPCDFileLoading(R,!1)}),updateViewsByDefaultSize:ht,generateRects:W,update2DViewRect:at}};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,3 +1,4 @@
1
+ import { PointCloud } from '@labelbee/lb-annotation';
1
2
  import React from 'react';
2
3
  interface IProps {
3
4
  src: string;
@@ -8,6 +9,7 @@ interface IProps {
8
9
  };
9
10
  backgroundColor?: string;
10
11
  isOrthographicCamera?: boolean;
12
+ getInstance?: (Instance: PointCloud) => void;
11
13
  }
12
14
  declare const PointCloudAnnotationView: (props: IProps) => React.JSX.Element;
13
15
  export default PointCloudAnnotationView;
@@ -1 +1 @@
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
+ import{PointCloud as g}from"@labelbee/lb-annotation";import{PointCloudUtils as i}from"@labelbee/lb-utils";import p,{useRef as f,useCallback as C,useEffect as l}from"react";const h=b=>{const{src:c,result:o,size:n,isOrthographicCamera:s=!1,backgroundColor:v="#ccc",getInstance:u}=b;let d=f();const e=f(),P=C(r=>{d.current=r},[]);return l(()=>{let r={container:d.current,backgroundColor:v,isOrthographicCamera:s};s&&Object.assign(r,{orthographicParams:i.getDefaultOrthographicParams(n)});const a=new g(r);return e.current=a,u&&e.current.on("loadPCDFileEnd",()=>{u(e.current)}),()=>{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 m;(m=e.current)==null||m.removeObjectByName(t.id,"box")}),(r=e.current)==null||r.render()}),[o]),p.createElement("div",{style:n,ref:P})};export{h as default};
@@ -1 +1 @@
1
- import n from"react";import u from"react-markdown";import P from"remark-math";import O from"rehype-katex";import k from"react-syntax-highlighter";import{docco as x}from"react-syntax-highlighter/dist/esm/styles/hljs";import b from"remark-gfm";import"github-markdown-css";import j from"./index.module.scss.js";import{classnames as E}from"../../utils/index.js";var N=Object.defineProperty,S=Object.defineProperties,I=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,g=(r,e,t)=>e in r?N(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,i=(r,e)=>{for(var t in e||(e={}))f.call(e,t)&&g(r,t,e[t]);if(o)for(var t of o(e))d.call(e,t)&&g(r,t,e[t]);return r},_=(r,e)=>S(r,I(e)),M=(r,e)=>{var t={};for(var a in r)f.call(r,a)&&e.indexOf(a)<0&&(t[a]=r[a]);if(r!=null&&o)for(var a of o(r))e.indexOf(a)<0&&d.call(r,a)&&(t[a]=r[a]);return t};const V=r=>{const{value:e,transformImageUri:t,transformLinkUri:a,components:h}=r,v=w=>{var m=w,{node:D,inline:y,className:s,children:l}=m,c=M(m,["node","inline","className","children"]);const p=/language-(\w+)/.exec(s||"");return!y&&p?n.createElement(k,_(i({},c),{className:"markdown-code-viewer",language:p[1],style:x,PreTag:"div"}),String(l).replace(/\n$/,"")):n.createElement("code",_(i({},c),{className:s}),l)};return n.createElement(u,{className:E({"markdown-body":!0,[j.markdownView]:!0}),remarkPlugins:[b,P],rehypePlugins:[O],transformImageUri:t,transformLinkUri:a,components:i({code:v},h)},e)};export{V as default};
1
+ import n from"react";import y from"react-markdown";import P from"remark-math";import O from"rehype-katex";import k from"react-syntax-highlighter";import{docco as x}from"react-syntax-highlighter/dist/esm/styles/hljs";import b from"remark-gfm";import"github-markdown-css";import j from"./index.module.scss.js";import{classnames as E}from"../../utils/index.js";var N=Object.defineProperty,S=Object.defineProperties,I=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,g=(r,e,t)=>e in r?N(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e)=>{for(var t in e||(e={}))f.call(e,t)&&g(r,t,e[t]);if(o)for(var t of o(e))d.call(e,t)&&g(r,t,e[t]);return r},h=(r,e)=>S(r,I(e)),M=(r,e)=>{var t={};for(var a in r)f.call(r,a)&&e.indexOf(a)<0&&(t[a]=r[a]);if(r!=null&&o)for(var a of o(r))e.indexOf(a)<0&&d.call(r,a)&&(t[a]=r[a]);return t};const V=r=>{const{value:e,transformImageUri:t,transformLinkUri:a,components:_}=r,u=v=>{var i=v,{node:D,inline:w,className:s,children:l}=i,c=M(i,["node","inline","className","children"]);const p=/language-(\w+)/.exec(s||"");return!w&&p?n.createElement(k,h(m({},c),{className:"markdown-code-viewer",language:p[1],style:x,PreTag:"div"}),String(l).replace(/\n$/,"")):n.createElement("code",h(m({},c),{className:s}),l)};return n.createElement(y,{className:E({"markdown-body":!0,[j.markdownView]:!0}),remarkPlugins:[b,P],rehypePlugins:[[O,{output:"mathml"}]],transformImageUri:t,transformLinkUri:a,components:m({code:u},_)},e)};export{V as default};
@@ -1 +1 @@
1
- import{getClassName as R}from"../../utils/dom.js";import n,{useState as b,useContext as Y,useEffect as A}from"react";import{PointCloudContainer as Z}from"./PointCloudLayout.js";import{PointCloudContext as B}from"./PointCloudContext.js";import{connect as D}from"react-redux";import{cKeyCode as ee,pointCloudLidar2image as te}from"@labelbee/lb-annotation";import{LabelBeeContext as ne}from"../../store/ctx.js";import{a2MapStateToProps as oe}from"../../store/annotation/map.js";import{toolStyleConverter as ie}from"@labelbee/lb-utils";import le from"./PointCloud2DSingleView.js";import T from"./components/TitleButton/index.js";import{LeftOutlined as re}from"@ant-design/icons";import se from"classnames";import ae from"../../assets/annotation/common/icon_esc.svg.js";import ue from"../../assets/annotation/common/icon_left_squareOutlined.svg.js";import ce from"../../assets/annotation/common/icon_right_squareOutlined.svg.js";var me=Object.defineProperty,pe=Object.defineProperties,de=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,$=(e,o,t)=>o in e?me(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,h=(e,o)=>{for(var t in o||(o={}))fe.call(o,t)&&$(e,t,o[t]);if(K)for(var t of K(o))ge.call(o,t)&&$(e,t,o[t]);return e},x=(e,o)=>pe(e,de(o));const C=ee.default,ve=({showEnlarge:e,isEnlargeTopView:o,data:t,setIsEnlarge:f,setCurIndex:c,curIndex:g=0,index:w,annotations2d:m})=>o?n.createElement(T,{title:t==null?void 0:t.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?n.createElement("div",{style:{display:"flex",alignItems:"center"}},n.createElement(re,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{f(!1),c(void 0)}}),n.createElement("span",null,t==null?void 0:t.calName),n.createElement("span",{style:{marginLeft:"8px"}},g+1,"/",m==null?void 0:m.length)):n.createElement(T,{title:t==null?void 0:t.calName,onClick:()=>{f(!0),c(w)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),ye=({currentData:e,config:o,thumbnailWidth:t,isEnlargeTopView:f,highlightAttribute:c,loadPCDFileLoading:g,checkMode:w})=>{var m;const[u,q]=b([]),{topViewInstance:z,displayPointCloudList:L}=Y(B),[_,M]=b(""),[v,P]=b(!1),[a,y]=b(void 0);A(()=>{var i;if(!g&&z&&(e==null?void 0:e.mappingImgList)&&((i=e==null?void 0:e.mappingImgList)==null?void 0:i.length)>0){const r={fill:"transparent",color:"green"};let s=[];e==null||e.mappingImgList.forEach(l=>{var p;const Q=L.reduce((U,d)=>{var k,I;const W=d.id===_||c===d.attribute,{transferViewData:N,viewRangePointList:E}=(k=te(d,l.calib,{createRange:W}))!=null?k:{};if(!N||!E)return[];const S=(I=ie.getColorFromConfig({attribute:d.attribute},x(h({},o),{attributeConfigurable:!0}),{}))==null?void 0:I.stroke,X=G({viewDataPointList:N,pointCloudBox:d,defaultViewStyle:r,stroke:S}),V=[...U,...X];return(E==null?void 0:E.length)>0&&V.unshift({type:"polygon",annotation:x(h({id:_,pointList:E},r),{stroke:S,fill:"rgba(255, 255, 255, 0.6)"})}),V},[]);s.push({annotations:Q,url:l==null?void 0:l.url,calName:(p=l==null?void 0:l.calib)==null?void 0:p.calName,calib:l==null?void 0:l.calib,path:l==null?void 0:l.path})}),q(s)}},[L,e==null?void 0:e.mappingImgList,_,c,g]),A(()=>(window.addEventListener("keydown",F),()=>{window.removeEventListener("keydown",F)}),[a]);const F=i=>{const{keyCode:r}=i;switch(r){case C.Esc:v&&P(!1);break;case C.Left:O();break;case C.Right:j();break}},O=()=>{a===void 0||!v||Number(a)>0&&y(a-1)},j=()=>{a===void 0||!v||Number(a)<(u==null?void 0:u.length)-1&&y(a+1)},G=({viewDataPointList:i,pointCloudBox:r,defaultViewStyle:s,stroke:l})=>i?i.map(p=>({type:p.type,annotation:x(h({id:r.id,pointList:p.pointList},s),{stroke:l})})):[],H=!e||!(e==null?void 0:e.mappingImgList)||!(((m=e==null?void 0:e.mappingImgList)==null?void 0:m.length)>0),J=n.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},n.createElement("img",{src:ue,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>O()}),n.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),n.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),n.createElement("img",{src:ce,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>j()}),n.createElement("img",{src:ae,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{P(!1),y(void 0)}}),n.createElement("span",null,"\u952E\u9000\u51FA"));return(u==null?void 0:u.length)>0?n.createElement(n.Fragment,null,u.map((i,r)=>{const s=v&&r===a;return n.createElement(Z,{className:se({[R("point-cloud-2d-container")]:!0,[R("point-cloud-container","zoom")]:s}),title:n.createElement(ve,{showEnlarge:s,isEnlargeTopView:f,data:i,setIsEnlarge:P,setCurIndex:y,curIndex:a,index:r,annotations2d:u}),titleOnSurface:!s,style:{display:H?"none":"flex",width:s?"100%":t},key:r,toolbar:J},(i==null?void 0:i.annotations)&&(i==null?void 0:i.url)&&n.createElement(le,{currentData:e,view2dData:i,setSelectedID:M,showEnlarge:s,checkMode:w}))})):null};var Ee=D(oe,null,null,{context:ne})(ye);export{Ee as default};
1
+ import{getClassName as G}from"../../utils/dom.js";import i,{useState as L,useContext as ne,useEffect as J}from"react";import{PointCloudContainer as ie}from"./PointCloudLayout.js";import{PointCloudContext as le}from"./PointCloudContext.js";import{connect as re}from"react-redux";import{cKeyCode as se,pointCloudLidar2image as ae,pointListLidar2Img as ue}from"@labelbee/lb-annotation";import{LabelBeeContext as ce}from"../../store/ctx.js";import{a2MapStateToProps as de}from"../../store/annotation/map.js";import{toolStyleConverter as Q}from"@labelbee/lb-utils";import me from"./PointCloud2DSingleView.js";import U from"./components/TitleButton/index.js";import{LeftOutlined as pe}from"@ant-design/icons";import fe from"classnames";import ge from"../../assets/annotation/common/icon_esc.svg.js";import ve from"../../assets/annotation/common/icon_left_squareOutlined.svg.js";import be from"../../assets/annotation/common/icon_right_squareOutlined.svg.js";import{isNumber as ye}from"lodash";var Ee=Object.defineProperty,he=Object.defineProperties,we=Object.getOwnPropertyDescriptors,W=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,X=(e,n,t)=>n in e?Ee(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,p=(e,n)=>{for(var t in n||(n={}))_e.call(n,t)&&X(e,t,n[t]);if(W)for(var t of W(n))Ce.call(n,t)&&X(e,t,n[t]);return e},f=(e,n)=>he(e,we(n));const I=se.default,Pe=({showEnlarge:e,isEnlargeTopView:n,data:t,setIsEnlarge:E,setCurIndex:g,curIndex:h=0,index:x,annotations2d:v})=>n?i.createElement(U,{title:t==null?void 0:t.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?i.createElement("div",{style:{display:"flex",alignItems:"center"}},i.createElement(pe,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{E(!1),g(void 0)}}),i.createElement("span",null,t==null?void 0:t.calName),i.createElement("span",{style:{marginLeft:"8px"}},h+1,"/",v==null?void 0:v.length)):i.createElement(U,{title:t==null?void 0:t.calName,onClick:()=>{E(!0),g(x)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),Le=({currentData:e,config:n,thumbnailWidth:t,isEnlargeTopView:E,highlightAttribute:g,loadPCDFileLoading:h,checkMode:x})=>{var v;const[d,Y]=L([]),{topViewInstance:Z,displayPointCloudList:O,polygonList:j,imageSizes:S,selectedIDs:N}=ne(le),[F,B]=L(""),[w,k]=L(!1),[a,_]=L(void 0);J(()=>{var l;if(!h&&Z&&(e==null?void 0:e.mappingImgList)&&((l=e==null?void 0:e.mappingImgList)==null?void 0:l.length)>0){const r={fill:"transparent",color:"green"};let s=[];e==null||e.mappingImgList.forEach(o=>{var b,z,T;const K=O.reduce((m,c)=>{var y,u;const C=c.id===F||g===c.attribute,{transferViewData:q,viewRangePointList:P}=(y=ae(c,o.calib,{createRange:C}))!=null?y:{};if(!q||!P)return[];const H=(u=Q.getColorFromConfig({attribute:c.attribute},f(p({},n),{attributeConfigurable:!0}),{}))==null?void 0:u.stroke,oe=D({viewDataPointList:q,pointCloudBox:c,defaultViewStyle:r,stroke:H}),M=[...m,...oe];return(P==null?void 0:P.length)>0&&M.unshift({type:"polygon",annotation:f(p({id:F,pointList:P},r),{stroke:H,fill:"rgba(255, 255, 255, 0.6)"})}),M},[]),$=S[(b=o==null?void 0:o.path)!=null?b:""];$&&ye((z=o==null?void 0:o.calib)==null?void 0:z.groundHeight)&&j.forEach(m=>{const c=m.pointList.map(u=>{var C;return f(p({},u),{z:(C=o==null?void 0:o.calib)==null?void 0:C.groundHeight})}),y=ue(c,o==null?void 0:o.calib,$);if(y){const u=Q.getColorFromConfig({attribute:m.attribute},f(p({},n),{attributeConfigurable:!0}),{});K.push({type:"polygon",annotation:f(p({id:m.id,pointList:y},r),{stroke:u==null?void 0:u.stroke,fill:N.includes(m.id)?u==null?void 0:u.fill:"rgba(255, 255, 255, 0.6)"})})}}),s.push({annotations:K,url:o==null?void 0:o.url,calName:(T=o==null?void 0:o.calib)==null?void 0:T.calName,calib:o==null?void 0:o.calib,path:o==null?void 0:o.path})}),Y(s)}},[O,e==null?void 0:e.mappingImgList,F,g,h,j,S,N]),J(()=>(window.addEventListener("keydown",V),()=>{window.removeEventListener("keydown",V)}),[a]);const V=l=>{const{keyCode:r}=l;switch(r){case I.Esc:w&&k(!1);break;case I.Left:R();break;case I.Right:A();break}},R=()=>{a===void 0||!w||Number(a)>0&&_(a-1)},A=()=>{a===void 0||!w||Number(a)<(d==null?void 0:d.length)-1&&_(a+1)},D=({viewDataPointList:l,pointCloudBox:r,defaultViewStyle:s,stroke:o})=>l?l.map(b=>({type:b.type,annotation:f(p({id:r.id,pointList:b.pointList},s),{stroke:o})})):[],ee=!e||!(e==null?void 0:e.mappingImgList)||!(((v=e==null?void 0:e.mappingImgList)==null?void 0:v.length)>0),te=i.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},i.createElement("img",{src:ve,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>R()}),i.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),i.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),i.createElement("img",{src:be,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>A()}),i.createElement("img",{src:ge,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{k(!1),_(void 0)}}),i.createElement("span",null,"\u952E\u9000\u51FA"));return(d==null?void 0:d.length)>0?i.createElement(i.Fragment,null,d.map((l,r)=>{const s=w&&r===a;return i.createElement(ie,{className:fe({[G("point-cloud-2d-container")]:!0,[G("point-cloud-container","zoom")]:s}),title:i.createElement(Pe,{showEnlarge:s,isEnlargeTopView:E,data:l,setIsEnlarge:k,setCurIndex:_,curIndex:a,index:r,annotations2d:d}),titleOnSurface:!s,style:{display:ee?"none":"flex",width:s?"100%":t},key:r,toolbar:te},(l==null?void 0:l.annotations)&&(l==null?void 0:l.url)&&i.createElement(me,{currentData:e,view2dData:l,setSelectedID:B,showEnlarge:s,checkMode:x}))})):null};var xe=re(de,null,null,{context:ce})(Le);export{xe as default};
@@ -1 +1 @@
1
- import{EPointCloudName as nt,MathUtils as w,getCuboidFromPointCloudBox as Gt}from"@labelbee/lb-annotation";import{EPerspectiveView as Q,PointCloudUtils as V,DEFAULT_SPHERE_PARAMS as Qt}from"@labelbee/lb-utils";import{useContext as Xt}from"react";import{PointCloudContext as Yt}from"../PointCloudContext.js";import{useSingleBox as qt}from"./useSingleBox.js";import{useSphere as Jt}from"./useSphere.js";import{useSelector as Kt,useDispatch as $t}from"../../../store/ctx.js";import to from"../../../utils/StepUtils.js";import{jsonParser as ft,getRectPointCloudBox as oo}from"../../../utils/index.js";import{PreDataProcess as it,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{message as eo}from"antd";import{useTranslation as no}from"react-i18next";import{useHistory as io}from"./useHistory.js";import{usePolygon as so}from"./usePolygon.js";import{useLatest as ro}from"ahooks";var lo=Object.defineProperty,ao=Object.defineProperties,co=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,xt=(e,t,i)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,L=(e,t)=>{for(var i in t||(t={}))uo.call(t,i)&&xt(e,i,t[i]);if(mt)for(var i of mt(t))po.call(t,i)&&xt(e,i,t[i]);return e},O=(e,t)=>ao(e,co(t)),st=(e,t,i)=>new Promise((d,o)=>{var a=u=>{try{c(i.next(u))}catch(P){o(P)}},g=u=>{try{c(i.throw(u))}catch(P){o(P)}},c=u=>u.done?d(u.value):Promise.resolve(u.value).then(a,g);c((i=i.apply(e,t)).next())});const J=5,K=90,ht=.01,v={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},rt=(e,t,i,d,o)=>{const{x:a,y:g}=V.transferCanvas2World(e,t),{defaultZ:c}=Qt,u={center:{x:a,y:g,z:c},id:e.id},P=d?L(L({},d),u):O(L({},u),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},lt=(e,t,i,d,o,a)=>{let g=e.pointList.map(B=>V.transferCanvas2World(B,t)),c=0,u=1,P={};if(i){const B=i.getSensesPointZAxisInPolygon(g,void 0,a);a&&B.fittedCoordinates.length>0&&(g=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,u=B.maxZ-B.minZ,P={count:B.zCount}}const[h,S,F]=g,R=w.getLineCenterPoint([h,F]),z=w.getLineLength(h,S),A=w.getLineLength(S,F),N=w.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,u=d.depth);const T={center:{x:R.x,y:R.y,z:c},width:a?A+ht:A,height:a?z+ht:z,depth:u,rotation:N,id:e.id},j=L(d?L(L({},d),T):O(L({},T),{attribute:"",valid:!0}),P);o&&Object.assign(j,o);const E=g.map(B=>V.transferWorld2Canvas(B,t));return{boxParams:j,newPointList:E}},Lt=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x-d.x,y:i.center.y,z:i.center.z-d.y}})},yt=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,P]=t.pointList,h=w.getLineCenterPoint([o,g]),S=w.getLineCenterPoint([c,P]),R={x:{x:h.x-S.x,y:h.y-S.y}.x,y:0,z:h.y-S.y},z=w.getLineLength(o,a),A=w.getLineLength(c,u),N=z-A,T=w.getLineLength(a,g),j=w.getLineLength(u,P),E=T-j,{newBoxParams:B}=d.getNewBoxBySideUpdate(R,E,N,i);return B},go=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x,y:i.center.y-d.x,z:i.center.z-d.y}})},fo=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,P]=t.pointList,h=w.getLineCenterPoint([o,g]),S=w.getLineCenterPoint([c,P]),R={x:{x:h.x-S.x,y:h.y-S.y}.x,y:0,z:h.y-S.y},z=w.getLineLength(o,a),A=w.getLineLength(c,u),N=z-A,T=w.getLineLength(a,g),j=w.getLineLength(u,P),E=T-j;let{newBoxParams:B}=d.getNewBoxByBackUpdate(R,E,N,i);return B},vt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,Q.Left);c.setInitCameraPosition(u);const{point2d:P,zoom:h}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([O(L(L({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{width:J,depth:J});const{cameraPositionVector:g}=a.updateOrthoCamera(e,Q.Left);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},wt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,Q.Back);c.setInitCameraPosition(u);const{point2d:P,zoom:h}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([O(L(L({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{height:J,depth:J});const{cameraPositionVector:g}=a.updateOrthoCamera(e,Q.Back);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,i,d)=>{if(!i||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,Q.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=i,{point2d:g}=a.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},dt=(e,t,i,d)=>{var o,a;if(!i||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:g,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),P=[...g.polygonList],h=P.find(S=>S.id===t.id);h?(h.pointList=u,h.valid=(o=e.valid)!=null?o:!0):P.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(a=e.valid)!=null?a:!0}),g.setResultAndSelectedID(P,t.id)},Co=()=>{const e=Xt(Yt),{topViewInstance:t,sideViewInstance:i,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:g,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:P,pointCloudSphereList:h,hideAttributes:S,setHighlight2DDataList:F,cuboidBoxIn2DView:R,imageSizes:z}=e,{addHistory:A,initHistory:N,pushHistoryUnderUpdatePolygon:T}=io(),{selectedPolygon:j}=so(),{getPointCloudSphereByID:E,updatePointCloudSphere:B,selectedSphere:X}=Jt(),{currentData:W,config:b}=Kt(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:ft(to.getCurrentStepInfo(p,s).config)}}),H=$t(),Dt=ro(R),$=n=>{if(!Dt.current){const{mappingImgList:s=[]}=W,p=s.map(r=>oo({pointCloudBox:n,mappingData:r,imageSizes:z}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:_,updateSelectedBox:St,updateSelectedBoxes:tt,getPointCloudByID:_t}=qt({generateRects:$}),{t:Vt}=no(),at=_==null?void 0:_.info;if(!t||!i||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Ot=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},kt=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},At=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const C=rt(n,s,ot,void 0,f);c(n.id);const m=g(C);Y(v.Top,n,C,p,m,b),A({newSphereParams:C})},Ut=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var C,m;const x={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(x,{trackID:V.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:h})});const I=t==null?void 0:t.toolInstance,D=L({},n);let{boxParams:y,newPointList:U}=lt(D,s,ot,void 0,x,f);if(y=H(it({tool:nt.PointCloud,dataList:[y],stepConfig:b,action:"viewUpdateBox"}))[0],(b==null?void 0:b.lowerLimitPointsNumInBox)&&typeof y.count=="number"&&y.count<b.lowerLimitPointsNumInBox){eo.info(Vt("LowerLimitPointsNumInBox",{num:b.lowerLimitPointsNumInBox})),I.deletePolygon(y.id);return}f&&(U==null?void 0:U.length)&&(D.pointList=U);const k=S.includes(D.attribute);$(y);const G=a(y),et=(m=e==null?void 0:e.polygonList)!=null?m:[];t==null||t.updatePolygonList(G!=null?G:[],et),k?c([]):(c(y.id),I.selection.setSelectedIDs(D.id),M({omitView:v.Top,polygon:D,boxParams:y,zoom:l,newPointCloudBoxList:G}),f&&dt(y,D,t,o)),A({newBoxParams:y})},Rt=n=>{const{boxID:s,imageName:p,width:r,height:l,x:f,y:C}=n,m=P.find(x=>x.id===s);if(m==null?void 0:m.rects){const{rects:x=[]}=m,I=x.find(D=>D.imageName===p);if(I){let D=x;const y=O(L({},I),{width:r,height:l,x:f,y:C});D=x.map(k=>k===I?y:k);const U=O(L({},m),{rects:D}),Z=P.map(k=>k===m?U:k);return t==null||t.updatePolygonList(Z!=null?Z:[]),Z}}},zt=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(u.length===0||!f)){if(n||(_==null?void 0:_.info)){const C=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(u[0]);const m=f.selectedPolygon;if(u.length===1&&C){M({omitView:v.Top,polygon:m,boxParams:C,newPointCloudBoxList:s});return}}if((p||X)&&u.length===1){const C=p!=null?p:X;f.setSelectedID(u[0]);const m=f.selectedPoint;C&&Y(v.Top,m,C,void 0,r,b)}}},ct=(n,s,p)=>{if(at){let r,l;switch(p){case v.Back:r=fo;break;case v.Side:r=yt;break;default:r=yt;break}l=r(n,s,at,i.pointCloudInstance);const C=H(it({tool:nt.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;if(l=C,o){const{count:I}=o.getSensesPointZAxisInPolygon(Gt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:I})}const x=St(l);return l=x.find(I=>I.id===l.id),M({omitView:m?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:x}),x}},ut=(n,s,p)=>{if(X){let r,l;switch(p){case v.Back:r=go;break;case v.Side:r=Lt;break;default:r=Lt;break}l=r(n,s,X);const f=B(l);return Y(p,n,l,void 0,f,b),f}},Tt=(n,s)=>{ut(n,s,v.Side)},jt=(n,s)=>{ut(n,s,v.Back)},Nt=(n,s)=>{ct(n,s,v.Side)},Et=(n,s)=>{ct(n,s,v.Back)},Ht=(n,s)=>{const p=E(n.id),r=rt(n,s,ot,p),l=B(r);Y(v.Top,n,r,void 0,l,b)},Ft=(n,s)=>{if(j){const r=n[0].newPolygon;r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,s)),T(n[0].newPolygon);return}let p=n.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=lt(r,s,t.pointCloudInstance,l);return f});if(p=H(it({tool:nt.PointCloud,dataList:p,stepConfig:b,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=tt(p);M({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=tt(p);r&&e.syncAllViewPointCloudColor(r)}},Wt=n=>{var s,p,r,l,f;if(_){const C=Number(n.widthDefault),m=Number(n.depthDefault),x=Number(n.heightDefault),I=_==null?void 0:_.info.trackID,y=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(q=>(q==null?void 0:q.trackID)===I),U={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},Z=y.pointList.map(q=>V.transferCanvas2World(q,U)),k=w.getModifiedRectangleCoordinates(Z,x,C),G=k[0],et=k[2],pt=w.getLineCenterPoint([G,et]),Zt=_.info.center.z-_.info.depth/2,gt=O(L({},_.info),{center:{x:pt.x,y:pt.y,z:Zt+m/2},width:C,height:x,depth:m,valid:!0}),Mt=tt([gt]);M({omitView:v["3D"],polygon:y,boxParams:gt,newPointCloudBoxList:Mt})}},Y=(n,s,p,r,l,f)=>st(void 0,null,function*(){const C=W==null?void 0:W.url,m={[v.Side]:()=>{vt(p,s,i,C,f)},[v.Back]:()=>{d&&wt(p,s,d,C,f)},[v.Top]:()=>{It(p,s,t,o)}};Object.keys(m).forEach(x=>{x!==n&&m[x]()}),r&&(o==null||o.updateCameraZoom(r)),kt(p)}),M=n=>st(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:f}=n,C=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const m={[v.Side]:()=>{Bt(r,p,i,C)},[v.Back]:()=>{d&&bt(r,p,d,C)},[v.Top]:()=>{dt(r,p,t,o)}};Object.keys(m).forEach(x=>{x!==s&&m[x]()}),l&&(o==null||o.updateCameraZoom(l)),Ot(r)});return{topViewAddSphere:At,topViewAddBox:Ut,topViewSelectedChanged:zt,topViewUpdatePoint:Ht,sideViewUpdatePoint:Tt,backViewUpdatePoint:jt,topViewUpdateBox:Ft,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>st(void 0,[...n],function*(s=W){var p,r,l,f,C,m;if(!(s==null?void 0:s.url)||!o)return;F([]),Ct(H,!0),Pt(H,!0),yield o.loadPCDFile(s.url,(p=b==null?void 0:b.radius)!=null?p:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],I=[],D=[],y=[];o.updateTopCamera();const U=(l=(r=ft(s.result))==null?void 0:r.valid)!=null?l:!0;e.setPointCloudValid(U),(f=e.sideViewInstance)==null||f.clearAllData(),(C=e.backViewInstance)==null||C.clearAllData(),t.updateData(s.url,s.result,{radius:(m=b==null?void 0:b.radius)!=null?m:K}),s.result&&(x=V.getBoxParamsFromResultList(s.result),D=V.getPolygonListFromResultList(s.result),I=V.getLineListFromResultList(s.result),y=V.getSphereParamsFromResultList(s.result),o==null||o.generateBoxes(x),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(x,[])),N({pointCloudBoxList:x,polygonList:D,lineList:I,pointCloudSphereList:y}),Ct(H,!1),Pt(H,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:Rt}};export{wt as syncBackViewByPoint,vt as syncSideViewByPoint,It as syncTopViewByPoint,bt as synchronizeBackView,Bt as synchronizeSideView,dt as synchronizeTopView,rt as topViewPoint2PointCloud,lt as topViewPolygon2PointCloud,Co as usePointCloudViews};
1
+ import{EPointCloudName as nt,MathUtils as w,getCuboidFromPointCloudBox as Gt}from"@labelbee/lb-annotation";import{EPerspectiveView as Q,PointCloudUtils as V,DEFAULT_SPHERE_PARAMS as Qt}from"@labelbee/lb-utils";import{useContext as Xt}from"react";import{PointCloudContext as Yt}from"../PointCloudContext.js";import{useSingleBox as qt}from"./useSingleBox.js";import{useSphere as Jt}from"./useSphere.js";import{useSelector as Kt,useDispatch as $t}from"../../../store/ctx.js";import to from"../../../utils/StepUtils.js";import{jsonParser as ft,getRectPointCloudBox as oo}from"../../../utils/index.js";import{PreDataProcess as it,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{message as eo}from"antd";import{useTranslation as no}from"react-i18next";import{useHistory as io}from"./useHistory.js";import{usePolygon as so}from"./usePolygon.js";import{useLatest as ro}from"ahooks";var lo=Object.defineProperty,ao=Object.defineProperties,co=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,xt=(e,t,i)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,L=(e,t)=>{for(var i in t||(t={}))uo.call(t,i)&&xt(e,i,t[i]);if(mt)for(var i of mt(t))po.call(t,i)&&xt(e,i,t[i]);return e},O=(e,t)=>ao(e,co(t)),st=(e,t,i)=>new Promise((d,o)=>{var a=u=>{try{c(i.next(u))}catch(P){o(P)}},g=u=>{try{c(i.throw(u))}catch(P){o(P)}},c=u=>u.done?d(u.value):Promise.resolve(u.value).then(a,g);c((i=i.apply(e,t)).next())});const J=5,K=90,ht=.01,v={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},rt=(e,t,i,d,o)=>{const{x:a,y:g}=V.transferCanvas2World(e,t),{defaultZ:c}=Qt,u={center:{x:a,y:g,z:c},id:e.id},P=d?L(L({},d),u):O(L({},u),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},lt=(e,t,i,d,o,a)=>{let g=e.pointList.map(B=>V.transferCanvas2World(B,t)),c=0,u=1,P={};if(i){const B=i.getSensesPointZAxisInPolygon(g,void 0,a);a&&B.fittedCoordinates.length>0&&(g=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,u=B.maxZ-B.minZ,P={count:B.zCount}}const[h,S,F]=g,R=w.getLineCenterPoint([h,F]),z=w.getLineLength(h,S),A=w.getLineLength(S,F),N=w.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,u=d.depth);const T={center:{x:R.x,y:R.y,z:c},width:a?A+ht:A,height:a?z+ht:z,depth:u,rotation:N,id:e.id},j=L(d?L(L({},d),T):O(L({},T),{attribute:"",valid:!0}),P);o&&Object.assign(j,o);const E=g.map(B=>V.transferWorld2Canvas(B,t));return{boxParams:j,newPointList:E}},Lt=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x-d.x,y:i.center.y,z:i.center.z-d.y}})},yt=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,P]=t.pointList,h=w.getLineCenterPoint([o,g]),S=w.getLineCenterPoint([c,P]),R={x:{x:h.x-S.x,y:h.y-S.y}.x,y:0,z:h.y-S.y},z=w.getLineLength(o,a),A=w.getLineLength(c,u),N=z-A,T=w.getLineLength(a,g),j=w.getLineLength(u,P),E=T-j,{newBoxParams:B}=d.getNewBoxBySideUpdate(R,E,N,i);return B},go=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x,y:i.center.y-d.x,z:i.center.z-d.y}})},fo=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,P]=t.pointList,h=w.getLineCenterPoint([o,g]),S=w.getLineCenterPoint([c,P]),R={x:{x:h.x-S.x,y:h.y-S.y}.x,y:0,z:h.y-S.y},z=w.getLineLength(o,a),A=w.getLineLength(c,u),N=z-A,T=w.getLineLength(a,g),j=w.getLineLength(u,P),E=T-j;let{newBoxParams:B}=d.getNewBoxByBackUpdate(R,E,N,i);return B},vt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,Q.Left);c.setInitCameraPosition(u);const{point2d:P,zoom:h}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([O(L(L({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{width:J,depth:J});const{cameraPositionVector:g}=a.updateOrthoCamera(e,Q.Left);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},wt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,Q.Back);c.setInitCameraPosition(u);const{point2d:P,zoom:h}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([O(L(L({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{height:J,depth:J});const{cameraPositionVector:g}=a.updateOrthoCamera(e,Q.Back);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,i,d)=>{if(!i||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,Q.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=i,{point2d:g}=a.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},dt=(e,t,i,d)=>{var o,a;if(!i||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:g,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),P=[...g.polygonList],h=P.find(S=>S.id===t.id);h?(h.pointList=u,h.valid=(o=e.valid)!=null?o:!0):P.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(a=e.valid)!=null?a:!0}),g.setResultAndSelectedID(P,t.id)},Co=()=>{const e=Xt(Yt),{topViewInstance:t,sideViewInstance:i,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:g,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:P,pointCloudSphereList:h,hideAttributes:S,setHighlight2DDataList:F,cuboidBoxIn2DView:R,imageSizes:z}=e,{addHistory:A,initHistory:N,pushHistoryUnderUpdatePolygon:T}=io(),{selectedPolygon:j}=so(),{getPointCloudSphereByID:E,updatePointCloudSphere:B,selectedSphere:X}=Jt(),{currentData:W,config:b}=Kt(n=>{const{stepList:r,step:p,imgList:s,imgIndex:l}=n.annotation;return{currentData:s[l],config:ft(to.getCurrentStepInfo(p,r).config)}}),H=$t(),Dt=ro(R),$=n=>{if(!Dt.current){const{mappingImgList:r=[]}=W,p=r.map(s=>oo({pointCloudBox:n,mappingData:s,imageSizes:z}));Object.assign(n,{rects:p.filter(s=>s!==void 0)})}},{selectedBox:_,updateSelectedBox:St,updateSelectedBoxes:tt,getPointCloudByID:_t}=qt({generateRects:$}),{t:Vt}=no(),at=_==null?void 0:_.info;if(!t||!i||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Ot=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},kt=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},At=({newPoint:n,size:r,zoom:p,trackConfigurable:s})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};s===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const C=rt(n,r,ot,void 0,f);c(n.id);const m=g(C);Y(v.Top,n,C,p,m,b),A({newSphereParams:C})},Ut=({polygon:n,size:r,imgList:p,trackConfigurable:s,zoom:l,intelligentFit:f})=>{var C,m;const x={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};s===!0&&Object.assign(x,{trackID:V.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:h})});const I=t==null?void 0:t.toolInstance,D=L({},n);let{boxParams:y,newPointList:U}=lt(D,r,ot,void 0,x,f);if(y=H(it({tool:nt.PointCloud,dataList:[y],stepConfig:b,action:"viewUpdateBox"}))[0],(b==null?void 0:b.lowerLimitPointsNumInBox)&&typeof y.count=="number"&&y.count<b.lowerLimitPointsNumInBox){eo.info(Vt("LowerLimitPointsNumInBox",{num:b.lowerLimitPointsNumInBox})),I.deletePolygon(y.id);return}f&&(U==null?void 0:U.length)&&(D.pointList=U);const k=S.includes(D.attribute);$(y);const G=a(y),et=(m=e==null?void 0:e.polygonList)!=null?m:[];t==null||t.updatePolygonList(G!=null?G:[],et),k?c([]):(c(y.id),I.selection.setSelectedIDs(D.id),M({omitView:v.Top,polygon:D,boxParams:y,zoom:l,newPointCloudBoxList:G}),f&&dt(y,D,t,o)),A({newBoxParams:y})},Rt=n=>{const{boxID:r,imageName:p,width:s,height:l,x:f,y:C}=n,m=P.find(x=>x.id===r);if(m==null?void 0:m.rects){const{rects:x=[]}=m,I=x.find(D=>D.imageName===p);if(I){let D=x;const y=O(L({},I),{width:s,height:l,x:f,y:C});D=x.map(k=>k===I?y:k);const U=O(L({},m),{rects:D}),Z=P.map(k=>k===m?U:k);return t==null||t.updatePolygonList(Z!=null?Z:[]),Z}}},zt=({newSelectedBox:n,newPointCloudList:r,newSelectedSphere:p,newSphereList:s})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(u.length===0||!f)){if(n||(_==null?void 0:_.info)){const C=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(u[0]);const m=f.selectedPolygon;if(u.length===1&&C){M({omitView:v.Top,polygon:m,boxParams:C,newPointCloudBoxList:r});return}}if((p||X)&&u.length===1){const C=p!=null?p:X;f.setSelectedID(u[0]);const m=f.selectedPoint;C&&Y(v.Top,m,C,void 0,s,b)}}},ct=(n,r,p)=>{if(at){let s,l;switch(p){case v.Back:s=fo;break;case v.Side:s=yt;break;default:s=yt;break}l=s(n,r,at,i.pointCloudInstance);const C=H(it({tool:nt.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;if(l=C,o){const{count:I}=o.getSensesPointZAxisInPolygon(Gt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:I})}const x=St(l);return l=x.find(I=>I.id===l.id),M({omitView:m?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:x}),x}},ut=(n,r,p)=>{if(X){let s,l;switch(p){case v.Back:s=go;break;case v.Side:s=Lt;break;default:s=Lt;break}l=s(n,r,X);const f=B(l);return Y(p,n,l,void 0,f,b),f}},Tt=(n,r)=>{ut(n,r,v.Side)},jt=(n,r)=>{ut(n,r,v.Back)},Nt=(n,r)=>{ct(n,r,v.Side)},Et=(n,r)=>{ct(n,r,v.Back)},Ht=(n,r)=>{const p=E(n.id),s=rt(n,r,ot,p),l=B(s);Y(v.Top,n,s,void 0,l,b)},Ft=(n,r)=>{if(j){const s=L({},n[0].newPolygon);s.pointList=s.pointList.map(l=>V.transferCanvas2World(l,r)),T(s);return}let p=n.map(({newPolygon:s})=>{const l=_t(s.id),{boxParams:f}=lt(s,r,t.pointCloudInstance,l);return f});if(p=H(it({tool:nt.PointCloud,dataList:p,stepConfig:b,action:"viewUpdateBox"})),p.length===1){const{newPolygon:s}=n[0],l=tt(p);M({polygon:s,boxParams:p[0],newPointCloudBoxList:l})}else{const s=tt(p);s&&e.syncAllViewPointCloudColor(s)}},Wt=n=>{var r,p,s,l,f;if(_){const C=Number(n.widthDefault),m=Number(n.depthDefault),x=Number(n.heightDefault),I=_==null?void 0:_.info.trackID,y=((r=t==null?void 0:t.toolInstance)==null?void 0:r.polygonList).find(q=>(q==null?void 0:q.trackID)===I),U={width:(s=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:s.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},Z=y.pointList.map(q=>V.transferCanvas2World(q,U)),k=w.getModifiedRectangleCoordinates(Z,x,C),G=k[0],et=k[2],pt=w.getLineCenterPoint([G,et]),Zt=_.info.center.z-_.info.depth/2,gt=O(L({},_.info),{center:{x:pt.x,y:pt.y,z:Zt+m/2},width:C,height:x,depth:m,valid:!0}),Mt=tt([gt]);M({omitView:v["3D"],polygon:y,boxParams:gt,newPointCloudBoxList:Mt})}},Y=(n,r,p,s,l,f)=>st(void 0,null,function*(){const C=W==null?void 0:W.url,m={[v.Side]:()=>{vt(p,r,i,C,f)},[v.Back]:()=>{d&&wt(p,r,d,C,f)},[v.Top]:()=>{It(p,r,t,o)}};Object.keys(m).forEach(x=>{x!==n&&m[x]()}),s&&(o==null||o.updateCameraZoom(s)),kt(p)}),M=n=>st(void 0,null,function*(){const{omitView:r,polygon:p,boxParams:s,zoom:l,newPointCloudBoxList:f}=n,C=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const m={[v.Side]:()=>{Bt(s,p,i,C)},[v.Back]:()=>{d&&bt(s,p,d,C)},[v.Top]:()=>{dt(s,p,t,o)}};Object.keys(m).forEach(x=>{x!==r&&m[x]()}),l&&(o==null||o.updateCameraZoom(l)),Ot(s)});return{topViewAddSphere:At,topViewAddBox:Ut,topViewSelectedChanged:zt,topViewUpdatePoint:Ht,sideViewUpdatePoint:Tt,backViewUpdatePoint:jt,topViewUpdateBox:Ft,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const r=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(r),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>st(void 0,[...n],function*(r=W){var p,s,l,f,C,m;if(!(r==null?void 0:r.url)||!o)return;F([]),Ct(H,!0),Pt(H,!0),yield o.loadPCDFile(r.url,(p=b==null?void 0:b.radius)!=null?p:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],I=[],D=[],y=[];o.updateTopCamera();const U=(l=(s=ft(r.result))==null?void 0:s.valid)!=null?l:!0;e.setPointCloudValid(U),(f=e.sideViewInstance)==null||f.clearAllData(),(C=e.backViewInstance)==null||C.clearAllData(),t.updateData(r.url,r.result,{radius:(m=b==null?void 0:b.radius)!=null?m:K}),r.result&&(x=V.getBoxParamsFromResultList(r.result),D=V.getPolygonListFromResultList(r.result),I=V.getLineListFromResultList(r.result),y=V.getSphereParamsFromResultList(r.result),o==null||o.generateBoxes(x),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(x,[])),N({pointCloudBoxList:x,polygonList:D,lineList:I,pointCloudSphereList:y}),Ct(H,!1),Pt(H,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:Rt}};export{wt as syncBackViewByPoint,vt as syncSideViewByPoint,It as syncTopViewByPoint,bt as synchronizeBackView,Bt as synchronizeSideView,dt as synchronizeTopView,rt as topViewPoint2PointCloud,lt as topViewPolygon2PointCloud,Co as usePointCloudViews};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.18.0-dev.2",
3
+ "version": "1.18.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.21.0-dev.2",
47
- "@labelbee/lb-utils": "1.14.0-dev.1",
46
+ "@labelbee/lb-annotation": "1.22.0",
47
+ "@labelbee/lb-utils": "1.14.0",
48
48
  "@labelbee/wavesurfer": "1.0.0",
49
49
  "@types/react-dom": "^18.2.7",
50
50
  "ahooks": "^3.4.0",