@labelbee/lb-components 1.23.0-alpha.126 → 1.23.0-alpha.128

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 index$4=require("../../LLMToolView/questionView/index.js"),index$2=require("../../LLMToolView/questionView/components/header/index.js"),index$3=require("../../LLMToolView/questionView/components/imgView/index.js"),index=require("../../../store/LLMMultiWheel/index.js"),index$1=require("../../../utils/index.js"),antd=require("antd"),React=require("react");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const DialogView=e=>{const{id:t,answerList:r,question:o,index:u,name:d="",answerIsImg:c,questionIsImg:m,LLMConfig:f}=e,{dataFormatType:n,selectedID:p,setSelectedID:v}=index(),a=u+1,E=d||`\u5BF9\u8BDD${a}`;return React__default.default.createElement("div",{key:t,onClick:()=>v(t),className:index$1.classnames({dialog:!0,selected:t===p})},React__default.default.createElement("div",{className:"header"},React__default.default.createElement("span",{className:"order"},a),React__default.default.createElement("div",{className:"name"},React__default.default.createElement("div",{className:"show-name"},E),React__default.default.createElement("div",{className:"tips"},"\uFF08\u9009\u4E2D\u6807\u6CE8\uFF09"))),React__default.default.createElement("div",{className:"dialog-question"},React__default.default.createElement(antd.Button,{type:"primary"},"\u9898\u76EE",a),React__default.default.createElement("div",null,React__default.default.createElement(index$2.RenderQuestion,{question:o,dataFormatType:n,isImg:m}))),React__default.default.createElement("div",{className:"dialog-answer"},c?React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Button,{type:"primary"},"\u7B54\u6848"),React__default.default.createElement(index$3,{answerList:r})):r.map((w,l)=>{const s=l+1,i=__spreadProps(__spreadValues({},w),{order:s}),_=index$4.getTextControlByConfig(i,f);return React__default.default.createElement("div",{key:l},React__default.default.createElement(antd.Button,{type:"primary"},"\u7B54\u6848",s),React__default.default.createElement(index$4.RenderAnswer,{i,isTextControl:_,dataFormatType:n}))})))};module.exports=DialogView;
1
+ "use strict";var index$4=require("../../LLMToolView/questionView/index.js"),index$2=require("../../LLMToolView/questionView/components/header/index.js"),index$3=require("../../LLMToolView/questionView/components/imgView/index.js"),index=require("../../../store/LLMMultiWheel/index.js"),index$1=require("../../../utils/index.js"),antd=require("antd"),React=require("react");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const DialogView=e=>{const{id:t,answerList:r,question:o,index:u,name:d="",answerIsImg:c,questionIsImg:m,LLMConfig:f}=e,{dataFormatType:n,selectedID:p,setSelectedID:v}=index(),a=u+1,E=d||`\u5BF9\u8BDD${a}`;return React__default.default.createElement("div",{key:t,onClick:()=>v(t),className:index$1.classnames({dialog:!0,selected:t===p})},React__default.default.createElement("div",{className:"header"},React__default.default.createElement("span",{className:"order"},a),React__default.default.createElement("div",{className:"name"},React__default.default.createElement("div",{className:"show-name"},E),React__default.default.createElement("div",{className:"tips"},"\uFF08\u9009\u4E2D\u6807\u6CE8\uFF09"))),React__default.default.createElement("div",{className:"dialog-question"},React__default.default.createElement(antd.Button,{type:"primary"},"\u9898\u76EE",a),React__default.default.createElement("div",null,React__default.default.createElement(index$2.RenderQuestion,{question:o,dataFormatType:n,isImg:m}))),React__default.default.createElement("div",{className:"dialog-answer"},c?React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Button,{type:"primary"},"\u7B54\u6848"),React__default.default.createElement(index$3,{answerList:r})):r==null?void 0:r.map((w,l)=>{const s=l+1,i=__spreadProps(__spreadValues({},w),{order:s}),_=index$4.getTextControlByConfig(i,f);return React__default.default.createElement("div",{key:l},React__default.default.createElement(antd.Button,{type:"primary"},"\u7B54\u6848",s),React__default.default.createElement(index$4.RenderAnswer,{i,isTextControl:_,dataFormatType:n}))})))};module.exports=DialogView;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),antd=require("antd"),index=require("../../../../../constant/index.js"),classNames=require("classnames"),imgFail_cn=require("../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js"),imgFail_en=require("../../../../../assets/annotation/LLMTool/imgFail_en.svg.js"),lbUtils=require("@labelbee/lb-utils"),index_module=require("./index.module.scss.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const LLMViewCls=`${index.prefix}-LLMView`,ImgView=e=>{const{answerList:t,hoverKey:l}=e,r=lbUtils.i18n.language==="en"?imgFail_en:imgFail_cn;return React__default.default.createElement("div",{className:index_module.imgView},t.map((a,s)=>React__default.default.createElement("div",{key:s,className:index_module.item},React__default.default.createElement(antd.Tag,{className:`${LLMViewCls}-tag`},a==null?void 0:a.order),React__default.default.createElement("div",{className:classNames__default.default({[`${index_module.image}`]:!0,[`${LLMViewCls}__contentActive`]:l===(a==null?void 0:a.order)})},React__default.default.createElement(antd.Image,{src:a==null?void 0:a.url,fallback:r,style:{objectFit:"contain"}})))))};module.exports=ImgView;
1
+ "use strict";var React=require("react"),antd=require("antd"),index=require("../../../../../constant/index.js"),classNames=require("classnames"),imgFail_cn=require("../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js"),imgFail_en=require("../../../../../assets/annotation/LLMTool/imgFail_en.svg.js"),lbUtils=require("@labelbee/lb-utils"),index_module=require("./index.module.scss.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const LLMViewCls=`${index.prefix}-LLMView`,ImgView=e=>{const{answerList:t,hoverKey:l}=e,r=lbUtils.i18n.language==="en"?imgFail_en:imgFail_cn;return React__default.default.createElement("div",{className:index_module.imgView},t==null?void 0:t.map((a,n)=>React__default.default.createElement("div",{key:n,className:classNames__default.default({[`${index_module.item}`]:!0,[`${LLMViewCls}__contentActive`]:l===(a==null?void 0:a.order)})},React__default.default.createElement(antd.Tag,{className:`${LLMViewCls}-tag`},a==null?void 0:a.order),React__default.default.createElement("div",{className:index_module.image},React__default.default.createElement(antd.Image,{src:a==null?void 0:a.url,fallback:r,style:{objectFit:"contain"}})))))};module.exports=ImgView;
@@ -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,{output:"mathml"}]],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"),rehypeRaw=require("rehype-raw"),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),rehypeRaw__default=_interopDefaultLegacy(rehypeRaw),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:[rehypeRaw__default.default,[rehypeKatex__default.default,{output:"mathml"}]],transformImageUri:a,transformLinkUri:t,components:__spreadValues({code:u},d)},r)};module.exports=MarkdownView;
@@ -1 +1 @@
1
- "use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),reactI18next=require("react-i18next"),actionCreators=require("../../store/annotation/actionCreators.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=(i,r,l)=>r in i?__defProp(i,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[r]=l,__spreadValues=(i,r)=>{for(var l in r||(r={}))__hasOwnProp.call(r,l)&&__defNormalProp(i,l,r[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(r))__propIsEnum.call(r,l)&&__defNormalProp(i,l,r[l]);return i},__spreadProps=(i,r)=>__defProps(i,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:i,config:r,checkMode:l,configString:_,imgIndex:f,toolInstanceRef:u,setResourceLoading:B})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:E,selectNextBox:L,selectPrevBox:q,updateSelectedBox:C,deleteSelectedPointCloudBoxAndPolygon:I}=useSingleBox.useSingleBox(),{selectedSphere:b,updatePointCloudSphere:O}=useSphere.useSphere(),{clearAllResult:w,updatePointCloudPattern:A}=useStatus.useStatus(),{copySelectedBoxes:j,pasteSelectedBoxes:T,copiedBoxes:$}=useBoxes.useBoxes({config:r,currentData:i}),{updateRotate:g}=useRotate.useRotate({currentData:i}),{updateRotateEdge:D}=useRotateEdge.useRotateEdge({currentData:i}),{updatePointCloudData:v,topViewSelectedChanged:m}=usePointCloudViews.usePointCloudViews({setResourceLoading:B}),{redo:h,undo:x,pushHistoryWithList:N,pushHistoryUnderUpdatePolygon:R,pushHistoryUnderUpdateLine:H}=useHistory.useHistory(),K=ctx.useDispatch(),{syncThreeViewsAttribute:S}=useAttribute.useAttribute(),{syncAllViewsConfig:U,reRenderTopViewRange:z}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:V}=useLine.useLine(),{t:y}=reactI18next.useTranslation(),F=ahooks.useLatest(i),P=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},G=(t,o)=>{var s,a;const{topViewInstance:c,mainViewInstance:n}=e;if(!c)return;const{pointCloud2dOperation:d}=c;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":D(-90);break;case"u":{const p=d.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;A(p);const Y={[lbAnnotation.EToolName.Polygon]:y("PolygonPattern"),[lbAnnotation.EToolName.Rect]:y("RectPattern")};antd.message.success(y("ChangePatternMsg",{pattern:Y[p]})),d.clearActiveStatus(),d.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){q();break}L(),o.preventDefault();break;case"f":E();break;case"arrowup":P({y:-1});break;case"arrowdown":P({y:1});break;case"arrowleft":P({x:-1});break;case"arrowright":P({x:1});break;case"delete":I(F.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=lbAnnotation.AttributeUtils.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((a=u.current)==null||a.setDefaultAttribute(p))}return}}},M=(t,o)=>{switch(t){case"c":j();break;case"v":T();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?h():x();break}}},W=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){M(o,t);return}G(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>W.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{U(r)},[_]),React.useEffect(()=>{(r==null?void 0:r.radius)&&z(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{v==null||v()},[f,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[f]),React.useEffect(()=>{u.current.setDefaultAttribute=t=>{var o,s,a,c;S(t);const n=e.selectedPointCloudBox;if(n){n.attribute=t;const d=K(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=d[0].valid;const p=C(n);(a=(s=(o=e==null?void 0:e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||a.call(s,n.id,!0,n.valid),e.mainViewInstance&&(m({newSelectedBox:n,newPointCloudList:p}),e.mainViewInstance.generateBoxes(p))}if(k&&R(__spreadProps(__spreadValues({},k),{attribute:t})),V&&H(__spreadProps(__spreadValues({},V),{attribute:t})),b){const d=O(__spreadProps(__spreadValues({},b),{attribute:t}));e.mainViewInstance&&((c=e.mainViewInstance)==null||c.generateSpheres(d),m({newSelectedSphere:b,newSphereList:d}))}},u.current.setSubAttribute=(t,o)=>{var s;const a=e.selectedPointCloudBox;if(a){const c=(s=a==null?void 0:a.subAttribute)!=null?s:{};a.subAttribute=__spreadProps(__spreadValues({},c),{[t]:o}),C(a),e.mainViewInstance&&e.selectedPointCloudBox&&e.mainViewInstance.generateBox(e.selectedPointCloudBox)}},u.current.clearResult=()=>{w==null||w()},u.current.redo=()=>{h()},u.current.undo=()=>{x()},u.current.setValid=t=>{u.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&w()})},u.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},u.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},u.current.asyncData=t=>{setTimeout(()=>{v==null||v(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{u.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},u.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{u.current.history={pushHistory:t=>{N({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||l)return;const s=n=>{S(n)},a=n=>{antd.message.error(n)},c=n=>{antd.message.info(n)};return o.on("syncAttribute",s),o.on("messageError",a),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",a),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$1;
1
+ "use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),useUpdatePointCloudColor=require("./hooks/useUpdatePointCloudColor.js"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,r,i)=>r in n?__defProp(n,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[r]=i,__spreadValues=(n,r)=>{for(var i in r||(r={}))__hasOwnProp.call(r,i)&&__defNormalProp(n,i,r[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(r))__propIsEnum.call(r,i)&&__defNormalProp(n,i,r[i]);return n},__spreadProps=(n,r)=>__defProps(n,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:n,config:r,checkMode:i,configString:_,imgIndex:w,toolInstanceRef:a,setResourceLoading:f})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:V,selectNextBox:E,selectPrevBox:B,updateSelectedBox:L,deleteSelectedPointCloudBoxAndPolygon:q}=useSingleBox.useSingleBox(),{selectedSphere:b,updatePointCloudSphere:I}=useSphere.useSphere(),{clearAllResult:P,updatePointCloudPattern:O}=useStatus.useStatus(),{copySelectedBoxes:j,pasteSelectedBoxes:A,copiedBoxes:$}=useBoxes.useBoxes({config:r,currentData:n}),{updateRotate:g}=useRotate.useRotate({currentData:n}),{updateRotateEdge:T}=useRotateEdge.useRotateEdge({currentData:n}),{updatePointCloudData:p,topViewSelectedChanged:D}=usePointCloudViews.usePointCloudViews({setResourceLoading:f}),{redo:h,undo:m,pushHistoryWithList:N,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:K}=useHistory.useHistory(),{syncThreeViewsAttribute:S}=useAttribute.useAttribute(),{syncAllViewsConfig:U,reRenderTopViewRange:R}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:x}=useLine.useLine(),{t:y}=reactI18next.useTranslation(),{updatePointCloudColor:z}=useUpdatePointCloudColor.useUpdatePointCloudColor(f,r),F=ahooks.useLatest(n),v=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},G=(t,o)=>{var s,u;const{topViewInstance:c,mainViewInstance:l}=e;if(!c)return;const{pointCloud2dOperation:C}=c;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":T(-90);break;case"u":{const d=C.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;O(d);const Y={[lbAnnotation.EToolName.Polygon]:y("PolygonPattern"),[lbAnnotation.EToolName.Rect]:y("RectPattern")};antd.message.success(y("ChangePatternMsg",{pattern:Y[d]})),C.clearActiveStatus(),C.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){B();break}E(),o.preventDefault();break;case"f":V();break;case"arrowup":v({y:-1});break;case"arrowdown":v({y:1});break;case"arrowleft":v({x:-1});break;case"arrowright":v({x:1});break;case"delete":q(F.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const d=lbAnnotation.AttributeUtils.getAttributeByKeycode(o.keyCode,r.attributeList);d!==void 0&&((u=a.current)==null||u.setDefaultAttribute(d))}return}}},M=(t,o)=>{switch(t){case"c":j();break;case"v":A();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?h():m();break}}},W=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||i===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){M(o,t);return}G(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>W.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{U(r)},[_]),React.useEffect(()=>{(r==null?void 0:r.radius)&&R(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{p==null||p()},[w,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[w]),React.useEffect(()=>{a.current.setDefaultAttribute=t=>{var o;if(S(t),z(t),k&&H(__spreadProps(__spreadValues({},k),{attribute:t})),x&&K(__spreadProps(__spreadValues({},x),{attribute:t})),b){const s=I(__spreadProps(__spreadValues({},b),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),D({newSelectedSphere:b,newSphereList:s}))}},a.current.setSubAttribute=(t,o)=>{var s;const u=e.selectedPointCloudBox;if(u){const c=(s=u==null?void 0:u.subAttribute)!=null?s:{};u.subAttribute=__spreadProps(__spreadValues({},c),{[t]:o}),L(u),e.mainViewInstance&&e.selectedPointCloudBox&&e.mainViewInstance.generateBox(e.selectedPointCloudBox)}},a.current.clearResult=()=>{P==null||P()},a.current.redo=()=>{h()},a.current.undo=()=>{m()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&P()})},a.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},a.current.asyncData=t=>{setTimeout(()=>{p==null||p(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{a.current.history={pushHistory:t=>{N({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||i)return;const s=l=>{S(l)},u=l=>{antd.message.error(l)},c=l=>{antd.message.info(l)};return o.on("syncAttribute",s),o.on("messageError",u),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",u),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$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"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,n,t)=>n in o?__defProp(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,__spreadValues=(o,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(o,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(o,t,n[t]);return o},__spreadProps=(o,n)=>__defProps(o,__getOwnPropDescs(n)),__async=(o,n,t)=>new Promise((u,p)=>{var e=d=>{try{c(t.next(d))}catch(x){p(x)}},P=d=>{try{c(t.throw(d))}catch(x){p(x)}},c=d=>d.done?u(d.value):Promise.resolve(d.value).then(e,P);c((t=t.apply(o,n)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,n,t,u,p)=>{const{x:e,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,n),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:e,y:P,z:c},id:o.id},x=u?__spreadValues(__spreadValues({},u),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,u,p,e)=>{let P=o.pointList.map(B=>lbUtils.PointCloudUtils.transferCanvas2World(B,n)),c=0,d=1,x={};if(t){const B=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&B.fittedCoordinates.length>0&&(P=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,d=B.maxZ-B.minZ,x={count:B.zCount}}const[f,L,R]=P,S=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),w=lbAnnotation.MathUtils.getLineLength(f,L),V=lbAnnotation.MathUtils.getLineLength(L,R),T=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);u&&(c=u.center.z,d=u.depth);const k={center:{x:S.x,y:S.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?w+INTELLIGENT_FIT_MARGIN:w,depth:d,rotation:T,id:o.id},O=__spreadValues(u?__spreadValues(__spreadValues({},u),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),x);p&&Object.assign(O,p);const M=P.map(B=>lbUtils.PointCloudUtils.transferWorld2Canvas(B,n));return{boxParams:O,newPointList:M}},sideViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-u.x,y:t.center.y,z:t.center.z-u.y}})},sideViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),S={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),M=k-O,{newBoxParams:B}=u.getNewBoxBySideUpdate(S,M,T,t);return B},backViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-u.x,z:t.center.z-u.y}})},backViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),S={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),M=k-O;let{newBoxParams:B}=u.getNewBoxByBackUpdate(S,M,T,t);return B},syncSideViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(d);const{point2d:x,zoom:f}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeSideView=(o,n,t,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);e.setInitCameraPosition(P);const{polygon2d:c,zoom:d}=e.getBoxSidePolygon2DCoordinate(o);e.camera.zoom=d,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncBackViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(d);const{point2d:x,zoom:f}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeBackView=(o,n,t,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);e.setInitCameraPosition(P);const{polygon2d:c,zoom:d}=e.getBoxBackPolygon2DCoordinate(o);e.camera.zoom=d,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncTopViewByPoint=(o,n,t,u)=>{if(!t||!u)return;u.generateSphere(o),u.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),u.render();const{toolInstance:p,pointCloudInstance:e}=t,{point2d:P}=e.getSphereTopPoint2DCoordinate(o),c=[...p.pointList].map(d=>d.id===n.id?__spreadProps(__spreadValues(__spreadValues({},n),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);p.setResult(c),p.setSelectedID(n.id)},synchronizeTopView=(o,n,t,u)=>{var p,e;if(!t||!u)return;u.generateBox(o,n.id),u.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(L=>L.id===n.id);f?(f.pointList=d,f.valid=(p=o.valid)!=null?p:!0):x.push({id:n.id,pointList:d,textAttribute:"",isRect:!0,valid:(e=o.valid)!=null?e:!0}),P.setResultAndSelectedID(x,n.id)},usePointCloudViews=o=>{const n=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:u,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:L,hideAttributes:R,setHighlight2DDataList:S,cuboidBoxIn2DView:w,imageSizes:V,history:T,linkageImageNameRectMap:k}=n,{addHistory:O,initHistory:M,pushHistoryUnderUpdatePolygon:B}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:Y,selectedSphere:F}=useSphere.useSphere(),{currentData:j,config:y}=ctx.useSelector(s=>{const{stepList:i,step:a,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(a,i).config)}}),z=ctx.useDispatch(),it=ahooks.useLatest(w),st=ahooks.useLatest(k),rt=React.useCallback((s,i)=>{const a=st.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=a.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),J=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:a=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:a,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:lt,updateSelectedBoxes:Q,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:J}),K=U==null?void 0:U.info;if(!t||!u||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:i,zoom:a,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const C=topViewPoint2PointCloud(s,i,X,void 0,g);d(s.id);const h=c(C);W(PointCloudView.Top,s,C,a,h,y),O({newSphereParams:C})},ct=({polygon:s,size:i,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,h,m;const D={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(D,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:L})});const I=t==null?void 0:t.toolInstance,b=__spreadValues({},s);let{boxParams:v,newPointList:A}=topViewPolygon2PointCloud(b,i,X,void 0,D,g);v=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[v],stepConfig:y,action:"viewUpdateBox"}))[0],g&&(A==null?void 0:A.length)&&(b.pointList=A);const N=R.includes(b.attribute);J(v);const H=P(v),Z=(h=n==null?void 0:n.polygonList)!=null?h:[];v.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(m=y==null?void 0:y.inputList)!=null?m:[]:[]),t==null||t.updatePolygonList(H!=null?H:[],Z),N?d([]):(d(v.id),I.selection.setSelectedIDs(b.id),E({omitView:PointCloudView.Top,polygon:b,boxParams:v,zoom:l,newPointCloudBoxList:H}),g&&synchronizeTopView(v,b,t,e)),O({newBoxParams:v})},pt=s=>{const{boxID:i,imageName:a,width:r,height:l,x:g,y:C}=s,h=f.find(v=>v.id===i);if(!(h==null?void 0:h.rects)||!h.rects.find(v=>v.imageName===a))return;const D=h.rects.map(v=>v.imageName===a?__spreadProps(__spreadValues({},v),{width:r,height:l,x:g,y:C}):v),I=__spreadProps(__spreadValues({},h),{rects:D}),b=f.map(v=>v.id===i?I:v);return t==null||t.updatePolygonList(b!=null?b:[]),b},gt=s=>{const{boxID:i,imageName:a}=s,r=f.find(h=>h.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(h=>h.imageName!==a),g=__spreadProps(__spreadValues({},r),{rects:l}),C=f.map(h=>h.id===i?g:h);return t==null||t.updatePolygonList(C!=null?C:[]),C},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:a,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(U==null?void 0:U.info)){const C=s!=null?s:U==null?void 0:U.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const h=g.selectedPolygon;if(x.length===1&&C){E({omitView:PointCloudView.Top,polygon:h,boxParams:C,newPointCloudBoxList:i});return}}if((a||F)&&x.length===1){const C=a!=null?a:F;g.setSelectedID(x[0]);const h=g.selectedPoint;C&&W(PointCloudView.Top,h,C,void 0,r,y)}}},$=(s,i,a)=>{if(K){let r,l;switch(a){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}if(l=r(s,i,K,u.pointCloudInstance),e){const{count:D}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:D})}const C=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:y,action:"viewUpdateBox"}))[0],h=l.valid!==C.valid;l=C;const m=lt(l);return l=m.find(D=>D.id===l.id),E({omitView:h?void 0:a,polygon:s,boxParams:l,newPointCloudBoxList:m}),m}},tt=(s,i,a)=>{if(F){let r,l;switch(a){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(s,i,F);const g=Y(l);return W(a,s,l,void 0,g,y),g}},Ct=(s,i)=>{tt(s,i,PointCloudView.Side)},ft=(s,i)=>{tt(s,i,PointCloudView.Back)},ht=(s,i)=>{$(s,i,PointCloudView.Side)},xt=(s,i)=>{$(s,i,PointCloudView.Back)},vt=(s,i)=>{const a=nt(s.id),r=topViewPoint2PointCloud(s,i,X,a),l=Y(r);W(PointCloudView.Top,s,r,void 0,l,y)},Lt=(s,i)=>{if(ot){const r=__spreadValues({},s[0].newPolygon);r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,i)),B(r);return}let a=s.map(({newPolygon:r})=>{const l=at(r.id),{boxParams:g}=topViewPolygon2PointCloud(r,i,t.pointCloudInstance,l);return g});if(a=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:a,stepConfig:y,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=s[0],l=Q(a);E({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=Q(a);r&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},yt=s=>{var i,a,r,l,g;if(U){const C=Number(s.widthDefault),h=Number(s.depthDefault),m=Number(s.heightDefault),D=U==null?void 0:U.info.trackID,b=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(G=>(G==null?void 0:G.trackID)===D),v={width:(r=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},A=b.pointList.map(G=>lbUtils.PointCloudUtils.transferCanvas2World(G,v)),q=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(A,m,C),N=q[0],H=q[2],Z=lbAnnotation.MathUtils.getLineCenterPoint([N,H]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:Z.x,y:Z.y,z:mt+h/2},width:C,height:m,depth:h,valid:!0}),Bt=Q([et]);E({omitView:PointCloudView["3D"],polygon:b,boxParams:et,newPointCloudBoxList:Bt})}},W=(s,i,a,r,l,g)=>__async(void 0,null,function*(){const C=j==null?void 0:j.url,h={[PointCloudView.Side]:()=>{syncSideViewByPoint(a,i,u,C,g)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(a,i,p,C,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(a,i,t,e)}};Object.keys(h).forEach(m=>{m!==s&&h[m]()}),r&&(e==null||e.updateCameraZoom(r)),dt(a)}),E=s=>{const{omitView:i,polygon:a,boxParams:r,zoom:l,newPointCloudBoxList:g}=s,C=j==null?void 0:j.url;g&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,g);const h={[PointCloudView.Side]:()=>{synchronizeSideView(r,a,u,C)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(r,a,p,C)},[PointCloudView.Top]:()=>{synchronizeTopView(r,a,t,e)}};Object.keys(h).forEach(m=>{m!==i&&h[m]()}),l&&(e==null||e.updateCameraZoom(l))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);e.initOrthographicCamera(i),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(i=j){var a,r,l,g,C,h,m,D;if(!(i==null?void 0:i.url)||!e)return;S([]),actionCreators.SetAnnotationLoading(z,!0),actionCreators.SetLoadPCDFileLoading(z,!0),(a=o==null?void 0:o.setResourceLoading)==null||a.call(o,!0),yield e.loadPCDFile(i.url,(r=y==null?void 0:y.radius)!=null?r:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let I=[],b=[],v=[],A=[];e.updateTopCamera();const q=(g=(l=index.jsonParser(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(q),(C=n.sideViewInstance)==null||C.clearAllData(),(h=n.backViewInstance)==null||h.clearAllData(),i.result){if(I=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(I==null?void 0:I.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){I=yield e==null?void 0:e.filterPreResult(i.url,y,I);const N=index.jsonParser(i.result);N[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=I,i.result=JSON.stringify(N),n.setPointCloudResult(I)}v=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),A=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(m=y==null?void 0:y.radius)!=null?m:DEFAULT_RADIUS}),e==null||e.generateBoxes(I),e==null||e.generateSpheres(A),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,I,[])}M({pointCloudBoxList:I,polygonList:v,lineList:b,pointCloudSphereList:A}),actionCreators.SetAnnotationLoading(z,!1),actionCreators.SetLoadPCDFileLoading(z,!1),(D=o==null?void 0:o.setResourceLoading)==null||D.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:J,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),u=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=u.current,c=p.current;if(c.length===0)return null;const d=new Map,x=new Set;if(c.filter(f=>f.extId!==void 0).forEach(f=>{const L=f.extId,R=f.imageName,S=_.pick(f,["x","y","width","height"]);let w=d.get(L);w||(w=new Map,d.set(L,w)),w.set(R,S),x.add(L)}),d.size){const f=P.map(L=>{var R;const S=L.id;if(x.has(S)){const w=__spreadValues({},L);return(R=w.rects)==null||R.forEach(V=>{var T;const k=V.imageName;Object.assign(V,(T=d.get(S))==null?void 0:T.get(k))}),w}return L});return t(f),f}return null},[])}};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,exports.useSyncRectPositionDimensionToPointCloudList=useSyncRectPositionDimensionToPointCloudList;
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"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,n,t)=>n in o?__defProp(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,__spreadValues=(o,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(o,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(o,t,n[t]);return o},__spreadProps=(o,n)=>__defProps(o,__getOwnPropDescs(n)),__async=(o,n,t)=>new Promise((u,p)=>{var e=a=>{try{c(t.next(a))}catch(x){p(x)}},P=a=>{try{c(t.throw(a))}catch(x){p(x)}},c=a=>a.done?u(a.value):Promise.resolve(a.value).then(e,P);c((t=t.apply(o,n)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,n,t,u,p)=>{const{x:e,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,n),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,a={center:{x:e,y:P,z:c},id:o.id},x=u?__spreadValues(__spreadValues({},u),a):__spreadProps(__spreadValues({},a),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,u,p,e)=>{let P=o.pointList.map(B=>lbUtils.PointCloudUtils.transferCanvas2World(B,n)),c=0,a=1,x={};if(t){const B=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&B.fittedCoordinates.length>0&&(P=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,a=B.maxZ-B.minZ,x={count:B.zCount}}const[f,L,R]=P,D=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),w=lbAnnotation.MathUtils.getLineLength(f,L),V=lbAnnotation.MathUtils.getLineLength(L,R),T=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);u&&(c=u.center.z,a=u.depth);const k={center:{x:D.x,y:D.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?w+INTELLIGENT_FIT_MARGIN:w,depth:a,rotation:T,id:o.id},O=__spreadValues(u?__spreadValues(__spreadValues({},u),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),x);p&&Object.assign(O,p);const M=P.map(B=>lbUtils.PointCloudUtils.transferWorld2Canvas(B,n));return{boxParams:O,newPointList:M}},sideViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-u.x,y:t.center.y,z:t.center.z-u.y}})},sideViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,a,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,a),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(a,x),M=k-O,{newBoxParams:B}=u.getNewBoxBySideUpdate(D,M,T,t);return B},backViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-u.x,z:t.center.z-u.y}})},backViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,a,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,a),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(a,x),M=k-O;let{newBoxParams:B}=u.getNewBoxByBackUpdate(D,M,T,t);return B},syncSideViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(a);const{point2d:x,zoom:f}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeSideView=(o,n,t,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);e.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=e.getBoxSidePolygon2DCoordinate(o);e.camera.zoom=a,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncBackViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(a);const{point2d:x,zoom:f}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeBackView=(o,n,t,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);e.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=e.getBoxBackPolygon2DCoordinate(o);e.camera.zoom=a,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncTopViewByPoint=(o,n,t,u)=>{if(!t||!u)return;u.generateSphere(o),u.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),u.render();const{toolInstance:p,pointCloudInstance:e}=t,{point2d:P}=e.getSphereTopPoint2DCoordinate(o),c=[...p.pointList].map(a=>a.id===n.id?__spreadProps(__spreadValues(__spreadValues({},n),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):a);p.setResult(c),p.setSelectedID(n.id)},synchronizeTopView=(o,n,t,u)=>{var p,e;if(!t||!u)return;u.generateBox(o,n.id),u.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:a}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(L=>L.id===n.id);f?(f.pointList=a,f.valid=(p=o.valid)!=null?p:!0):x.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(e=o.valid)!=null?e:!0}),P.setResultAndSelectedID(x,n.id)},usePointCloudViews=o=>{const n=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:u,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:a,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:L,hideAttributes:R,setHighlight2DDataList:D,cuboidBoxIn2DView:w,imageSizes:V,history:T,linkageImageNameRectMap:k}=n,{addHistory:O,initHistory:M,pushHistoryUnderUpdatePolygon:B}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:Y,selectedSphere:W}=useSphere.useSphere(),{currentData:j,config:y}=ctx.useSelector(s=>{const{stepList:i,step:d,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,i).config)}}),z=ctx.useDispatch(),it=ahooks.useLatest(w),st=ahooks.useLatest(k),rt=React.useCallback((s,i)=>{const d=st.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=d.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),J=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:d=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:d,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:lt,updateSelectedBoxes:Q,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:J}),K=U==null?void 0:U.info;if(!t||!u||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:i,zoom:d,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const C=topViewPoint2PointCloud(s,i,X,void 0,g);a(s.id);const h=c(C);q(PointCloudView.Top,s,C,d,h,y),O({newSphereParams:C})},ct=({polygon:s,size:i,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,h,m;const b={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(b,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:L})});const S=t==null?void 0:t.toolInstance,I=__spreadValues({},s);let{boxParams:v,newPointList:A}=topViewPolygon2PointCloud(I,i,X,void 0,b,g);v=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[v],stepConfig:y,action:"viewUpdateBox"}))[0],g&&(A==null?void 0:A.length)&&(I.pointList=A);const E=R.includes(I.attribute);J(v);const F=P(v),Z=(h=n==null?void 0:n.polygonList)!=null?h:[];v.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(m=y==null?void 0:y.inputList)!=null?m:[]:[]),t==null||t.updatePolygonList(F!=null?F:[],Z),E?a([]):(a(v.id),S.selection.setSelectedIDs(I.id),N({omitView:PointCloudView.Top,polygon:I,boxParams:v,zoom:l,newPointCloudBoxList:F}),g&&synchronizeTopView(v,I,t,e)),O({newBoxParams:v})},pt=s=>{const{boxID:i,imageName:d,width:r,height:l,x:g,y:C}=s,h=f.find(v=>v.id===i);if(!(h==null?void 0:h.rects)||!h.rects.find(v=>v.imageName===d))return;const b=h.rects.map(v=>v.imageName===d?__spreadProps(__spreadValues({},v),{width:r,height:l,x:g,y:C}):v),S=__spreadProps(__spreadValues({},h),{rects:b}),I=f.map(v=>v.id===i?S:v);return t==null||t.updatePolygonList(I!=null?I:[]),I},gt=s=>{const{boxID:i,imageName:d}=s,r=f.find(h=>h.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(h=>h.imageName!==d),g=__spreadProps(__spreadValues({},r),{rects:l}),C=f.map(h=>h.id===i?g:h);return t==null||t.updatePolygonList(C!=null?C:[]),C},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:d,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(U==null?void 0:U.info)){const C=s!=null?s:U==null?void 0:U.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const h=g.selectedPolygon;if(x.length===1&&C){N({omitView:PointCloudView.Top,polygon:h,boxParams:C,newPointCloudBoxList:i});return}}if((d||W)&&x.length===1){const C=d!=null?d:W;g.setSelectedID(x[0]);const h=g.selectedPoint;C&&q(PointCloudView.Top,h,C,void 0,r,y)}}},$=(s,i,d)=>{if(K){let r,l;switch(d){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}if(l=r(s,i,K,u.pointCloudInstance),e){const{count:b}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:b})}const C=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:y,action:"viewUpdateBox"}))[0],h=l.valid!==C.valid;l=C;const m=lt(l);return l=m.find(b=>b.id===l.id),N({omitView:h?void 0:d,polygon:s,boxParams:l,newPointCloudBoxList:m}),m}},tt=(s,i,d)=>{if(W){let r,l;switch(d){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(s,i,W);const g=Y(l);return q(d,s,l,void 0,g,y),g}},Ct=(s,i)=>{tt(s,i,PointCloudView.Side)},ft=(s,i)=>{tt(s,i,PointCloudView.Back)},ht=(s,i)=>{$(s,i,PointCloudView.Side)},xt=(s,i)=>{$(s,i,PointCloudView.Back)},vt=(s,i)=>{const d=nt(s.id),r=topViewPoint2PointCloud(s,i,X,d),l=Y(r);q(PointCloudView.Top,s,r,void 0,l,y)},Lt=(s,i)=>{if(ot){const r=__spreadValues({},s[0].newPolygon);r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,i)),B(r);return}let d=s.map(({newPolygon:r})=>{const l=at(r.id),{boxParams:g}=topViewPolygon2PointCloud(r,i,t.pointCloudInstance,l);return g});if(d=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:y,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=s[0],l=Q(d);N({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=Q(d);r&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},yt=s=>{var i,d,r,l,g;if(U){const C=Number(s.widthDefault),h=Number(s.depthDefault),m=Number(s.heightDefault),b=U==null?void 0:U.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(G=>(G==null?void 0:G.trackID)===b),v={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},A=I.pointList.map(G=>lbUtils.PointCloudUtils.transferCanvas2World(G,v)),H=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(A,m,C),E=H[0],F=H[2],Z=lbAnnotation.MathUtils.getLineCenterPoint([E,F]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:Z.x,y:Z.y,z:mt+h/2},width:C,height:m,depth:h,valid:!0}),Bt=Q([et]);N({omitView:PointCloudView["3D"],polygon:I,boxParams:et,newPointCloudBoxList:Bt})}},q=(s,i,d,r,l,g)=>__async(void 0,null,function*(){const C=j==null?void 0:j.url,h={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,i,u,C,g)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(d,i,p,C,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,i,t,e)}};Object.keys(h).forEach(m=>{m!==s&&h[m]()}),r&&(e==null||e.updateCameraZoom(r)),dt(d)}),N=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:d,polygon:r,boxParams:l,zoom:g,newPointCloudBoxList:C}=s,h=j==null?void 0:j.url;C&&n.syncAllViewPointCloudColor(i,C);const m={[PointCloudView.Side]:()=>{synchronizeSideView(l,r,u,h)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(l,r,p,h)},[PointCloudView.Top]:()=>{synchronizeTopView(l,r,t,e)}};Object.keys(m).forEach(b=>{b!==d&&m[b]()}),g&&(e==null||e.updateCameraZoom(g))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:N,syncPointCloudPoint:q,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);e.initOrthographicCamera(i),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(i=j){var d,r,l,g,C,h,m,b;if(!(i==null?void 0:i.url)||!e)return;D([]),actionCreators.SetAnnotationLoading(z,!0),actionCreators.SetLoadPCDFileLoading(z,!0),(d=o==null?void 0:o.setResourceLoading)==null||d.call(o,!0),yield e.loadPCDFile(i.url,(r=y==null?void 0:y.radius)!=null?r:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let S=[],I=[],v=[],A=[];e.updateTopCamera();const H=(g=(l=index.jsonParser(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(H),(C=n.sideViewInstance)==null||C.clearAllData(),(h=n.backViewInstance)==null||h.clearAllData(),i.result){if(S=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(S==null?void 0:S.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){S=yield e==null?void 0:e.filterPreResult(i.url,y,S);const E=index.jsonParser(i.result);E[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=S,i.result=JSON.stringify(E),n.setPointCloudResult(S)}v=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),I=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),A=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(m=y==null?void 0:y.radius)!=null?m:DEFAULT_RADIUS}),e==null||e.generateBoxes(S),e==null||e.generateSpheres(A),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,S,[])}M({pointCloudBoxList:S,polygonList:v,lineList:I,pointCloudSphereList:A}),actionCreators.SetAnnotationLoading(z,!1),actionCreators.SetLoadPCDFileLoading(z,!1),(b=o==null?void 0:o.setResourceLoading)==null||b.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:J,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),u=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=u.current,c=p.current;if(c.length===0)return null;const a=new Map,x=new Set;if(c.filter(f=>f.extId!==void 0).forEach(f=>{const L=f.extId,R=f.imageName,D=_.pick(f,["x","y","width","height"]);let w=a.get(L);w||(w=new Map,a.set(L,w)),w.set(R,D),x.add(L)}),a.size){const f=P.map(L=>{var R;const D=L.id;if(x.has(D)){const w=__spreadValues({},L);return(R=w.rects)==null||R.forEach(V=>{var T;const k=V.imageName;Object.assign(V,(T=a.get(D))==null?void 0:T.get(k))}),w}return L});return t(f),f}return null},[])}};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,exports.useSyncRectPositionDimensionToPointCloudList=useSyncRectPositionDimensionToPointCloudList;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),ctx=require("../../../store/ctx.js"),useSingleBox=require("./useSingleBox.js"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),actionCreators=require("../../../store/annotation/actionCreators.js"),usePointCloudViews=require("./usePointCloudViews.js"),useSphere=require("./useSphere.js"),useHistory=require("./useHistory.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js");const PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},useUpdatePointCloudColor=(v,d)=>{const l=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:u,selectedIDs:i,pointCloudBoxList:s,mainViewInstance:c,selectedID:g}=l,f=ctx.useDispatch(),{selectedSphere:C}=useSphere.useSphere(),{syncPointCloudViews:p,syncPointCloudPoint:P,generateRects:h}=usePointCloudViews.usePointCloudViews({setResourceLoading:v}),{selectedBox:a,updateSelectedBox:x}=useSingleBox.useSingleBox({generateRects:h}),{pushHistoryWithList:V}=useHistory.useHistory(),q=({newSelectedSphere:n,newSphereList:o})=>{const e=u==null?void 0:u.toolInstance;if((n||C)&&i.length===1){const t=n!=null?n:C;e.setSelectedID(i[0]);const r=e.selectedPoint;t&&(P==null||P(PointCloudView.Top,r,t,void 0,o,d))}},y=({trigger:n,newSelectedBox:o})=>{const e=u==null?void 0:u.toolInstance;if(!(i.length===0||!e)&&(o||(a==null?void 0:a.info))){const t=o!=null?o:a==null?void 0:a.info,r=o;if(t){p==null||p({omitView:PointCloudView.Top,polygon:r,boxParams:t},n);return}}};return{updatePointCloudColor:n=>{if(s.forEach(o=>{var e,t,r;if(o&&i.includes(o.id)){o.attribute=n;const S=f(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[o],stepConfig:d,action:"viewUpdateBox"}));o.valid=S[0].valid,x(o),(r=(t=(e=l==null?void 0:l.topViewInstance)==null?void 0:e.pointCloud2dOperation)==null?void 0:t.setPolygonValidAndRender)==null||r.call(t,o.id,!0,o.valid),q({})}}),c){const o=i&&i.length>1?ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MulitSelect:ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single;l.syncAllViewPointCloudColor(o,s),s.forEach(e=>{y({trigger:o,newSelectedBox:e})}),c.generateBoxes(s)}g||V({pointCloudBoxList:s})}}};exports.useUpdatePointCloudColor=useUpdatePointCloudColor;
package/dist/index.css CHANGED
@@ -8,13 +8,9 @@
8
8
  }
