@labelbee/lb-components 1.24.0-alpha.50 → 1.24.0-alpha.51

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 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=(a,r,u)=>r in a?__defProp(a,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[r]=u,__spreadValues=(a,r)=>{for(var u in r||(r={}))__hasOwnProp.call(r,u)&&__defNormalProp(a,u,r[u]);if(__getOwnPropSymbols)for(var u of __getOwnPropSymbols(r))__propIsEnum.call(r,u)&&__defNormalProp(a,u,r[u]);return a},__spreadProps=(a,r)=>__defProps(a,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:a,config:r,checkMode:u,configString:x,imgIndex:g,toolInstanceRef:i,setResourceLoading:w,isBatchSetValid:k})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:V,selectNextBox:_,selectPrevBox:E,updateSelectedBox:B,deleteSelectedPointCloudBoxAndPolygon:I}=useSingleBox.useSingleBox(),{selectedSphere:v,updatePointCloudSphere:q}=useSphere.useSphere(),{clearAllResult:b,updatePointCloudPattern:L}=useStatus.useStatus(),{copySelectedBoxes:O,pasteSelectedBoxes:j,copiedBoxes:Y}=useBoxes.useBoxes({config:r,currentData:a}),{updateRotate:C}=useRotate.useRotate({currentData:a}),{updateRotateEdge:A}=useRotateEdge.useRotateEdge({currentData:a}),{updatePointCloudData:d,topViewSelectedChanged:T}=usePointCloudViews.usePointCloudViews({setResourceLoading:w}),{redo:y,undo:h,pushHistoryWithList:D,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:N}=useHistory.useHistory(),{syncThreeViewsAttribute:f}=useAttribute.useAttribute(),{syncAllViewsConfig:K,reRenderTopViewRange:R}=useConfig.useConfig(),{selectedPolygon:m}=usePolygon.usePolygon(),{selectedLine:S}=useLine.useLine(),{t:P}=reactI18next.useTranslation(),{updatePointCloudColor:U}=useUpdatePointCloudColor.useUpdatePointCloudColor(w,r),z=ahooks.useLatest(a),p=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},F=(t,o)=>{const{topViewInstance:s,mainViewInstance:n}=e;if(!s)return;const{pointCloud2dOperation:l}=s;switch(t){case"q":{C(e.rectRotateSensitivity);break}case"e":C(-Number(e.rectRotateSensitivity));break;case"g":A(-90);break;case"u":{const c=l.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;L(c);const W={[lbAnnotation.EToolName.Polygon]:P("PolygonPattern"),[lbAnnotation.EToolName.Rect]:P("RectPattern")};antd.message.success(P("ChangePatternMsg",{pattern:W[c]})),l.clearActiveStatus(),l.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":k?(antd.Modal.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){E();break}_(),o.preventDefault();break;case"f":V();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(z.current);break}},M=(t,o)=>{switch(t){case"c":O();break;case"v":j();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?y():h();break}}},G=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||u===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){M(o,t);return}F(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(l=>G.current(l))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{K(r)},[x]),React.useEffect(()=>{(r==null?void 0:r.radius)&&R(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{d==null||d()},[g,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[g]),React.useEffect(()=>{i.current.setAttrChangeTrigger=t=>{var o;(o=e.topViewInstance)==null||o.toolInstance.setAttrChangeTrigger(t)},i.current.setDefaultAttribute=t=>{var o;if(f(t),U(t),m&&H(__spreadProps(__spreadValues({},m),{attribute:t})),S&&N(__spreadProps(__spreadValues({},S),{attribute:t})),v){const s=q(__spreadProps(__spreadValues({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),T({newSelectedSphere:v,newSphereList:s}))}},i.current.setSubAttribute=(t,o)=>{var s;const n=e.selectedPointCloudBox;if(n){const l=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=__spreadProps(__spreadValues({},l),{[t]:o}),B(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},i.current.clearResult=()=>{b==null||b()},i.current.redo=()=>{y()},i.current.undo=()=>{h()},i.current.setValid=t=>{i.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},i.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)},i.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},i.current.asyncData=t=>{setTimeout(()=>{d==null||d(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{i.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},i.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{i.current.history={pushHistory:t=>{D({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||u)return;const s=c=>{f(c)},n=c=>{antd.message.error(c)},l=c=>{antd.message.info(c)};return o.on("syncAttribute",s),o.on("messageError",n),o.on("messageInfo",l),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",n),o.unbind("messageInfo",l)}},[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=(a,r,u)=>r in a?__defProp(a,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[r]=u,__spreadValues=(a,r)=>{for(var u in r||(r={}))__hasOwnProp.call(r,u)&&__defNormalProp(a,u,r[u]);if(__getOwnPropSymbols)for(var u of __getOwnPropSymbols(r))__propIsEnum.call(r,u)&&__defNormalProp(a,u,r[u]);return a},__spreadProps=(a,r)=>__defProps(a,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:a,config:r,checkMode:u,configString:x,imgIndex:w,toolInstanceRef:i,setResourceLoading:b,isBatchSetValid:k})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:V,selectNextBox:_,selectPrevBox:E,updateSelectedBox:L,deleteSelectedPointCloudBoxAndPolygon:B}=useSingleBox.useSingleBox(),{selectedSphere:v,updatePointCloudSphere:I}=useSphere.useSphere(),{clearAllResult:C,updatePointCloudPattern:q}=useStatus.useStatus(),{copySelectedBoxes:O,pasteSelectedBoxes:T,copiedBoxes:$}=useBoxes.useBoxes({config:r,currentData:a}),{updateRotate:y}=useRotate.useRotate({currentData:a}),{updateRotateEdge:j}=useRotateEdge.useRotateEdge({currentData:a}),{updatePointCloudData:d,topViewSelectedChanged:A}=usePointCloudViews.usePointCloudViews({setResourceLoading:b}),{redo:h,undo:g,pushHistoryWithList:D,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:N}=useHistory.useHistory(),{syncThreeViewsAttribute:S}=useAttribute.useAttribute(),{syncAllViewsConfig:R,reRenderTopViewRange:K,reRenderTopViewTipScopeList:U}=useConfig.useConfig(),{selectedPolygon:m}=usePolygon.usePolygon(),{selectedLine:f}=useLine.useLine(),{t:P}=reactI18next.useTranslation(),{updatePointCloudColor:z}=useUpdatePointCloudColor.useUpdatePointCloudColor(b,r),F=ahooks.useLatest(a),p=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},M=(t,o)=>{const{topViewInstance:s,mainViewInstance:n}=e;if(!s)return;const{pointCloud2dOperation:l}=s;switch(t){case"q":{y(e.rectRotateSensitivity);break}case"e":y(-Number(e.rectRotateSensitivity));break;case"g":j(-90);break;case"u":{const c=l.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;q(c);const Y={[lbAnnotation.EToolName.Polygon]:P("PolygonPattern"),[lbAnnotation.EToolName.Rect]:P("RectPattern")};antd.message.success(P("ChangePatternMsg",{pattern:Y[c]})),l.clearActiveStatus(),l.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":k?(antd.Modal.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){E();break}_(),o.preventDefault();break;case"f":V();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":B(F.current);break}},G=(t,o)=>{switch(t){case"c":O();break;case"v":T();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?h():g();break}}},W=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||u===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){G(o,t);return}M(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(l=>W.current(l))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{R(r)},[x]),React.useEffect(()=>{(r==null?void 0:r.radius)&&K(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{(r==null?void 0:r.tipScopeList)&&U(r==null?void 0:r.tipScopeList)},[r==null?void 0:r.tipScopeList]),React.useEffect(()=>{d==null||d()},[w,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[w]),React.useEffect(()=>{i.current.setAttrChangeTrigger=t=>{var o;(o=e.topViewInstance)==null||o.toolInstance.setAttrChangeTrigger(t)},i.current.setDefaultAttribute=t=>{var o;if(S(t),z(t),m&&H(__spreadProps(__spreadValues({},m),{attribute:t})),f&&N(__spreadProps(__spreadValues({},f),{attribute:t})),v){const s=I(__spreadProps(__spreadValues({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),A({newSelectedSphere:v,newSphereList:s}))}},i.current.setSubAttribute=(t,o)=>{var s;const n=e.selectedPointCloudBox;if(n){const l=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=__spreadProps(__spreadValues({},l),{[t]:o}),L(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},i.current.clearResult=()=>{C==null||C()},i.current.redo=()=>{h()},i.current.undo=()=>{g()},i.current.setValid=t=>{i.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},i.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)},i.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},i.current.asyncData=t=>{setTimeout(()=>{d==null||d(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{i.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},i.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{i.current.history={pushHistory:t=>{D({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||u)return;const s=c=>{S(c)},n=c=>{antd.message.error(c)},l=c=>{antd.message.info(c)};return o.on("syncAttribute",s),o.on("messageError",n),o.on("messageInfo",l),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",n),o.unbind("messageInfo",l)}},[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 PointCloudContext=require("../PointCloudContext.js"),React=require("react");const useConfig=()=>{const{topViewInstance:n,sideViewInstance:r,backViewInstance:a,mainViewInstance:i}=React.useContext(PointCloudContext.PointCloudContext);return{syncAllViewsConfig:t=>{[n,r,a].forEach(e=>{var o,l;e==null||e.updateConfig(t);const u=(l=(o=t==null?void 0:t.attributeList)==null?void 0:o[0])==null?void 0:l.value;u&&(e==null||e.pointCloud2dOperation.setDefaultAttribute(u))}),i==null||i.setConfig(t)},reRenderTopViewRange:t=>{var e,o,l;(o=(e=n==null?void 0:n.pointCloudInstance)==null?void 0:e.generateRange)==null||o.call(e,t),(l=n==null?void 0:n.pointCloudInstance)==null||l.render()}}};exports.useConfig=useConfig;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PointCloudContext=require("../PointCloudContext.js"),React=require("react");const useConfig=()=>{const{topViewInstance:n,sideViewInstance:r,backViewInstance:d,mainViewInstance:i}=React.useContext(PointCloudContext.PointCloudContext);return{syncAllViewsConfig:o=>{[n,r,d].forEach(e=>{var t,l;e==null||e.updateConfig(o);const u=(l=(t=o==null?void 0:o.attributeList)==null?void 0:t[0])==null?void 0:l.value;u&&(e==null||e.pointCloud2dOperation.setDefaultAttribute(u))}),i==null||i.setConfig(o)},reRenderTopViewRange:o=>{var e,t,l;(t=(e=n==null?void 0:n.pointCloudInstance)==null?void 0:e.generateRange)==null||t.call(e,o),(l=n==null?void 0:n.pointCloudInstance)==null||l.render()},reRenderTopViewTipScopeList:(o=[])=>{var e,t,l;(t=(e=n==null?void 0:n.pointCloudInstance)==null?void 0:e.generateTipScopeList)==null||t.call(e,o),(l=n==null?void 0:n.pointCloudInstance)==null||l.render()}}};exports.useConfig=useConfig;
@@ -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((a,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?a(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,a,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=a?__spreadValues(__spreadValues({},a),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,a,p,e)=>{let P=o.pointList.map(w=>lbUtils.PointCloudUtils.transferCanvas2World(w,n)),c=0,d=1,x={};if(t){const w=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&w.fittedCoordinates.length>0&&(P=w.fittedCoordinates),c=(w.maxZ+w.minZ)/2,d=w.maxZ-w.minZ,x={count:w.zCount}}const[f,v,R]=P,I=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),S=lbAnnotation.MathUtils.getLineLength(f,v),V=lbAnnotation.MathUtils.getLineLength(v,R),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);a&&(c=a.center.z,d=a.depth);const T={center:{x:I.x,y:I.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?S+INTELLIGENT_FIT_MARGIN:S,depth:d,rotation:k,id:o.id},A=__spreadValues(a?__spreadValues(__spreadValues({},a),T):__spreadProps(__spreadValues({},T),{attribute:"",valid:!0}),x);p&&Object.assign(A,p);const O=P.map(w=>lbUtils.PointCloudUtils.transferWorld2Canvas(w,n));return{boxParams:A,newPointList:O}},sideViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-a.x,y:t.center.y,z:t.center.z-a.y}})},sideViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A,{newBoxParams:w}=a.getNewBoxBySideUpdate(I,O,k,t);return w},backViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-a.x,z:t.center.z-a.y}})},backViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A;let{newBoxParams:w}=a.getNewBoxByBackUpdate(I,O,k,t);return w},syncSideViewByPoint=(o,n,t,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(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,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,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,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(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,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,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,a)=>{if(!t||!a)return;a.generateSphere(o),a.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),a.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,a)=>{var p,e;if(!t||!a)return;a.generateBox(o),a.setHighlightColor(o.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(v=>v.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:a,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:v,hideAttributes:R,setHighlight2DDataList:I,cuboidBoxIn2DView:S,imageSizes:V,history:k,linkageImageNameRectMap:T}=n,{addHistory:A,initHistory:O,pushHistoryUnderUpdatePolygon:w}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:X,selectedSphere:F}=useSphere.useSphere(),{currentData:E,config:y}=ctx.useSelector(s=>{const{stepList:i,step:u,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:index.jsonParser(StepUtils.getCurrentStepInfo(u,i).config)}}),M=ctx.useDispatch(),it=ahooks.useLatest(S),st=ahooks.useLatest(T),rt=React.useCallback((s,i)=>{const u=st.current,l=i.id;return s.filter(r=>{if(!r)return!1;const h=u.get(r.imageName);return h===void 0?!0:Boolean(h.get(l))})},[]),Z=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:u=[]}=E;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:u,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:lt,updateSelectedBoxes:G,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:Z}),Y=U==null?void 0:U.info;if(!t||!a||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:J}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:i,zoom:u,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const h=topViewPoint2PointCloud(s,i,J,void 0,r);d(s.id);const C=c(h);H(PointCloudView.Top,s,h,u,C,y),A({newSphereParams:h})},ct=({polygon:s,size:i,imgList:u,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var h,C,b;const D={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};l===!0&&Object.assign(D,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:v})}),t==null||t.toolInstance;const L=__spreadValues({},s);let{boxParams:B,newPointList:m}=topViewPolygon2PointCloud(L,i,J,void 0,D,r);B=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(m==null?void 0:m.length)&&(L.pointList=m);const N=R.includes(L.attribute);Z(B);const z=P(B),Q=(C=n==null?void 0:n.polygonList)!=null?C:[];B.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(b=y==null?void 0:y.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(z!=null?z:[],Q,!1),N?d([]):(d(B.id),r&&synchronizeTopView(B,L,t,e)),A({newBoxParams:B})},pt=s=>{const{boxID:i,imageName:u,width:l,height:g,x:r,y:h}=s,C=f.find(m=>m.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(m=>m.imageName===u))return;const D=C.rects.map(m=>m.imageName===u?__spreadProps(__spreadValues({},m),{width:l,height:g,x:r,y:h}):m),L=__spreadProps(__spreadValues({},C),{rects:D}),B=f.map(m=>m.id===i?L:m);return t==null||t.updatePolygonList(B!=null?B:[]),B},gt=s=>{const{boxID:i,imageName:u}=s,l=f.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==u),r=__spreadProps(__spreadValues({},l),{rects:g}),h=f.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(h!=null?h:[]),h},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:u,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(x.length===0||!r)){if(s||(U==null?void 0:U.info)){const h=s!=null?s:U==null?void 0:U.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(x[0]);const C=r.selectedPolygon;if(x.length===1&&h){q({omitView:PointCloudView.Top,polygon:C,boxParams:h,newPointCloudBoxList:i});return}}if((u||F)&&x.length===1){const h=u!=null?u:F;r.setSelectedID(x[0]);const C=r.selectedPoint;h&&H(PointCloudView.Top,C,h,void 0,l,y)}}},K=(s,i,u,l=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{if(Y){let g,r;switch(u){case PointCloudView.Back:g=backViewPolygon2PointCloud;break;case PointCloudView.Side:g=sideViewPolygon2PointCloud;break;default:g=sideViewPolygon2PointCloud;break}if(r=g(s,i,Y,a.pointCloudInstance),e){const{count:L}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:L})}const C=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],b=r.valid!==C.valid;r=C;const D=lt(r);return r=D.find(L=>L.id===r.id),q({omitView:b?void 0:u,polygon:s,boxParams:r,newPointCloudBoxList:D},l),D}},$=(s,i,u)=>{if(F){let l,g;switch(u){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}g=l(s,i,F);const r=X(g);return H(u,s,g,void 0,r,y),r}},Ct=(s,i)=>{$(s,i,PointCloudView.Side)},ft=(s,i)=>{$(s,i,PointCloudView.Back)},ht=(s,i)=>{K(s,i,PointCloudView.Side,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},xt=(s,i)=>{K(s,i,PointCloudView.Back,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},vt=(s,i)=>{const u=nt(s.id),l=topViewPoint2PointCloud(s,i,J,u),g=X(l);H(PointCloudView.Top,s,l,void 0,g,y)},Lt=(s,i)=>{if(ot){const l=__spreadValues({},s[0].newPolygon);l.pointList=l.pointList.map(g=>lbUtils.PointCloudUtils.transferCanvas2World(g,i)),w(l);return}let u=s.map(({newPolygon:l})=>{const g=at(l.id),{boxParams:r}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,g);return r});if(u=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:u,stepConfig:y,action:"viewUpdateBox"})),u.length===1){const{newPolygon:l}=s[0],g=G(u);q({polygon:l,boxParams:u[0],newPointCloudBoxList:g},ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)}else{const l=G(u);l&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,l)}},yt=s=>{var i,u,l,g,r;if(U){const h=Number(s.widthDefault),C=Number(s.depthDefault),b=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(W=>(W==null?void 0:W.trackID)===D),m={width:(l=(u=t==null?void 0:t.toolInstance)==null?void 0:u.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},j=B.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,m)),N=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(j,b,h),z=N[0],Q=N[2],tt=lbAnnotation.MathUtils.getLineCenterPoint([z,Q]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:tt.x,y:tt.y,z:mt+C/2},width:h,height:b,depth:C,valid:!0}),Bt=G([et]);q({omitView:PointCloudView["3D"],polygon:B,boxParams:et,newPointCloudBoxList:Bt})}},H=(s,i,u,l,g,r)=>__async(void 0,null,function*(){const h=E==null?void 0:E.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(u,i,a,h,r)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(u,i,p,h,r)},[PointCloudView.Top]:()=>{syncTopViewByPoint(u,i,t,e)}};Object.keys(C).forEach(b=>{b!==s&&C[b]()}),l&&(e==null||e.updateCameraZoom(l)),dt(u)}),q=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:u,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:h}=s,C=E==null?void 0:E.url;h&&n.syncAllViewPointCloudColor(i,h);const b={[PointCloudView.Side]:()=>{synchronizeSideView(g,l,a,C)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(g,l,p,C)},[PointCloudView.Top]:()=>{synchronizeTopView(g,l,t,e)}};Object.keys(b).forEach(D=>{D!==u&&b[D]()}),r&&(e==null||e.updateCameraZoom(r))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:q,syncPointCloudPoint:H,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=E){var u,l,g,r,h,C,b,D;if(!(i==null?void 0:i.url)||!e)return;I([]),actionCreators.SetAnnotationLoading(M,!0),actionCreators.SetLoadPCDFileLoading(M,!0),(u=o==null?void 0:o.setResourceLoading)==null||u.call(o,!0),yield e.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let L=[],B=[],m=[],j=[];e.updateTopCamera();const N=(r=(g=index.jsonParser(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(N),(h=n.sideViewInstance)==null||h.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(L=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(L==null?void 0:L.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){L=yield e==null?void 0:e.filterPreResult(i.url,y,L);const z=index.jsonParser(i.result);z[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=L,i.result=JSON.stringify(z),n.setPointCloudResult(L)}m=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),j=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=y==null?void 0:y.radius)!=null?b:DEFAULT_RADIUS}),e==null||e.generateBoxes(L),e==null||e.generateSpheres(j),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,L,[])}O({pointCloudBoxList:L,polygonList:m,lineList:B,pointCloudSphereList:j}),actionCreators.SetAnnotationLoading(M,!1),actionCreators.SetLoadPCDFileLoading(M,!1),(D=o==null?void 0:o.setResourceLoading)==null||D.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:Z,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),a=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=a.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 v=f.extId,R=f.imageName,I=_.pick(f,["x","y","width","height"]);let S=d.get(v);S||(S=new Map,d.set(v,S)),S.set(R,I),x.add(v)}),d.size){const f=P.map(v=>{var R;const I=v.id;if(x.has(I)){const S=__spreadValues({},v);return(R=S.rects)==null||R.forEach(V=>{var k;const T=V.imageName;Object.assign(V,(k=d.get(I))==null?void 0:k.get(T))}),S}return v});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,i,t)=>i in o?__defProp(o,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[i]=t,__spreadValues=(o,i)=>{for(var t in i||(i={}))__hasOwnProp.call(i,t)&&__defNormalProp(o,t,i[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(i))__propIsEnum.call(i,t)&&__defNormalProp(o,t,i[t]);return o},__spreadProps=(o,i)=>__defProps(o,__getOwnPropDescs(i)),__async=(o,i,t)=>new Promise((a,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?a(d.value):Promise.resolve(d.value).then(e,P);c((t=t.apply(o,i)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,i,t,a,p)=>{const{x:e,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,i),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:e,y:P,z:c},id:o.id},x=a?__spreadValues(__spreadValues({},a),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,i,t,a,p,e)=>{let P=o.pointList.map(w=>lbUtils.PointCloudUtils.transferCanvas2World(w,i)),c=0,d=1,x={};if(t){const w=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&w.fittedCoordinates.length>0&&(P=w.fittedCoordinates),c=(w.maxZ+w.minZ)/2,d=w.maxZ-w.minZ,x={count:w.zCount}}const[f,v,R]=P,I=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),S=lbAnnotation.MathUtils.getLineLength(f,v),V=lbAnnotation.MathUtils.getLineLength(v,R),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);a&&(c=a.center.z,d=a.depth);const T={center:{x:I.x,y:I.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?S+INTELLIGENT_FIT_MARGIN:S,depth:d,rotation:k,id:o.id},A=__spreadValues(a?__spreadValues(__spreadValues({},a),T):__spreadProps(__spreadValues({},T),{attribute:"",valid:!0}),x);p&&Object.assign(A,p);const O=P.map(w=>lbUtils.PointCloudUtils.transferWorld2Canvas(w,i));return{boxParams:A,newPointList:O}},sideViewPoint2PointCloud=(o,i,t)=>{const a={x:o.x-i.x,y:o.y-i.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-a.x,y:t.center.y,z:t.center.z-a.y}})},sideViewPolygon2PointCloud=(o,i,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=i.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A,{newBoxParams:w}=a.getNewBoxBySideUpdate(I,O,k,t);return w},backViewPoint2PointCloud=(o,i,t)=>{const a={x:o.x-i.x,y:o.y-i.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-a.x,z:t.center.z-a.y}})},backViewPolygon2PointCloud=(o,i,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=i.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A;let{newBoxParams:w}=a.getNewBoxByBackUpdate(I,O,k,t);return w},syncSideViewByPoint=(o,i,t,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(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({},i),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(i.id)},synchronizeSideView=(o,i,t,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,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:i.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],i.id)},syncBackViewByPoint=(o,i,t,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(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({},i),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(i.id)},synchronizeBackView=(o,i,t,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,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:i.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],i.id)},syncTopViewByPoint=(o,i,t,a)=>{if(!t||!a)return;a.generateSphere(o),a.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:p,pointCloudInstance:e}=t,{point2d:P}=e.getSphereTopPoint2DCoordinate(o),c=[...p.pointList].map(d=>d.id===i.id?__spreadProps(__spreadValues(__spreadValues({},i),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);p.setResult(c),p.setSelectedID(i.id)},synchronizeTopView=(o,i,t,a)=>{var p,e;if(!t||!a)return;a.generateBox(o),a.setHighlightColor(o.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(v=>v.id===i.id);f?(f.pointList=d,f.valid=(p=o.valid)!=null?p:!0):x.push({id:i.id,pointList:d,textAttribute:"",isRect:!0,valid:(e=o.valid)!=null?e:!0}),P.setResultAndSelectedID(x,i.id)},usePointCloudViews=o=>{const i=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:a,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:v,hideAttributes:R,setHighlight2DDataList:I,cuboidBoxIn2DView:S,imageSizes:V,history:k,linkageImageNameRectMap:T}=i,{addHistory:A,initHistory:O,pushHistoryUnderUpdatePolygon:w}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:it,updatePointCloudSphere:X,selectedSphere:F}=useSphere.useSphere(),{currentData:E,config:y}=ctx.useSelector(s=>{const{stepList:n,step:u,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:index.jsonParser(StepUtils.getCurrentStepInfo(u,n).config)}}),M=ctx.useDispatch(),nt=ahooks.useLatest(S),st=ahooks.useLatest(T),rt=React.useCallback((s,n)=>{const u=st.current,l=n.id;return s.filter(r=>{if(!r)return!1;const h=u.get(r.imageName);return h===void 0?!0:Boolean(h.get(l))})},[]),Z=s=>{const{enableAutoMap2DRect:n=!1}=y;if(!nt.current||n){const{mappingImgList:u=[]}=E;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:u,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:lt,updateSelectedBoxes:G,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:Z}),Y=U==null?void 0:U.info;if(!t||!a||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:J}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:n,zoom:u,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const h=topViewPoint2PointCloud(s,n,J,void 0,r);d(s.id);const C=c(h);H(PointCloudView.Top,s,h,u,C,y),A({newSphereParams:h})},ct=({polygon:s,size:n,imgList:u,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var h,C,b;const D={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};l===!0&&Object.assign(D,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:v})}),t==null||t.toolInstance;const L=__spreadValues({},s);let{boxParams:B,newPointList:m}=topViewPolygon2PointCloud(L,n,J,void 0,D,r);B=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(m==null?void 0:m.length)&&(L.pointList=m);const N=R.includes(L.attribute);Z(B);const z=P(B),Q=(C=i==null?void 0:i.polygonList)!=null?C:[];B.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(b=y==null?void 0:y.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(z!=null?z:[],Q,!1),N?d([]):(d(B.id),r&&synchronizeTopView(B,L,t,e)),A({newBoxParams:B})},pt=s=>{const{boxID:n,imageName:u,width:l,height:g,x:r,y:h}=s,C=f.find(m=>m.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(m=>m.imageName===u))return;const D=C.rects.map(m=>m.imageName===u?__spreadProps(__spreadValues({},m),{width:l,height:g,x:r,y:h}):m),L=__spreadProps(__spreadValues({},C),{rects:D}),B=f.map(m=>m.id===n?L:m);return t==null||t.updatePolygonList(B!=null?B:[]),B},gt=s=>{const{boxID:n,imageName:u}=s,l=f.find(C=>C.id===n);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==u),r=__spreadProps(__spreadValues({},l),{rects:g}),h=f.map(C=>C.id===n?r:C);return t==null||t.updatePolygonList(h!=null?h:[]),h},Pt=({newSelectedBox:s,newPointCloudList:n,newSelectedSphere:u,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(x.length===0||!r)){if(s||(U==null?void 0:U.info)){const h=s!=null?s:U==null?void 0:U.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(x[0]);const C=r.selectedPolygon;if(x.length===1&&h){q({omitView:PointCloudView.Top,polygon:C,boxParams:h,newPointCloudBoxList:n});return}}if((u||F)&&x.length===1){const h=u!=null?u:F;r.setSelectedID(x[0]);const C=r.selectedPoint;h&&H(PointCloudView.Top,C,h,void 0,l,y)}}},K=(s,n,u,l=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{if(Y){let g,r;switch(u){case PointCloudView.Back:g=backViewPolygon2PointCloud;break;case PointCloudView.Side:g=sideViewPolygon2PointCloud;break;default:g=sideViewPolygon2PointCloud;break}if(r=g(s,n,Y,a.pointCloudInstance),e){const{count:L}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:L})}const C=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],b=r.valid!==C.valid;r=C;const D=lt(r);return r=D.find(L=>L.id===r.id),q({omitView:b?void 0:u,polygon:s,boxParams:r,newPointCloudBoxList:D},l),D}},$=(s,n,u)=>{if(F){let l,g;switch(u){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}g=l(s,n,F);const r=X(g);return H(u,s,g,void 0,r,y),r}},Ct=(s,n)=>{$(s,n,PointCloudView.Side)},ft=(s,n)=>{$(s,n,PointCloudView.Back)},ht=(s,n)=>{K(s,n,PointCloudView.Side,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},xt=(s,n)=>{K(s,n,PointCloudView.Back,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},vt=(s,n)=>{const u=it(s.id),l=topViewPoint2PointCloud(s,n,J,u),g=X(l);H(PointCloudView.Top,s,l,void 0,g,y)},Lt=(s,n)=>{if(ot){const l=__spreadValues({},s[0].newPolygon);l.pointList=l.pointList.map(g=>lbUtils.PointCloudUtils.transferCanvas2World(g,n)),w(l);return}let u=s.map(({newPolygon:l})=>{const g=at(l.id),{boxParams:r}=topViewPolygon2PointCloud(l,n,t.pointCloudInstance,g);return r});if(u=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:u,stepConfig:y,action:"viewUpdateBox"})),u.length===1){const{newPolygon:l}=s[0],g=G(u);q({polygon:l,boxParams:u[0],newPointCloudBoxList:g},ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)}else{const l=G(u);l&&i.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,l)}},yt=s=>{var n,u,l,g,r;if(U){const h=Number(s.widthDefault),C=Number(s.depthDefault),b=Number(s.heightDefault),D=U==null?void 0:U.info.trackID,B=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(W=>(W==null?void 0:W.trackID)===D),m={width:(l=(u=t==null?void 0:t.toolInstance)==null?void 0:u.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},j=B.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,m)),N=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(j,b,h),z=N[0],Q=N[2],tt=lbAnnotation.MathUtils.getLineCenterPoint([z,Q]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:tt.x,y:tt.y,z:mt+C/2},width:h,height:b,depth:C,valid:!0}),Bt=G([et]);q({omitView:PointCloudView["3D"],polygon:B,boxParams:et,newPointCloudBoxList:Bt})}},H=(s,n,u,l,g,r)=>__async(void 0,null,function*(){const h=E==null?void 0:E.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(u,n,a,h,r)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(u,n,p,h,r)},[PointCloudView.Top]:()=>{syncTopViewByPoint(u,n,t,e)}};Object.keys(C).forEach(b=>{b!==s&&C[b]()}),l&&(e==null||e.updateCameraZoom(l)),dt(u)}),q=(s,n=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:u,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:h}=s,C=E==null?void 0:E.url;h&&i.syncAllViewPointCloudColor(n,h);const b={[PointCloudView.Side]:()=>{synchronizeSideView(g,l,a,C)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(g,l,p,C)},[PointCloudView.Top]:()=>{synchronizeTopView(g,l,t,e)}};Object.keys(b).forEach(D=>{D!==u&&b[D]()}),r&&(e==null||e.updateCameraZoom(r))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:q,syncPointCloudPoint:H,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const n=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);e.initOrthographicCamera(n),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(n=E){var u,l,g,r,h,C,b,D;if(!(n==null?void 0:n.url)||!e)return;I([]),actionCreators.SetAnnotationLoading(M,!0),actionCreators.SetLoadPCDFileLoading(M,!0),(u=o==null?void 0:o.setResourceLoading)==null||u.call(o,!0),yield e.loadPCDFile(n.url,(l=y==null?void 0:y.radius)!=null?l:DEFAULT_RADIUS,y==null?void 0:y.tipScopeList),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let L=[],B=[],m=[],j=[];e.updateTopCamera();const N=(r=(g=index.jsonParser(n.result))==null?void 0:g.valid)!=null?r:!0;if(i.setPointCloudValid(N),(h=i.sideViewInstance)==null||h.clearAllData(),(C=i.backViewInstance)==null||C.clearAllData(),n.result){if(L=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),(L==null?void 0:L.length)>0&&n.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){L=yield e==null?void 0:e.filterPreResult(n.url,y,L);const z=index.jsonParser(n.result);z[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=L,n.result=JSON.stringify(z),i.setPointCloudResult(L)}m=lbUtils.PointCloudUtils.getPolygonListFromResultList(n.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(n.result),j=lbUtils.PointCloudUtils.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(b=y==null?void 0:y.radius)!=null?b:DEFAULT_RADIUS}),e==null||e.generateBoxes(L),e==null||e.generateSpheres(j),yield i.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,L,[])}O({pointCloudBoxList:L,polygonList:m,lineList:B,pointCloudSphereList:j}),actionCreators.SetAnnotationLoading(M,!1),actionCreators.SetLoadPCDFileLoading(M,!1),(D=o==null?void 0:o.setResourceLoading)==null||D.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:Z,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:i,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),a=ahooks.useLatest(o),p=ahooks.useLatest(i);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=a.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 v=f.extId,R=f.imageName,I=_.pick(f,["x","y","width","height"]);let S=d.get(v);S||(S=new Map,d.set(v,S)),S.set(R,I),x.add(v)}),d.size){const f=P.map(v=>{var R;const I=v.id;if(x.has(I)){const S=__spreadValues({},v);return(R=S.rects)==null||R.forEach(V=>{var k;const T=V.imageName;Object.assign(V,(k=d.get(I))==null?void 0:k.get(T))}),S}return v});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,5 +1,6 @@
1
- import { IPointCloudConfig } from '@labelbee/lb-utils';
1
+ import { IPointCloudConfig, ITipScopeParams } from '@labelbee/lb-utils';
2
2
  export declare const useConfig: () => {
3
3
  syncAllViewsConfig: (config: IPointCloudConfig) => void;
4
4
  reRenderTopViewRange: (radius: number) => void;
5
+ reRenderTopViewTipScopeList: (tipScopeList?: ITipScopeParams[]) => void;
5
6
  };
@@ -1 +1 @@
1
- import{PointCloudContext as oe}from"./PointCloudContext.js";import{useRotate as re}from"./hooks/useRotate.js";import{useRotateEdge as se}from"./hooks/useRotateEdge.js";import{useBoxes as ne}from"./hooks/useBoxes.js";import{useSingleBox as ie}from"./hooks/useSingleBox.js";import{useSphere as ae}from"./hooks/useSphere.js";import{useContext as ue,useEffect as c}from"react";import{CommonToolUtils as le,EToolName as P,cTool as ce}from"@labelbee/lb-annotation";import{Modal as de,message as y}from"antd";import{connect as pe}from"react-redux";import{a2MapStateToProps as me}from"../../store/annotation/map.js";import{useStatus as Pe}from"./hooks/useStatus.js";import{usePointCloudViews as we}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as fe}from"../../store/ctx.js";import{useHistory as ve}from"./hooks/useHistory.js";import{useAttribute as be}from"./hooks/useAttribute.js";import{useConfig as ye}from"./hooks/useConfig.js";import{usePolygon as ge}from"./hooks/usePolygon.js";import{useLine as he}from"./hooks/useLine.js";import{useUpdatePointCloudColor as Ce}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as Se}from"react-i18next";import{useLatest as B}from"ahooks";var ke=Object.defineProperty,Ve=Object.defineProperties,xe=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,j=(i,r,u)=>r in i?ke(i,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[r]=u,w=(i,r)=>{for(var u in r||(r={}))_e.call(r,u)&&j(i,u,r[u]);if(O)for(var u of O(r))Ie.call(r,u)&&j(i,u,r[u]);return i},f=(i,r)=>Ve(i,xe(r));const{EPolygonPattern:Be}=ce,Oe=({currentData:i,config:r,checkMode:u,configString:L,imgIndex:g,toolInstanceRef:a,setResourceLoading:h,isBatchSetValid:A})=>{const e=ue(oe),{changeSelectedBoxValid:T,selectNextBox:E,selectPrevBox:D,updateSelectedBox:H,deleteSelectedPointCloudBoxAndPolygon:K}=ie(),{selectedSphere:v,updatePointCloudSphere:N}=ae(),{clearAllResult:C,updatePointCloudPattern:U}=Pe(),{copySelectedBoxes:z,pasteSelectedBoxes:R,copiedBoxes:Le}=ne({config:r,currentData:i}),{updateRotate:S}=re({currentData:i}),{updateRotateEdge:F}=se({currentData:i}),{updatePointCloudData:p,topViewSelectedChanged:M}=we({setResourceLoading:h}),{redo:k,undo:V,pushHistoryWithList:q,pushHistoryUnderUpdatePolygon:G,pushHistoryUnderUpdateLine:W}=ve(),{syncThreeViewsAttribute:x}=be(),{syncAllViewsConfig:Y,reRenderTopViewRange:$}=ye(),{selectedPolygon:_}=ge(),{selectedLine:I}=he(),{t:b}=Se(),{updatePointCloudColor:J}=Ce(h,r),Q=B(i),m=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},X=(t,o)=>{const{topViewInstance:s,mainViewInstance:n}=e;if(!s)return;const{pointCloud2dOperation:l}=s;switch(t){case"q":{S(e.rectRotateSensitivity);break}case"e":S(-Number(e.rectRotateSensitivity));break;case"g":F(-90);break;case"u":{const d=l.pattern===Be.Normal?P.Rect:P.Polygon;U(d);const te={[P.Polygon]:b("PolygonPattern"),[P.Rect]:b("RectPattern")};y.success(b("ChangePatternMsg",{pattern:te[d]})),l.clearActiveStatus(),l.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":A?(de.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){D();break}E(),o.preventDefault();break;case"f":T();break;case"arrowup":m({y:-1});break;case"arrowdown":m({y:1});break;case"arrowleft":m({x:-1});break;case"arrowright":m({x:1});break;case"delete":K(Q.current);break}},Z=(t,o)=>{switch(t){case"c":z();break;case"v":R();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?k():V();break}}},ee=B(t=>{if(!le.hotkeyFilter(t)||u===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){Z(o,t);return}X(o,t)});return c(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(l=>ee.current(l))},[e,e.topViewInstance,e.windowKeydownListenerHook]),c(()=>{Y(r)},[L]),c(()=>{(r==null?void 0:r.radius)&&$(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{p==null||p()},[g,e.mainViewInstance]),c(()=>{e.setHideAttributes([])},[g]),c(()=>{a.current.setAttrChangeTrigger=t=>{var o;(o=e.topViewInstance)==null||o.toolInstance.setAttrChangeTrigger(t)},a.current.setDefaultAttribute=t=>{var o;if(x(t),J(t),_&&G(f(w({},_),{attribute:t})),I&&W(f(w({},I),{attribute:t})),v){const s=N(f(w({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),M({newSelectedSphere:v,newSphereList:s}))}},a.current.setSubAttribute=(t,o)=>{var s;const n=e.selectedPointCloudBox;if(n){const l=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=f(w({},l),{[t]:o}),H(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},a.current.clearResult=()=>{C==null||C()},a.current.redo=()=>{k()},a.current.undo=()=>{V()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},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]),c(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),c(()=>{a.current.history={pushHistory:t=>{q({pointCloudBoxList:t})},initRecord:()=>{}}},[]),c(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||u)return;const s=d=>{x(d)},n=d=>{y.error(d)},l=d=>{y.info(d)};return o.on("syncAttribute",s),o.on("messageError",n),o.on("messageInfo",l),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",n),o.unbind("messageInfo",l)}},[e.topViewInstance]),null};var je=pe(me,null,null,{context:fe})(Oe);export{je as default};
1
+ import{PointCloudContext as re}from"./PointCloudContext.js";import{useRotate as se}from"./hooks/useRotate.js";import{useRotateEdge as ne}from"./hooks/useRotateEdge.js";import{useBoxes as ie}from"./hooks/useBoxes.js";import{useSingleBox as ae}from"./hooks/useSingleBox.js";import{useSphere as le}from"./hooks/useSphere.js";import{useContext as ue,useEffect as c}from"react";import{CommonToolUtils as ce,EToolName as v,cTool as de}from"@labelbee/lb-annotation";import{Modal as pe,message as f}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as ve}from"../../store/annotation/map.js";import{useStatus as Pe}from"./hooks/useStatus.js";import{usePointCloudViews as we}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as be}from"../../store/ctx.js";import{useHistory as ye}from"./hooks/useHistory.js";import{useAttribute as fe}from"./hooks/useAttribute.js";import{useConfig as he}from"./hooks/useConfig.js";import{usePolygon as Ce}from"./hooks/usePolygon.js";import{useLine as Se}from"./hooks/useLine.js";import{useUpdatePointCloudColor as ge}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as ke}from"react-i18next";import{useLatest as L}from"ahooks";var Ve=Object.defineProperty,xe=Object.defineProperties,_e=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,O=(i,r,l)=>r in i?Ve(i,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[r]=l,P=(i,r)=>{for(var l in r||(r={}))Ie.call(r,l)&&O(i,l,r[l]);if(B)for(var l of B(r))Le.call(r,l)&&O(i,l,r[l]);return i},w=(i,r)=>xe(i,_e(r));const{EPolygonPattern:Be}=de,Oe=({currentData:i,config:r,checkMode:l,configString:j,imgIndex:h,toolInstanceRef:a,setResourceLoading:C,isBatchSetValid:T})=>{const e=ue(re),{changeSelectedBoxValid:A,selectNextBox:E,selectPrevBox:D,updateSelectedBox:H,deleteSelectedPointCloudBoxAndPolygon:K}=ae(),{selectedSphere:b,updatePointCloudSphere:N}=le(),{clearAllResult:S,updatePointCloudPattern:U}=Pe(),{copySelectedBoxes:z,pasteSelectedBoxes:R,copiedBoxes:Te}=ie({config:r,currentData:i}),{updateRotate:g}=se({currentData:i}),{updateRotateEdge:F}=ne({currentData:i}),{updatePointCloudData:p,topViewSelectedChanged:M}=we({setResourceLoading:C}),{redo:k,undo:V,pushHistoryWithList:q,pushHistoryUnderUpdatePolygon:G,pushHistoryUnderUpdateLine:W}=ye(),{syncThreeViewsAttribute:x}=fe(),{syncAllViewsConfig:Y,reRenderTopViewRange:$,reRenderTopViewTipScopeList:J}=he(),{selectedPolygon:_}=Ce(),{selectedLine:I}=Se(),{t:y}=ke(),{updatePointCloudColor:Q}=ge(C,r),X=L(i),m=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},Z=(t,o)=>{const{topViewInstance:s,mainViewInstance:n}=e;if(!s)return;const{pointCloud2dOperation:u}=s;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":F(-90);break;case"u":{const d=u.pattern===Be.Normal?v.Rect:v.Polygon;U(d);const oe={[v.Polygon]:y("PolygonPattern"),[v.Rect]:y("RectPattern")};f.success(y("ChangePatternMsg",{pattern:oe[d]})),u.clearActiveStatus(),u.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":T?(pe.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){D();break}E(),o.preventDefault();break;case"f":A();break;case"arrowup":m({y:-1});break;case"arrowdown":m({y:1});break;case"arrowleft":m({x:-1});break;case"arrowright":m({x:1});break;case"delete":K(X.current);break}},ee=(t,o)=>{switch(t){case"c":z();break;case"v":R();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?k():V();break}}},te=L(t=>{if(!ce.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){ee(o,t);return}Z(o,t)});return c(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(u=>te.current(u))},[e,e.topViewInstance,e.windowKeydownListenerHook]),c(()=>{Y(r)},[j]),c(()=>{(r==null?void 0:r.radius)&&$(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{(r==null?void 0:r.tipScopeList)&&J(r==null?void 0:r.tipScopeList)},[r==null?void 0:r.tipScopeList]),c(()=>{p==null||p()},[h,e.mainViewInstance]),c(()=>{e.setHideAttributes([])},[h]),c(()=>{a.current.setAttrChangeTrigger=t=>{var o;(o=e.topViewInstance)==null||o.toolInstance.setAttrChangeTrigger(t)},a.current.setDefaultAttribute=t=>{var o;if(x(t),Q(t),_&&G(w(P({},_),{attribute:t})),I&&W(w(P({},I),{attribute:t})),b){const s=N(w(P({},b),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),M({newSelectedSphere:b,newSphereList:s}))}},a.current.setSubAttribute=(t,o)=>{var s;const n=e.selectedPointCloudBox;if(n){const u=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=w(P({},u),{[t]:o}),H(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},a.current.clearResult=()=>{S==null||S()},a.current.redo=()=>{k()},a.current.undo=()=>{V()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},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]),c(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),c(()=>{a.current.history={pushHistory:t=>{q({pointCloudBoxList:t})},initRecord:()=>{}}},[]),c(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||l)return;const s=d=>{x(d)},n=d=>{f.error(d)},u=d=>{f.info(d)};return o.on("syncAttribute",s),o.on("messageError",n),o.on("messageInfo",u),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",n),o.unbind("messageInfo",u)}},[e.topViewInstance]),null};var je=me(ve,null,null,{context:be})(Oe);export{je as default};
@@ -1 +1 @@
1
- import{PointCloudContext as r}from"../PointCloudContext.js";import{useContext as s}from"react";const v=()=>{const{topViewInstance:t,sideViewInstance:d,backViewInstance:a,mainViewInstance:i}=s(r);return{syncAllViewsConfig:n=>{[t,d,a].forEach(e=>{var o,l;e==null||e.updateConfig(n);const u=(l=(o=n==null?void 0:n.attributeList)==null?void 0:o[0])==null?void 0:l.value;u&&(e==null||e.pointCloud2dOperation.setDefaultAttribute(u))}),i==null||i.setConfig(n)},reRenderTopViewRange:n=>{var e,o,l;(o=(e=t==null?void 0:t.pointCloudInstance)==null?void 0:e.generateRange)==null||o.call(e,n),(l=t==null?void 0:t.pointCloudInstance)==null||l.render()}}};export{v as useConfig};
1
+ import{PointCloudContext as a}from"../PointCloudContext.js";import{useContext as s}from"react";const p=()=>{const{topViewInstance:n,sideViewInstance:u,backViewInstance:r,mainViewInstance:i}=s(a);return{syncAllViewsConfig:o=>{[n,u,r].forEach(e=>{var t,l;e==null||e.updateConfig(o);const d=(l=(t=o==null?void 0:o.attributeList)==null?void 0:t[0])==null?void 0:l.value;d&&(e==null||e.pointCloud2dOperation.setDefaultAttribute(d))}),i==null||i.setConfig(o)},reRenderTopViewRange:o=>{var e,t,l;(t=(e=n==null?void 0:n.pointCloudInstance)==null?void 0:e.generateRange)==null||t.call(e,o),(l=n==null?void 0:n.pointCloudInstance)==null||l.render()},reRenderTopViewTipScopeList:(o=[])=>{var e,t,l;(t=(e=n==null?void 0:n.pointCloudInstance)==null?void 0:e.generateTipScopeList)==null||t.call(e,o),(l=n==null?void 0:n.pointCloudInstance)==null||l.render()}}};export{p as useConfig};
@@ -1 +1 @@
1
- import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as ht}from"react";import{PointCloudContext as xt}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as F}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as rt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as lt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as K}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n)=>{for(var t in n||(n={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,n,t,d,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?x(x({},d),a):A(x({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},at=(e,n,t,d,p,o)=>{let f=e.pointList.map(D=>O.transferCanvas2World(D,n)),u=0,a=1,h={};if(t){const D=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&D.fittedCoordinates.length>0&&(f=D.fittedCoordinates),u=(D.maxZ+D.minZ)/2,a=D.maxZ-D.minZ,h={count:D.zCount}}const[P,L,T]=f,V=w.getLineCenterPoint([P,T]),R=w.getLineLength(P,L),U=w.getLineLength(L,T),N=w.getRadiusFromQuadrangle(e.pointList);d&&(u=d.center.z,a=d.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+It:U,height:o?R+It:R,depth:a,rotation:N,id:e.id},j=x(d?x(x({},d),z):A(x({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const E=f.map(D=>O.transferWorld2Canvas(D,n));return{boxParams:j,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},Dt=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j,{newBoxParams:D}=d.getNewBoxBySideUpdate(V,E,N,t);return D},Lo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},vo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j;let{newBoxParams:D}=d.getNewBoxByBackUpdate(V,E,N,t);return D},St=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,X.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(x(x({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ct=(e,n,t,d)=>{var p,o;if(!t||!d)return;d.generateBox(e),d.setHighlightColor(e.id),d.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),h=[...f.polygonList],P=h.find(L=>L.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},yo=e=>{const n=mt(xt),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:P,pointCloudSphereList:L,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:R,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:E,pushHistoryUnderUpdatePolygon:D}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:ut,selectedSphere:Y}=ro(),{currentData:W,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:rt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(R),Ut=K(z),zt=ht((s,i)=>{const c=Ut.current,l=i.id;return s.filter(r=>{if(!r)return!1;const m=c.get(r.imageName);return m===void 0?!0:Boolean(m.get(l))})},[]),ot=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=W;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),pt=k==null?void 0:k.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:nt}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:c,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const m=dt(s,i,nt,void 0,r);a(s.id);const C=u(m);J(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,S;const _={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(_,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:L})}),t==null||t.toolInstance;const v=x({},s);let{boxParams:I,newPointList:B}=at(v,i,nt,void 0,_,r);I=M(lt({tool:st.PointCloud,dataList:[I],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(B==null?void 0:B.length)&&(v.pointList=B);const G=T.includes(v.attribute);ot(I);const H=f(I),it=(C=n==null?void 0:n.polygonList)!=null?C:[];I.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(S=y==null?void 0:y.inputList)!=null?S:[]:[]),t==null||t.updatePolygonList(H!=null?H:[],it,!1),G?a([]):(a(I.id),r&&ct(I,v,t,o)),j({newBoxParams:I})},Ft=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(B=>B.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===c))return;const _=C.rects.map(B=>B.imageName===c?A(x({},B),{width:l,height:g,x:r,y:m}):B),v=A(x({},C),{rects:_}),I=P.map(B=>B.id===i?v:B);return t==null||t.updatePolygonList(I!=null?I:[]),I},Wt=s=>{const{boxID:i,imageName:c}=s,l=P.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==c),r=A(x({},l),{rects:g}),m=P.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(h.length===0||!r)){if(s||(k==null?void 0:k.info)){const m=s!=null?s:k==null?void 0:k.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(h[0]);const C=r.selectedPolygon;if(h.length===1&&m){Q({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Y)&&h.length===1){const m=c!=null?c:Y;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&J(b.Top,C,m,void 0,l,y)}}},gt=(s,i,c,l=F.Default)=>{if(pt){let g,r;switch(c){case b.Back:g=vo;break;case b.Side:g=Dt;break;default:g=Dt;break}if(r=g(s,i,pt,d.pointCloudInstance),o){const{count:v}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(x({},r),{count:v})}const C=M(lt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],S=r.valid!==C.valid;r=C;const _=Nt(r);return r=_.find(v=>v.id===r.id),Q({omitView:S?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:_},l),_}},ft=(s,i,c)=>{if(Y){let l,g;switch(c){case b.Back:l=Lo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Y);const r=ut(g);return J(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{ft(s,i,b.Side)},Jt=(s,i)=>{ft(s,i,b.Back)},Qt=(s,i)=>{gt(s,i,b.Side,F.Single)},Xt=(s,i)=>{gt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=dt(s,i,nt,c),g=ut(l);J(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=x({},s[0].newPolygon);l.pointList=l.pointList.map(g=>O.transferCanvas2World(g,i)),D(l);return}let c=s.map(({newPolygon:l})=>{const g=jt(l.id),{boxParams:r}=at(l,i,t.pointCloudInstance,g);return r});if(c=M(lt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Q({polygon:l,boxParams:c[0],newPointCloudBoxList:g},F.Single)}else{const l=et(c);l&&n.syncAllViewPointCloudColor(F.MultiMove,l)}},Kt=s=>{var i,c,l,g,r;if(k){const m=Number(s.widthDefault),C=Number(s.depthDefault),S=Number(s.heightDefault),_=k==null?void 0:k.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===_),B={width:(l=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},Z=I.pointList.map(q=>O.transferCanvas2World(q,B)),G=w.getModifiedRectangleCoordinates(Z,S,m),H=G[0],it=G[2],Ct=w.getLineCenterPoint([H,it]),$t=k.info.center.z-k.info.depth/2,Pt=A(x({},k.info),{center:{x:Ct.x,y:Ct.y,z:$t+C/2},width:m,height:S,depth:C,valid:!0}),to=et([Pt]);Q({omitView:b["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:to})}},J=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=W==null?void 0:W.url,C={[b.Side]:()=>{St(c,i,d,m,r)},[b.Back]:()=>{p&&_t(c,i,p,m,r)},[b.Top]:()=>{kt(c,i,t,o)}};Object.keys(C).forEach(S=>{S!==s&&C[S]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Q=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=W==null?void 0:W.url;m&&n.syncAllViewPointCloudColor(i,m);const S={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{ct(g,l,t,o)}};Object.keys(S).forEach(_=>{_!==c&&S[_]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=W){var c,l,g,r,m,C,S,_;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(M,!0),vt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:tt),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],I=[],B=[],Z=[];o.updateTopCamera();const G=(r=(g=rt(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(G),(m=n.sideViewInstance)==null||m.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(v=O.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,y,v);const H=rt(i.result);H[no].result=v,i.result=JSON.stringify(H),n.setPointCloudResult(v)}B=O.getPolygonListFromResultList(i.result),I=O.getLineListFromResultList(i.result),Z=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(S=y==null?void 0:y.radius)!=null?S:tt}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(Z),yield n.syncAllViewPointCloudColor(F.Default,v,[])}E({pointCloudBoxList:v,polygonList:B,lineList:I,pointCloudSphereList:Z}),Lt(M,!1),vt(M,!1),(_=e==null?void 0:e.setResourceLoading)==null||_.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=K(e),p=K(n);return{syncToPointCloudBoxList:ht(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const L=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let R=a.get(L);R||(R=new Map,a.set(L,R)),R.set(T,V),h.add(L)}),a.size){const P=f.map(L=>{var T;const V=L.id;if(h.has(V)){const R=x({},L);return(T=R.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),R}return L});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
1
+ import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as ht}from"react";import{PointCloudContext as xt}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as F}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as rt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as lt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as K}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n)=>{for(var t in n||(n={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,n,t,d,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?x(x({},d),a):A(x({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},at=(e,n,t,d,p,o)=>{let f=e.pointList.map(S=>O.transferCanvas2World(S,n)),u=0,a=1,h={};if(t){const S=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&S.fittedCoordinates.length>0&&(f=S.fittedCoordinates),u=(S.maxZ+S.minZ)/2,a=S.maxZ-S.minZ,h={count:S.zCount}}const[P,L,T]=f,V=w.getLineCenterPoint([P,T]),R=w.getLineLength(P,L),U=w.getLineLength(L,T),N=w.getRadiusFromQuadrangle(e.pointList);d&&(u=d.center.z,a=d.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+It:U,height:o?R+It:R,depth:a,rotation:N,id:e.id},j=x(d?x(x({},d),z):A(x({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const E=f.map(S=>O.transferWorld2Canvas(S,n));return{boxParams:j,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},St=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j,{newBoxParams:S}=d.getNewBoxBySideUpdate(V,E,N,t);return S},Lo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},vo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j;let{newBoxParams:S}=d.getNewBoxByBackUpdate(V,E,N,t);return S},Dt=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,X.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(x(x({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ct=(e,n,t,d)=>{var p,o;if(!t||!d)return;d.generateBox(e),d.setHighlightColor(e.id),d.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),h=[...f.polygonList],P=h.find(L=>L.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},yo=e=>{const n=mt(xt),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:P,pointCloudSphereList:L,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:R,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:E,pushHistoryUnderUpdatePolygon:S}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:ut,selectedSphere:Y}=ro(),{currentData:W,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:rt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(R),Ut=K(z),zt=ht((s,i)=>{const c=Ut.current,l=i.id;return s.filter(r=>{if(!r)return!1;const m=c.get(r.imageName);return m===void 0?!0:Boolean(m.get(l))})},[]),ot=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=W;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),pt=k==null?void 0:k.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:nt}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:c,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const m=dt(s,i,nt,void 0,r);a(s.id);const C=u(m);J(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,D;const _={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(_,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:L})}),t==null||t.toolInstance;const v=x({},s);let{boxParams:I,newPointList:B}=at(v,i,nt,void 0,_,r);I=M(lt({tool:st.PointCloud,dataList:[I],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(B==null?void 0:B.length)&&(v.pointList=B);const G=T.includes(v.attribute);ot(I);const H=f(I),it=(C=n==null?void 0:n.polygonList)!=null?C:[];I.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(D=y==null?void 0:y.inputList)!=null?D:[]:[]),t==null||t.updatePolygonList(H!=null?H:[],it,!1),G?a([]):(a(I.id),r&&ct(I,v,t,o)),j({newBoxParams:I})},Ft=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(B=>B.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===c))return;const _=C.rects.map(B=>B.imageName===c?A(x({},B),{width:l,height:g,x:r,y:m}):B),v=A(x({},C),{rects:_}),I=P.map(B=>B.id===i?v:B);return t==null||t.updatePolygonList(I!=null?I:[]),I},Wt=s=>{const{boxID:i,imageName:c}=s,l=P.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==c),r=A(x({},l),{rects:g}),m=P.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(h.length===0||!r)){if(s||(k==null?void 0:k.info)){const m=s!=null?s:k==null?void 0:k.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(h[0]);const C=r.selectedPolygon;if(h.length===1&&m){Q({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Y)&&h.length===1){const m=c!=null?c:Y;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&J(b.Top,C,m,void 0,l,y)}}},gt=(s,i,c,l=F.Default)=>{if(pt){let g,r;switch(c){case b.Back:g=vo;break;case b.Side:g=St;break;default:g=St;break}if(r=g(s,i,pt,d.pointCloudInstance),o){const{count:v}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(x({},r),{count:v})}const C=M(lt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],D=r.valid!==C.valid;r=C;const _=Nt(r);return r=_.find(v=>v.id===r.id),Q({omitView:D?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:_},l),_}},ft=(s,i,c)=>{if(Y){let l,g;switch(c){case b.Back:l=Lo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Y);const r=ut(g);return J(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{ft(s,i,b.Side)},Jt=(s,i)=>{ft(s,i,b.Back)},Qt=(s,i)=>{gt(s,i,b.Side,F.Single)},Xt=(s,i)=>{gt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=dt(s,i,nt,c),g=ut(l);J(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=x({},s[0].newPolygon);l.pointList=l.pointList.map(g=>O.transferCanvas2World(g,i)),S(l);return}let c=s.map(({newPolygon:l})=>{const g=jt(l.id),{boxParams:r}=at(l,i,t.pointCloudInstance,g);return r});if(c=M(lt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Q({polygon:l,boxParams:c[0],newPointCloudBoxList:g},F.Single)}else{const l=et(c);l&&n.syncAllViewPointCloudColor(F.MultiMove,l)}},Kt=s=>{var i,c,l,g,r;if(k){const m=Number(s.widthDefault),C=Number(s.depthDefault),D=Number(s.heightDefault),_=k==null?void 0:k.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===_),B={width:(l=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},Z=I.pointList.map(q=>O.transferCanvas2World(q,B)),G=w.getModifiedRectangleCoordinates(Z,D,m),H=G[0],it=G[2],Ct=w.getLineCenterPoint([H,it]),$t=k.info.center.z-k.info.depth/2,Pt=A(x({},k.info),{center:{x:Ct.x,y:Ct.y,z:$t+C/2},width:m,height:D,depth:C,valid:!0}),to=et([Pt]);Q({omitView:b["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:to})}},J=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=W==null?void 0:W.url,C={[b.Side]:()=>{Dt(c,i,d,m,r)},[b.Back]:()=>{p&&_t(c,i,p,m,r)},[b.Top]:()=>{kt(c,i,t,o)}};Object.keys(C).forEach(D=>{D!==s&&C[D]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Q=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=W==null?void 0:W.url;m&&n.syncAllViewPointCloudColor(i,m);const D={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{ct(g,l,t,o)}};Object.keys(D).forEach(_=>{_!==c&&D[_]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=W){var c,l,g,r,m,C,D,_;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(M,!0),vt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:tt,y==null?void 0:y.tipScopeList),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],I=[],B=[],Z=[];o.updateTopCamera();const G=(r=(g=rt(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(G),(m=n.sideViewInstance)==null||m.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(v=O.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,y,v);const H=rt(i.result);H[no].result=v,i.result=JSON.stringify(H),n.setPointCloudResult(v)}B=O.getPolygonListFromResultList(i.result),I=O.getLineListFromResultList(i.result),Z=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(D=y==null?void 0:y.radius)!=null?D:tt}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(Z),yield n.syncAllViewPointCloudColor(F.Default,v,[])}E({pointCloudBoxList:v,polygonList:B,lineList:I,pointCloudSphereList:Z}),Lt(M,!1),vt(M,!1),(_=e==null?void 0:e.setResourceLoading)==null||_.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=K(e),p=K(n);return{syncToPointCloudBoxList:ht(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const L=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let R=a.get(L);R||(R=new Map,a.set(L,R)),R.set(T,V),h.add(L)}),a.size){const P=f.map(L=>{var T;const V=L.id;if(h.has(V)){const R=x({},L);return(T=R.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),R}return L});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,Dt as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.24.0-alpha.50",
3
+ "version": "1.24.0-alpha.51",
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.28.0-alpha.27",
47
- "@labelbee/lb-utils": "1.20.0-alpha.5",
46
+ "@labelbee/lb-annotation": "1.28.0-alpha.28",
47
+ "@labelbee/lb-utils": "1.20.0-alpha.6",
48
48
  "@labelbee/wavesurfer": "1.1.0",
49
49
  "@types/react-dom": "18.3.1",
50
50
  "@types/react-transition-group": "^4.4.9",