9
9
  .index-module_imgView__wmxDk .index-module_item__-80YI {
10
10
  margin: 0px 40px 40px 0px;
11
- width: 400px;
12
11
  display: flex;
13
- height: 300px;
14
12
  }
15
13
  .index-module_imgView__wmxDk .index-module_item__-80YI .index-module_image__V49oW {
16
- height: 260px;
17
- min-width: 300px;
18
14
  flex: 1;
19
15
  background: #E9EBF1;
20
16
  display: flex;
@@ -6,6 +6,7 @@
6
6
  import { PointCloudAnnotation, PointCloud } from '@labelbee/lb-annotation';
7
7
  import { IPointCloudBox, IPointCloudSphere, IPointUnit, UpdatePolygonByDragList, IDefaultSize, IBasicRect } from '@labelbee/lb-utils';
8
8
  import { ISize } from '@/types/main';
9
+ import { EPointCloudBoxRenderTrigger } from '@/utils/ToolPointCloudBoxRenderHelper';
9
10
  import { IFileItem } from '@/types/data';
10
11
  export declare const topViewPoint2PointCloud: (newPoint: any, size: ISize, pointCloud: PointCloud, selectedPointCloudSphere?: IPointCloudSphere, defaultValue?: {
11
12
  [v: string]: any;
@@ -56,6 +57,19 @@ export declare const synchronizeTopView: (newBoxParams: IPointCloudBox, newPolyg
56
57
  interface IUsePointCloudViewsParams {
57
58
  setResourceLoading?: (loading: boolean) => void;
58
59
  }
60
+ /**
61
+ * Sync views' data from omit view, regenerate and highlight box on 3D-view
62
+ * @param omitView
63
+ * @param polygon
64
+ * @param boxParams
65
+ */
66
+ interface ISyncPointCloudViews {
67
+ omitView?: string;
68
+ polygon: any;
69
+ boxParams: IPointCloudBox;
70
+ zoom?: number;
71
+ newPointCloudBoxList?: IPointCloudBox[];
72
+ }
59
73
  export declare const usePointCloudViews: (params?: IUsePointCloudViewsParams) => {
60
74
  topViewAddSphere: () => void;
61
75
  topViewAddBox: () => void;
@@ -66,6 +80,8 @@ export declare const usePointCloudViews: (params?: IUsePointCloudViewsParams) =>
66
80
  sideViewUpdatePoint?: undefined;
67
81
  backViewUpdatePoint?: undefined;
68
82
  topViewUpdateBox?: undefined;
83
+ syncPointCloudViews?: undefined;
84
+ syncPointCloudPoint?: undefined;
69
85
  pointCloudBoxListUpdated?: undefined;
70
86
  initPointCloud3d?: undefined;
71
87
  updatePointCloudData?: undefined;
@@ -100,6 +116,8 @@ export declare const usePointCloudViews: (params?: IUsePointCloudViewsParams) =>
100
116
  topViewUpdateBox: (updateList: UpdatePolygonByDragList, size: ISize) => void;
101
117
  sideViewUpdateBox: (newPolygon: any, originPolygon: any) => void;
102
118
  backViewUpdateBox: (newPolygon: any, originPolygon: any) => void;
119
+ syncPointCloudViews: (params: ISyncPointCloudViews, trigger?: EPointCloudBoxRenderTrigger) => void;
120
+ syncPointCloudPoint: (omitView: string, point: any, sphereParams: IPointCloudSphere, zoom?: number, newPointCloudSphereList?: IPointCloudSphere[], config?: any) => Promise<void>;
103
121
  pointCloudBoxListUpdated: (newBoxes: IPointCloudBox[]) => void;
104
122
  initPointCloud3d: (size: ISize) => void;
105
123
  updatePointCloudData: (newData?: any) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ declare const useUpdatePointCloudColor: (setResourceLoading: any, config: any) => {
2
+ updatePointCloudColor: (newAttribute: string) => void;
3
+ };
4
+ export { useUpdatePointCloudColor };
@@ -8,7 +8,8 @@ export declare enum EPointCloudBoxRenderTrigger {
8
8
  SingleToggleValid = "SingleToggleValid",
9
9
  SingleRotate = "SingleRotate",
10
10
  MultiPaste = "MultiPaste",
11
- MultiMove = "MultiMove"
11
+ MultiMove = "MultiMove",
12
+ MulitSelect = "MulitSelect"
12
13
  }
13
14
  export declare enum EPointCloudBoxSingleModifiedType {
14
15
  ChangeAttribute = "ChangeAttribute",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation");exports.EPointCloudBoxRenderTrigger=void 0,function(t){t.Default="Default",t.UndoRedo="UndoRedo",t.ClearAll="ClearAll",t.Single="Single",t.SingleDelete="SingleDelete",t.SingleToggleValid="SingleToggleValid",t.SingleRotate="SingleRotate",t.MultiPaste="MultiPaste",t.MultiMove="MultiMove"}(exports.EPointCloudBoxRenderTrigger||(exports.EPointCloudBoxRenderTrigger={})),exports.EPointCloudBoxSingleModifiedType=void 0,function(t){t.ChangeAttribute="ChangeAttribute",t.Move="Move",t.ChangeDepth="ChangeDepth",t.ChangeSize="ChangeSize",t.ToggleValid="ToggleValid"}(exports.EPointCloudBoxSingleModifiedType||(exports.EPointCloudBoxSingleModifiedType={}));const checkRectanglesIntersect=(t,n)=>{const i=getAxes(t).concat(getAxes(n));for(const e of i){const o=projectRectangle(t,e),r=projectRectangle(n,e);if(!projectionsOverlap(o,r))return!1}return!0},getAxes=t=>{const n=[];for(let i=0;i<t.length;i++){const e=t[i],o=t[(i+1)%t.length],r={x:o.x-e.x,y:o.y-e.y},d={x:-r.y,y:r.x};n.push(d)}return n},projectRectangle=(t,n)=>{let i=dotProduct(t[0],n),e=i;for(const o of t){const r=dotProduct(o,n);r<i&&(i=r),r>e&&(e=r)}return{min:i,max:e}},projectionsOverlap=(t,n)=>!(t.max<n.min||n.max<t.min),dotProduct=(t,n)=>t.x*n.x+t.y*n.y,getIntersectingBoxIds=(t,n)=>{const i=[];return n.forEach(e=>{const{polygonPointList:o}=lbAnnotation.getCuboidFromPointCloudBox(e);checkRectanglesIntersect(t,o)&&i.push(e.id)}),i},getAddBoxId=(t,n)=>{const i=t.map(o=>o.id),e=n.map(o=>o.id);return i.find(o=>!e.includes(o))||""},getDeletedBox=(t,n)=>{const i=t.map(e=>e.id);return n.find(e=>!i.includes(e.id))},getValidChangedBox=(t,n)=>t.find(e=>{const o=n.find(r=>r.id===e.id);return o&&o.valid!==e.valid}),getRotationChangedBox=(t,n)=>t.find(e=>{const o=n.find(r=>r.id===e.id);return o&&o.rotation!==e.rotation}),getIntersectingBoxIdsOfBox=(t,n)=>{const{polygonPointList:i}=lbAnnotation.getCuboidFromPointCloudBox(t);return{ids:getIntersectingBoxIds(i,n.filter(o=>o.id!==t.id)),rect:i}},getModifiedBox=(t,n)=>{const i=(e,o)=>e.attribute===o.attribute&&e.center.x===o.center.x&&e.center.y===o.center.y&&e.depth===o.depth&&e.width===o.width&&e.height===o.height;for(const e of t){const o=n.find(r=>r.id===e.id);if(o&&!i(e,o)){let r;if(o.attribute!==e.attribute?r=exports.EPointCloudBoxSingleModifiedType.ChangeAttribute:o.center.x!==e.center.x||o.center.y!==e.center.y?r=exports.EPointCloudBoxSingleModifiedType.Move:o.depth!==e.depth?r=exports.EPointCloudBoxSingleModifiedType.ChangeDepth:(o.width!==e.width||o.height!==e.height)&&(r=exports.EPointCloudBoxSingleModifiedType.ChangeSize),r!==void 0)return{modifiedType:r,box:e}}}},calcResetAreasAndBoxIds=(t,n,i)=>{try{switch(t){case exports.EPointCloudBoxRenderTrigger.Single:if(n.length>i.length){const e=getAddBoxId(n,i);return e?{modifiedBoxIds:[e],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}else{const e=[],o=[],r=getModifiedBox(n,i);if(r&&(e.push(r.box.id),r.modifiedType===exports.EPointCloudBoxSingleModifiedType.ChangeSize||r.modifiedType===exports.EPointCloudBoxSingleModifiedType.Move)){const d=i.find(l=>l.id===r.box.id),{ids:s,rect:c}=getIntersectingBoxIdsOfBox(d,n);e.push(...s),o.push(c)}return{modifiedBoxIds:e,resetAreas:o}}case exports.EPointCloudBoxRenderTrigger.SingleDelete:if(n.length<i.length){const e=getDeletedBox(n,i);if(e){const r=[lbAnnotation.getCuboidFromPointCloudBox(e).polygonPointList],d=[];if(n.length>1){const{ids:s}=getIntersectingBoxIdsOfBox(e,n);s.length&&d.push(...s)}return{modifiedBoxIds:d,resetAreas:r}}return{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.SingleRotate:if(getRotationChangedBox(n,i)){const e=getRotationChangedBox(n,i);if(e){const o=i.find(s=>s.id===e.id),{ids:r,rect:d}=getIntersectingBoxIdsOfBox(o,n);return{modifiedBoxIds:[e.id,...r],resetAreas:[d]}}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.SingleToggleValid:if(getValidChangedBox(n,i)){const e=getValidChangedBox(n,i);return e?{modifiedBoxIds:[e.id],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.MultiPaste:case exports.EPointCloudBoxRenderTrigger.MultiMove:case exports.EPointCloudBoxRenderTrigger.Default:case exports.EPointCloudBoxRenderTrigger.UndoRedo:case exports.EPointCloudBoxRenderTrigger.ClearAll:default:return{modifiedBoxIds:[],resetAreas:[]}}}catch(e){return console.error("calcResetAreasAndBoxIds error:",e),{modifiedBoxIds:[],resetAreas:[]}}};exports.calcResetAreasAndBoxIds=calcResetAreasAndBoxIds;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation");exports.EPointCloudBoxRenderTrigger=void 0,function(t){t.Default="Default",t.UndoRedo="UndoRedo",t.ClearAll="ClearAll",t.Single="Single",t.SingleDelete="SingleDelete",t.SingleToggleValid="SingleToggleValid",t.SingleRotate="SingleRotate",t.MultiPaste="MultiPaste",t.MultiMove="MultiMove",t.MulitSelect="MulitSelect"}(exports.EPointCloudBoxRenderTrigger||(exports.EPointCloudBoxRenderTrigger={})),exports.EPointCloudBoxSingleModifiedType=void 0,function(t){t.ChangeAttribute="ChangeAttribute",t.Move="Move",t.ChangeDepth="ChangeDepth",t.ChangeSize="ChangeSize",t.ToggleValid="ToggleValid"}(exports.EPointCloudBoxSingleModifiedType||(exports.EPointCloudBoxSingleModifiedType={}));const checkRectanglesIntersect=(t,o)=>{const r=getAxes(t).concat(getAxes(o));for(const e of r){const n=projectRectangle(t,e),i=projectRectangle(o,e);if(!projectionsOverlap(n,i))return!1}return!0},getAxes=t=>{const o=[];for(let r=0;r<t.length;r++){const e=t[r],n=t[(r+1)%t.length],i={x:n.x-e.x,y:n.y-e.y},d={x:-i.y,y:i.x};o.push(d)}return o},projectRectangle=(t,o)=>{let r=dotProduct(t[0],o),e=r;for(const n of t){const i=dotProduct(n,o);i<r&&(r=i),i>e&&(e=i)}return{min:r,max:e}},projectionsOverlap=(t,o)=>!(t.max<o.min||o.max<t.min),dotProduct=(t,o)=>t.x*o.x+t.y*o.y,getIntersectingBoxIds=(t,o)=>{const r=[];return o.forEach(e=>{const{polygonPointList:n}=lbAnnotation.getCuboidFromPointCloudBox(e);checkRectanglesIntersect(t,n)&&r.push(e.id)}),r},getAddBoxId=(t,o)=>{const r=t.map(n=>n.id),e=o.map(n=>n.id);return r.find(n=>!e.includes(n))||""},getDeletedBox=(t,o)=>{const r=t.map(e=>e.id);return o.find(e=>!r.includes(e.id))},getValidChangedBox=(t,o)=>t.find(e=>{const n=o.find(i=>i.id===e.id);return n&&n.valid!==e.valid}),getRotationChangedBox=(t,o)=>t.find(e=>{const n=o.find(i=>i.id===e.id);return n&&n.rotation!==e.rotation}),getIntersectingBoxIdsOfBox=(t,o)=>{const{polygonPointList:r}=lbAnnotation.getCuboidFromPointCloudBox(t);return{ids:getIntersectingBoxIds(r,o.filter(n=>n.id!==t.id)),rect:r}},getModifiedBox=(t,o)=>{const r=(e,n)=>e.attribute===n.attribute&&e.center.x===n.center.x&&e.center.y===n.center.y&&e.depth===n.depth&&e.width===n.width&&e.height===n.height;for(const e of t){const n=o.find(i=>i.id===e.id);if(n&&!r(e,n)){let i;if(n.attribute!==e.attribute?i=exports.EPointCloudBoxSingleModifiedType.ChangeAttribute:n.center.x!==e.center.x||n.center.y!==e.center.y?i=exports.EPointCloudBoxSingleModifiedType.Move:n.depth!==e.depth?i=exports.EPointCloudBoxSingleModifiedType.ChangeDepth:(n.width!==e.width||n.height!==e.height)&&(i=exports.EPointCloudBoxSingleModifiedType.ChangeSize),i!==void 0)return{modifiedType:i,box:e}}}},calcResetAreasAndBoxIds=(t,o,r)=>{try{switch(t){case exports.EPointCloudBoxRenderTrigger.Single:if(o.length>r.length){const e=getAddBoxId(o,r);return e?{modifiedBoxIds:[e],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}else{const e=[],n=[],i=getModifiedBox(o,r);if(i&&(e.push(i.box.id),i.modifiedType===exports.EPointCloudBoxSingleModifiedType.ChangeSize||i.modifiedType===exports.EPointCloudBoxSingleModifiedType.Move)){const d=r.find(l=>l.id===i.box.id),{ids:s,rect:c}=getIntersectingBoxIdsOfBox(d,o);e.push(...s),n.push(c)}return{modifiedBoxIds:e,resetAreas:n}}case exports.EPointCloudBoxRenderTrigger.SingleDelete:if(o.length<r.length){const e=getDeletedBox(o,r);if(e){const i=[lbAnnotation.getCuboidFromPointCloudBox(e).polygonPointList],d=[];if(o.length>1){const{ids:s}=getIntersectingBoxIdsOfBox(e,o);s.length&&d.push(...s)}return{modifiedBoxIds:d,resetAreas:i}}return{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.SingleRotate:if(getRotationChangedBox(o,r)){const e=getRotationChangedBox(o,r);if(e){const n=r.find(s=>s.id===e.id),{ids:i,rect:d}=getIntersectingBoxIdsOfBox(n,o);return{modifiedBoxIds:[e.id,...i],resetAreas:[d]}}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.SingleToggleValid:if(getValidChangedBox(o,r)){const e=getValidChangedBox(o,r);return e?{modifiedBoxIds:[e.id],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.MulitSelect:return{modifiedBoxIds:getDifference(o,r),resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.MultiPaste:case exports.EPointCloudBoxRenderTrigger.MultiMove:case exports.EPointCloudBoxRenderTrigger.Default:case exports.EPointCloudBoxRenderTrigger.UndoRedo:case exports.EPointCloudBoxRenderTrigger.ClearAll:default:return{modifiedBoxIds:[],resetAreas:[]}}}catch(e){return console.error("calcResetAreasAndBoxIds error:",e),{modifiedBoxIds:[],resetAreas:[]}}},deepEqual=(t,o)=>{if(t===o)return!0;if(typeof t!="object"||typeof o!="object"||t===null||o===null)return!1;const r=Object.keys(t),e=Object.keys(o);if(r.length!==e.length)return!1;for(const n of r)if(!deepEqual(t[n],o[n]))return!1;return!0},getDifference=(t,o)=>{const r=new Map;for(const e of o)r.set(e.id,e);return t.filter(e=>{const n=r.get(e.id);return!n||!deepEqual(e,n)}).map(e=>e.id)};exports.calcResetAreasAndBoxIds=calcResetAreasAndBoxIds;