@labelbee/lb-components 1.14.0-alpha.7 → 1.14.0-alpha.9
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.
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),reactI18next=require("react-i18next"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(
|
|
1
|
+
"use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),reactI18next=require("react-i18next"),actionCreators=require("../../store/annotation/actionCreators.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(l,r,u)=>r in l?__defProp(l,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[r]=u,__spreadValues=(l,r)=>{for(var u in r||(r={}))__hasOwnProp.call(r,u)&&__defNormalProp(l,u,r[u]);if(__getOwnPropSymbols)for(var u of __getOwnPropSymbols(r))__propIsEnum.call(r,u)&&__defNormalProp(l,u,r[u]);return l},__spreadProps=(l,r)=>__defProps(l,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:l,config:r,checkMode:u,configString:B,imgIndex:f,toolInstanceRef:a})=>{const t=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:L,selectNextBox:E,selectPrevBox:O,updateSelectedBox:g,deleteSelectedPointCloudBoxAndPolygon:q}=useSingleBox.useSingleBox(),{selectedSphere:P,updatePointCloudSphere:A}=useSphere.useSphere(),{clearAllResult:y,updatePointCloudPattern:j}=useStatus.useStatus(),{copySelectedBoxes:I,pasteSelectedBoxes:T,copiedBoxes:D}=useBoxes.useBoxes({config:r}),{updateRotate:w}=useRotate.useRotate({currentData:l}),{updatePointCloudData:v,topViewSelectedChanged:m}=usePointCloudViews.usePointCloudViews(),{redo:h,undo:x,pushHistoryWithList:N,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:K}=useHistory.useHistory(),U=ctx.useDispatch(),{syncThreeViewsAttribute:S}=useAttribute.useAttribute(),{syncAllViewsConfig:z,reRenderTopViewRange:R}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:_}=useLine.useLine(),{t:C}=reactI18next.useTranslation(),b=e=>{var o;const{topViewInstance:s}=t;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(e)},F=(e,o)=>{var s,i;const{topViewInstance:c,mainViewInstance:n}=t;if(!c)return;const{pointCloud2dOperation:d}=c;switch(e){case"q":{w(2);break}case"e":w(-2);break;case"g":w(180);break;case"u":{const p=d.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;j(p);const M={[lbAnnotation.EToolName.Polygon]:C("PolygonPattern"),[lbAnnotation.EToolName.Rect]:C("RectPattern")};antd.message.success(C("ChangePatternMsg",{pattern:M[p]})),d.clearActiveStatus(),d.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":t.setPointCloudValid(!t.valid);break;case"tab":if(o.shiftKey){O();break}E(),o.preventDefault();break;case"f":L();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":q();break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=lbAnnotation.AttributeUtils.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((i=a.current)==null||i.setDefaultAttribute(p))}return}}},G=(e,o)=>{switch(e){case"c":I();break;case"v":T();break;case"a":o.preventDefault(),t.selectedAllBoxes();break;case"z":{o.shiftKey?h():x();break}}},V=e=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(e)||u===!0)return;const o=e.key.toLocaleLowerCase();if(e.ctrlKey){G(o,e);return}F(o,e)};return React.useEffect(()=>{const{topViewInstance:e}=t;if(!!e)return window.addEventListener("keydown",V),()=>{window.removeEventListener("keydown",V)}},[t,D,r,t.pointCloudBoxList,t.polygonList]),React.useEffect(()=>{z(r)},[B]),React.useEffect(()=>{(r==null?void 0:r.radius)&&R(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{v==null||v()},[f,t.mainViewInstance]),React.useEffect(()=>{t.setHideAttributes([])},[f]),React.useEffect(()=>{a.current.setDefaultAttribute=e=>{var o,s,i,c;S(e);const n=t.selectedPointCloudBox;if(n){n.attribute=e;const d=U(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=d[0].valid;const p=g(n);(i=(s=(o=t==null?void 0:t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||i.call(s,n.id,!0,n.valid),t.mainViewInstance&&m({newSelectedBox:n,newPointCloudList:p})}if(k&&H(__spreadProps(__spreadValues({},k),{attribute:e})),_&&K(__spreadProps(__spreadValues({},_),{attribute:e})),P){const d=A(__spreadProps(__spreadValues({},P),{attribute:e}));t.mainViewInstance&&((c=t.mainViewInstance)==null||c.generateSpheres(d),m({newSelectedSphere:P,newSphereList:d}))}},a.current.setSubAttribute=(e,o)=>{var s;const i=t.selectedPointCloudBox;if(i){const c=(s=i==null?void 0:i.subAttribute)!=null?s:{};i.subAttribute=__spreadProps(__spreadValues({},c),{[e]:o}),g(i)}},a.current.clearResult=()=>{y==null||y()},a.current.redo=()=>{h()},a.current.undo=()=>{x()},a.current.setValid=e=>{a.current.valid=e,setTimeout(()=>{t.setPointCloudValid(e),e===!1&&y()})},a.current.setForbidOperation=e=>{var o,s;(s=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(e),e===!0&&t.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=e=>{var o,s;(s=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(e)},a.current.asyncData=e=>{setTimeout(()=>{v==null||v(e)})}},[t.pointCloudBoxList,t.pointCloudSphereList,t.selectedID,t.valid,t.polygonList,t.lineList,t.mainViewInstance,t.ptSegmentInstance]),React.useEffect(()=>{a.current.updateSegmentTool=e=>{var o;(o=t.ptSegmentInstance)==null||o.emit(e)},a.current.segmentInstance=t.ptSegmentInstance},[t.ptSegmentInstance]),React.useEffect(()=>{a.current.history={pushHistory:e=>{N({pointCloudBoxList:e})},initRecord:()=>{}}},[]),React.useEffect(()=>{var e;const o=(e=t.topViewInstance)==null?void 0:e.toolInstance;if(!o||u)return;const s=n=>{S(n)},i=n=>{antd.message.error(n)},c=n=>{antd.message.info(n)};return o.on("syncAttribute",s),o.on("messageError",i),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",i),o.unbind("messageInfo",c)}},[t.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,i)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,__spreadValues=(o,e)=>{for(var i in e||(e={}))__hasOwnProp.call(e,i)&&__defNormalProp(o,i,e[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(e))__propIsEnum.call(e,i)&&__defNormalProp(o,i,e[i]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e)),__async=(o,e,i)=>new Promise((l,t)=>{var a=c=>{try{d(i.next(c))}catch(g){t(g)}},P=c=>{try{d(i.throw(c))}catch(g){t(g)}},d=c=>c.done?l(c.value):Promise.resolve(c.value).then(a,P);d((i=i.apply(o,e)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,e,i,l,t)=>{const{x:a,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,e),{defaultZ:d}=lbUtils.DEFAULT_SPHERE_PARAMS,c={center:{x:a,y:P,z:d},id:o.id},g=l?__spreadValues(__spreadValues({},l),c):__spreadProps(__spreadValues({},c),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},topViewPolygon2PointCloud=(o,e,i,l,t,a)=>{let P=o.pointList.map(f=>lbUtils.PointCloudUtils.transferCanvas2World(f,e)),d=0,c=1,g={};if(i){const f=i.getSensesPointZAxisInPolygon(P,void 0,a);a&&f.fittedCoordinates.length>0&&(P=f.fittedCoordinates),d=(f.maxZ+f.minZ)/2,c=f.maxZ-f.minZ,g={count:f.zCount}}const[h,m,T]=P,b=lbAnnotation.MathUtils.getLineCenterPoint([h,T]),D=lbAnnotation.MathUtils.getLineLength(h,m),I=lbAnnotation.MathUtils.getLineLength(m,T),O=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);l&&(d=l.center.z,c=l.depth);const _={center:{x:b.x,y:b.y,z:d},width:a?I+INTELLIGENT_FIT_MARGIN:I,height:a?D+INTELLIGENT_FIT_MARGIN:D,depth:c,rotation:O,id:o.id},k=__spreadValues(l?__spreadValues(__spreadValues({},l),_):__spreadProps(__spreadValues({},_),{attribute:"",valid:!0}),g);t&&Object.assign(k,t);const S=P.map(f=>lbUtils.PointCloudUtils.transferWorld2Canvas(f,e));return{boxParams:k,newPointList:S}},sideViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k,{newBoxParams:f}=l.getNewBoxBySideUpdate(b,S,O,i);return f},backViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k;let{newBoxParams:f}=l.getNewBoxByBackUpdate(b,S,O,i);return f},syncSideViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereSidePoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeSideView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxSidePolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncBackViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereBackPoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeBackView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxBackPolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncTopViewByPoint=(o,e,i,l)=>{if(!i||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=i,{point2d:P}=a.getSphereTopPoint2DCoordinate(o),d=[...t.pointList].map(c=>c.id===e.id?__spreadProps(__spreadValues(__spreadValues({},e),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):c);t.setResult(d),t.setSelectedID(e.id)},synchronizeTopView=(o,e,i,l)=>{var t,a;if(!i||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:P,pointCloudInstance:d}=i,{polygon2d:c}=d.getBoxTopPolygon2DCoordinate(o),g=[...P.polygonList],h=g.find(m=>m.id===e.id);h?(h.pointList=c,h.valid=(t=o.valid)!=null?t:!0):g.push({id:e.id,pointList:c,textAttribute:"",isRect:!0,valid:(a=o.valid)!=null?a:!0}),P.setResultAndSelectedID(g,e.id)},usePointCloudViews=()=>{const o=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:e,sideViewInstance:i,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:P,setSelectedIDs:d,selectedIDs:c,pointCloudBoxList:g,pointCloudSphereList:h,hideAttributes:m,setHighlight2DDataList:T}=o,{addHistory:b,initHistory:D,pushHistoryUnderUpdatePolygon:I,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{updateSelectedBox:k,updateSelectedBoxes:S,getPointCloudByID:f}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:G,updatePointCloudSphere:H,selectedSphere:M}=useSphere.useSphere(),{currentData:z,config:L}=ctx.useSelector(n=>{const{stepList:s,step:p,imgList:u,imgIndex:r}=n.annotation;return{currentData:u[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),A=ctx.useDispatch(),{selectedBox:w}=useSingleBox.useSingleBox(),{t:Q}=reactI18next.useTranslation(),F=w==null?void 0:w.info;if(!e||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:N}=e,X=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},Y=n=>{t==null||t.generateSphere(n),t==null||t.controls.update(),t==null||t.render()},J=({newPoint:n,size:s,zoom:p,trackConfigurable:u})=>{var r;const C={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};u===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const x=topViewPoint2PointCloud(n,s,N,void 0,C);d(n.id);const y=P(x);E(PointCloudView.Top,n,x,p,y,L),b({newSphereParams:x})},K=({polygon:n,size:s,imgList:p,trackConfigurable:u,zoom:r,intelligentFit:C})=>{var x,y;const v={attribute:(x=e.toolInstance.defaultAttribute)!=null?x:""};u===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:h})});const U=e==null?void 0:e.toolInstance,V=__spreadValues({},n);let{boxParams:B,newPointList:R}=topViewPolygon2PointCloud(V,s,N,void 0,v,C);if(B=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:L,action:"viewUpdateBox"}))[0],(L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(Q("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),U.deletePolygon(B.id);return}C&&(R==null?void 0:R.length)&&(V.pointList=R);const at=m.includes(V.attribute),q=a(B),dt=(y=o==null?void 0:o.polygonList)!=null?y:[];e==null||e.updatePolygonList(q!=null?q:[],dt),at?d([]):(d(B.id),U.selection.setSelectedIDs(V.id),j({omitView:PointCloudView.Top,polygon:V,boxParams:B,zoom:r,newPointCloudBoxList:q}),C&&synchronizeTopView(B,V,e,t)),b({newBoxParams:B})},$=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:u})=>{var r;const C=e==null?void 0:e.toolInstance;if(!(c.length===0||!C)){if(n||(w==null?void 0:w.info)){const x=n!=null?n:w==null?void 0:w.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(c[0]);const y=C.selectedPolygon;if(c.length===1&&x){j({omitView:PointCloudView.Top,polygon:y,boxParams:x,newPointCloudBoxList:s});return}}if((p||M)&&c.length===1){const x=p!=null?p:M;C.setSelectedID(c[0]);const y=C.selectedPoint;x&&E(PointCloudView.Top,y,x,void 0,u,L)}}},Z=(n,s,p)=>{if(F){let u,r;switch(p){case PointCloudView.Back:u=backViewPolygon2PointCloud;break;case PointCloudView.Side:u=sideViewPolygon2PointCloud;break;default:u=sideViewPolygon2PointCloud;break}r=u(n,s,F,i.pointCloudInstance);const x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:L,action:"viewUpdateBox"}))[0],y=r.valid!==x.valid;if(r=x,t){const{count:U}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:U})}const v=k(r);return r=v.find(U=>U.id===r.id),j({omitView:y?void 0:p,polygon:n,boxParams:r,newPointCloudBoxList:v}),v}},W=(n,s,p)=>{if(M){let u,r;switch(p){case PointCloudView.Back:u=backViewPoint2PointCloud;break;case PointCloudView.Side:u=sideViewPoint2PointCloud;break;default:u=sideViewPoint2PointCloud;break}r=u(n,s,M);const C=H(r);return E(p,n,r,void 0,C,L),C}},tt=(n,s)=>{W(n,s,PointCloudView.Side)},ot=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},it=(n,s)=>{Z(n,s,PointCloudView.Back)},nt=(n,s)=>{O(n)},st=(n,s)=>{const p=G(n.id),u=topViewPoint2PointCloud(n,s,N,p),r=H(u);E(PointCloudView.Top,n,u,void 0,r,L)},rt=(n,s)=>{if(_){const u=n[0].newPolygon;u.pointList=u.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,s)),I(n[0].newPolygon);return}let p=n.map(({newPolygon:u})=>{const r=f(u.id),{boxParams:C}=topViewPolygon2PointCloud(u,s,e.pointCloudInstance,r);return C});if(p=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:L,action:"viewUpdateBox"})),p.length===1){const{newPolygon:u}=n[0],r=S(p);j({omitView:PointCloudView.Top,polygon:u,boxParams:p[0],newPointCloudBoxList:r})}else{const u=S(p);u&&o.syncAllViewPointCloudColor(u)}},lt=n=>{var s;if(w){const p=w==null?void 0:w.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(y=>(y==null?void 0:y.trackID)===p),C=__spreadProps(__spreadValues({},w.info),{width:Number(n.widthDefault),depth:Number(n.depthDefault),height:Number(n.heightDefault)}),x=S([C]);j({omitView:PointCloudView["3D"],polygon:r,boxParams:C,newPointCloudBoxList:x})}},E=(n,s,p,u,r,C)=>__async(void 0,null,function*(){const x=z==null?void 0:z.url,y={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,i,x,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(p,s,l,x,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,e,t)}};Object.keys(y).forEach(v=>{v!==n&&y[v]()}),u&&(t==null||t.updateCameraZoom(u)),Y(p)}),j=n=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:u,zoom:r,newPointCloudBoxList:C}=n,x=z==null?void 0:z.url;C&&(yield o.syncAllViewPointCloudColor(C));const y={[PointCloudView.Side]:()=>{synchronizeSideView(u,p,i,x)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(u,p,l,x)},[PointCloudView.Top]:()=>{synchronizeTopView(u,p,e,t)}};Object.keys(y).forEach(v=>{v!==s&&y[v]()}),r&&(t==null||t.updateCameraZoom(r)),X(u)});return{topViewAddSphere:J,topViewAddBox:K,topViewSelectedChanged:$,topViewUpdatePoint:st,sideViewUpdatePoint:tt,backViewUpdatePoint:ot,topViewUpdateBox:rt,topViewUpdateLine:nt,sideViewUpdateBox:et,backViewUpdateBox:it,pointCloudBoxListUpdated:n=>{e.updatePolygonList(n),t==null||t.generateBoxes(n)},initPointCloud3d:n=>{if(!t)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=z){var p,u,r,C,x,y;if(!(s==null?void 0:s.url)||!t)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield t.loadPCDFile(s.url,(p=L==null?void 0:L.radius)!=null?p:DEFAULT_RADIUS),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],U=[],V=[],B=[];t.updateTopCamera();const R=(r=(u=index.jsonParser(s.result))==null?void 0:u.valid)!=null?r:!0;o.setPointCloudValid(R),(C=o.sideViewInstance)==null||C.clearAllData(),(x=o.backViewInstance)==null||x.clearAllData(),e.updateData(s.url,s.result,{radius:(y=L==null?void 0:L.radius)!=null?y:DEFAULT_RADIUS}),s.result&&(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),V=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),U=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(B),yield o.syncAllViewPointCloudColor(v,[])),D({pointCloudBoxList:v,polygonList:V,lineList:U,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:lt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,i)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,__spreadValues=(o,e)=>{for(var i in e||(e={}))__hasOwnProp.call(e,i)&&__defNormalProp(o,i,e[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(e))__propIsEnum.call(e,i)&&__defNormalProp(o,i,e[i]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e)),__async=(o,e,i)=>new Promise((l,t)=>{var a=c=>{try{d(i.next(c))}catch(g){t(g)}},P=c=>{try{d(i.throw(c))}catch(g){t(g)}},d=c=>c.done?l(c.value):Promise.resolve(c.value).then(a,P);d((i=i.apply(o,e)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,e,i,l,t)=>{const{x:a,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,e),{defaultZ:d}=lbUtils.DEFAULT_SPHERE_PARAMS,c={center:{x:a,y:P,z:d},id:o.id},g=l?__spreadValues(__spreadValues({},l),c):__spreadProps(__spreadValues({},c),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},topViewPolygon2PointCloud=(o,e,i,l,t,a)=>{let P=o.pointList.map(f=>lbUtils.PointCloudUtils.transferCanvas2World(f,e)),d=0,c=1,g={};if(i){const f=i.getSensesPointZAxisInPolygon(P,void 0,a);a&&f.fittedCoordinates.length>0&&(P=f.fittedCoordinates),d=(f.maxZ+f.minZ)/2,c=f.maxZ-f.minZ,g={count:f.zCount}}const[h,m,z]=P,b=lbAnnotation.MathUtils.getLineCenterPoint([h,z]),D=lbAnnotation.MathUtils.getLineLength(h,m),I=lbAnnotation.MathUtils.getLineLength(m,z),O=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);l&&(d=l.center.z,c=l.depth);const _={center:{x:b.x,y:b.y,z:d},width:a?I+INTELLIGENT_FIT_MARGIN:I,height:a?D+INTELLIGENT_FIT_MARGIN:D,depth:c,rotation:O,id:o.id},k=__spreadValues(l?__spreadValues(__spreadValues({},l),_):__spreadProps(__spreadValues({},_),{attribute:"",valid:!0}),g);t&&Object.assign(k,t);const S=P.map(f=>lbUtils.PointCloudUtils.transferWorld2Canvas(f,e));return{boxParams:k,newPointList:S}},sideViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k,{newBoxParams:f}=l.getNewBoxBySideUpdate(b,S,O,i);return f},backViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k;let{newBoxParams:f}=l.getNewBoxByBackUpdate(b,S,O,i);return f},syncSideViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereSidePoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeSideView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxSidePolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncBackViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereBackPoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeBackView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxBackPolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncTopViewByPoint=(o,e,i,l)=>{if(!i||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=i,{point2d:P}=a.getSphereTopPoint2DCoordinate(o),d=[...t.pointList].map(c=>c.id===e.id?__spreadProps(__spreadValues(__spreadValues({},e),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):c);t.setResult(d),t.setSelectedID(e.id)},synchronizeTopView=(o,e,i,l)=>{var t,a;if(!i||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:P,pointCloudInstance:d}=i,{polygon2d:c}=d.getBoxTopPolygon2DCoordinate(o),g=[...P.polygonList],h=g.find(m=>m.id===e.id);h?(h.pointList=c,h.valid=(t=o.valid)!=null?t:!0):g.push({id:e.id,pointList:c,textAttribute:"",isRect:!0,valid:(a=o.valid)!=null?a:!0}),P.setResultAndSelectedID(g,e.id)},usePointCloudViews=()=>{const o=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:e,sideViewInstance:i,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:P,setSelectedIDs:d,selectedIDs:c,pointCloudBoxList:g,pointCloudSphereList:h,hideAttributes:m,setHighlight2DDataList:z}=o,{addHistory:b,initHistory:D,pushHistoryUnderUpdatePolygon:I,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{updateSelectedBox:k,updateSelectedBoxes:S,getPointCloudByID:f}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:G,updatePointCloudSphere:H,selectedSphere:M}=useSphere.useSphere(),{currentData:T,config:L}=ctx.useSelector(n=>{const{stepList:s,step:p,imgList:u,imgIndex:r}=n.annotation;return{currentData:u[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),A=ctx.useDispatch(),{selectedBox:w}=useSingleBox.useSingleBox(),{t:Q}=reactI18next.useTranslation(),F=w==null?void 0:w.info;if(!e||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:N}=e,X=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},Y=n=>{t==null||t.generateSphere(n),t==null||t.controls.update(),t==null||t.render()},J=({newPoint:n,size:s,zoom:p,trackConfigurable:u})=>{var r;const C={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};u===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const x=topViewPoint2PointCloud(n,s,N,void 0,C);d(n.id);const y=P(x);E(PointCloudView.Top,n,x,p,y,L),b({newSphereParams:x})},K=({polygon:n,size:s,imgList:p,trackConfigurable:u,zoom:r,intelligentFit:C})=>{var x,y;const v={attribute:(x=e.toolInstance.defaultAttribute)!=null?x:""};u===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:h})});const U=e==null?void 0:e.toolInstance,V=__spreadValues({},n);let{boxParams:B,newPointList:R}=topViewPolygon2PointCloud(V,s,N,void 0,v,C);if(B=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:L,action:"viewUpdateBox"}))[0],(L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(Q("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),U.deletePolygon(B.id);return}C&&(R==null?void 0:R.length)&&(V.pointList=R);const at=m.includes(V.attribute),q=a(B),dt=(y=o==null?void 0:o.polygonList)!=null?y:[];e==null||e.updatePolygonList(q!=null?q:[],dt),at?d([]):(d(B.id),U.selection.setSelectedIDs(V.id),j({omitView:PointCloudView.Top,polygon:V,boxParams:B,zoom:r,newPointCloudBoxList:q}),C&&synchronizeTopView(B,V,e,t)),b({newBoxParams:B})},$=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:u})=>{var r;const C=e==null?void 0:e.toolInstance;if(!(c.length===0||!C)){if(n||(w==null?void 0:w.info)){const x=n!=null?n:w==null?void 0:w.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(c[0]);const y=C.selectedPolygon;if(c.length===1&&x){j({omitView:PointCloudView.Top,polygon:y,boxParams:x,newPointCloudBoxList:s});return}}if((p||M)&&c.length===1){const x=p!=null?p:M;C.setSelectedID(c[0]);const y=C.selectedPoint;x&&E(PointCloudView.Top,y,x,void 0,u,L)}}},Z=(n,s,p)=>{if(F){let u,r;switch(p){case PointCloudView.Back:u=backViewPolygon2PointCloud;break;case PointCloudView.Side:u=sideViewPolygon2PointCloud;break;default:u=sideViewPolygon2PointCloud;break}r=u(n,s,F,i.pointCloudInstance);const x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:L,action:"viewUpdateBox"}))[0],y=r.valid!==x.valid;if(r=x,t){const{count:U}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:U})}const v=k(r);return r=v.find(U=>U.id===r.id),j({omitView:y?void 0:p,polygon:n,boxParams:r,newPointCloudBoxList:v}),v}},W=(n,s,p)=>{if(M){let u,r;switch(p){case PointCloudView.Back:u=backViewPoint2PointCloud;break;case PointCloudView.Side:u=sideViewPoint2PointCloud;break;default:u=sideViewPoint2PointCloud;break}r=u(n,s,M);const C=H(r);return E(p,n,r,void 0,C,L),C}},tt=(n,s)=>{W(n,s,PointCloudView.Side)},ot=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},it=(n,s)=>{Z(n,s,PointCloudView.Back)},nt=(n,s)=>{O(n)},st=(n,s)=>{const p=G(n.id),u=topViewPoint2PointCloud(n,s,N,p),r=H(u);E(PointCloudView.Top,n,u,void 0,r,L)},rt=(n,s)=>{if(_){const u=n[0].newPolygon;u.pointList=u.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,s)),I(n[0].newPolygon);return}let p=n.map(({newPolygon:u})=>{const r=f(u.id),{boxParams:C}=topViewPolygon2PointCloud(u,s,e.pointCloudInstance,r);return C});if(p=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:L,action:"viewUpdateBox"})),p.length===1){const{newPolygon:u}=n[0],r=S(p);j({polygon:u,boxParams:p[0],newPointCloudBoxList:r})}else{const u=S(p);u&&o.syncAllViewPointCloudColor(u)}},lt=n=>{var s;if(w){const p=w==null?void 0:w.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(y=>(y==null?void 0:y.trackID)===p),C=__spreadProps(__spreadValues({},w.info),{width:Number(n.widthDefault),depth:Number(n.depthDefault),height:Number(n.heightDefault),valid:!0}),x=S([C]);j({omitView:PointCloudView["3D"],polygon:r,boxParams:C,newPointCloudBoxList:x})}},E=(n,s,p,u,r,C)=>__async(void 0,null,function*(){const x=T==null?void 0:T.url,y={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,i,x,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(p,s,l,x,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,e,t)}};Object.keys(y).forEach(v=>{v!==n&&y[v]()}),u&&(t==null||t.updateCameraZoom(u)),Y(p)}),j=n=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:u,zoom:r,newPointCloudBoxList:C}=n,x=T==null?void 0:T.url;C&&(yield o.syncAllViewPointCloudColor(C));const y={[PointCloudView.Side]:()=>{synchronizeSideView(u,p,i,x)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(u,p,l,x)},[PointCloudView.Top]:()=>{synchronizeTopView(u,p,e,t)}};Object.keys(y).forEach(v=>{v!==s&&y[v]()}),r&&(t==null||t.updateCameraZoom(r)),X(u)});return{topViewAddSphere:J,topViewAddBox:K,topViewSelectedChanged:$,topViewUpdatePoint:st,sideViewUpdatePoint:tt,backViewUpdatePoint:ot,topViewUpdateBox:rt,topViewUpdateLine:nt,sideViewUpdateBox:et,backViewUpdateBox:it,pointCloudBoxListUpdated:n=>{e.updatePolygonList(n),t==null||t.generateBoxes(n)},initPointCloud3d:n=>{if(!t)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=T){var p,u,r,C,x,y;if(!(s==null?void 0:s.url)||!t)return;z([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield t.loadPCDFile(s.url,(p=L==null?void 0:L.radius)!=null?p:DEFAULT_RADIUS),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],U=[],V=[],B=[];t.updateTopCamera();const R=(r=(u=index.jsonParser(s.result))==null?void 0:u.valid)!=null?r:!0;o.setPointCloudValid(R),(C=o.sideViewInstance)==null||C.clearAllData(),(x=o.backViewInstance)==null||x.clearAllData(),e.updateData(s.url,s.result,{radius:(y=L==null?void 0:L.radius)!=null?y:DEFAULT_RADIUS}),s.result&&(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),V=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),U=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(B),yield o.syncAllViewPointCloudColor(v,[])),D({pointCloudBoxList:v,polygonList:V,lineList:U,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:lt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
1
|
+
import{PointCloudContext as ee}from"./PointCloudContext.js";import{useRotate as te}from"./hooks/useRotate.js";import{useBoxes as oe}from"./hooks/useBoxes.js";import{useSingleBox as re}from"./hooks/useSingleBox.js";import{useSphere as ne}from"./hooks/useSphere.js";import{useContext as se,useEffect as c}from"react";import{EPointCloudName as ie,CommonToolUtils as ae,AttributeUtils as ue,EToolName as P,cTool as le}from"@labelbee/lb-annotation";import{message as S}from"antd";import{connect as de}from"react-redux";import{a2MapStateToProps as ce}from"../../store/annotation/map.js";import{useStatus as pe}from"./hooks/useStatus.js";import{usePointCloudViews as me}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as ve,useDispatch as be}from"../../store/ctx.js";import{useHistory as Pe}from"./hooks/useHistory.js";import{useAttribute as fe}from"./hooks/useAttribute.js";import{useConfig as ye}from"./hooks/useConfig.js";import{usePolygon as we}from"./hooks/usePolygon.js";import{useLine as Ce}from"./hooks/useLine.js";import{useTranslation as he}from"react-i18next";import{PreDataProcess as ge}from"../../store/annotation/actionCreators.js";var Se=Object.defineProperty,xe=Object.defineProperties,ke=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,I=(l,r,u)=>r in l?Se(l,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[r]=u,f=(l,r)=>{for(var u in r||(r={}))_e.call(r,u)&&I(l,u,r[u]);if(D)for(var u of D(r))Ve.call(r,u)&&I(l,u,r[u]);return l},y=(l,r)=>xe(l,ke(r));const{EPolygonPattern:Le}=le,Be=({currentData:l,config:r,checkMode:u,configString:E,imgIndex:x,toolInstanceRef:i})=>{const t=se(ee),{changeSelectedBoxValid:T,selectNextBox:N,selectPrevBox:H,updateSelectedBox:k,deleteSelectedPointCloudBoxAndPolygon:K}=re(),{selectedSphere:w,updatePointCloudSphere:U}=ne(),{clearAllResult:C,updatePointCloudPattern:z}=pe(),{copySelectedBoxes:F,pasteSelectedBoxes:q,copiedBoxes:G}=oe({config:r}),{updateRotate:h}=te({currentData:l}),{updatePointCloudData:v,topViewSelectedChanged:_}=me(),{redo:V,undo:L,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:R,pushHistoryUnderUpdateLine:W}=Pe(),Y=be(),{syncThreeViewsAttribute:B}=fe(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=ye(),{selectedPolygon:O}=we(),{selectedLine:j}=Ce(),{t:g}=he(),b=e=>{var o;const{topViewInstance:n}=t;!n||(o=n.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(e)},Q=(e,o)=>{var n,a;const{topViewInstance:d,mainViewInstance:s}=t;if(!d)return;const{pointCloud2dOperation:p}=d;switch(e){case"q":{h(2);break}case"e":h(-2);break;case"g":h(180);break;case"u":{const m=p.pattern===Le.Normal?P.Rect:P.Polygon;z(m);const Z={[P.Polygon]:g("PolygonPattern"),[P.Rect]:g("RectPattern")};S.success(g("ChangePatternMsg",{pattern:Z[m]})),p.clearActiveStatus(),p.clearDrawingStatus()}break;case"+":s==null||s.updatePointSize({zoomIn:!0});break;case"-":s==null||s.updatePointSize({zoomIn:!1});break;case"v":t.setPointCloudValid(!t.valid);break;case"tab":if(o.shiftKey){H();break}N(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":K();break;default:{if(((n=r.attributeList)==null?void 0:n.length)>0){const m=ue.getAttributeByKeycode(o.keyCode,r.attributeList);m!==void 0&&((a=i.current)==null||a.setDefaultAttribute(m))}return}}},X=(e,o)=>{switch(e){case"c":F();break;case"v":q();break;case"a":o.preventDefault(),t.selectedAllBoxes();break;case"z":{o.shiftKey?V():L();break}}},A=e=>{if(!ae.hotkeyFilter(e)||u===!0)return;const o=e.key.toLocaleLowerCase();if(e.ctrlKey){X(o,e);return}Q(o,e)};return c(()=>{const{topViewInstance:e}=t;if(!!e)return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}},[t,G,r,t.pointCloudBoxList,t.polygonList]),c(()=>{$(r)},[E]),c(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{v==null||v()},[x,t.mainViewInstance]),c(()=>{t.setHideAttributes([])},[x]),c(()=>{i.current.setDefaultAttribute=e=>{var o,n,a,d;B(e);const s=t.selectedPointCloudBox;if(s){s.attribute=e;const p=Y(ge({tool:ie.PointCloud,dataList:[s],stepConfig:r,action:"viewUpdateBox"}));s.valid=p[0].valid;const m=k(s);(a=(n=(o=t==null?void 0:t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:n.setPolygonValidAndRender)==null||a.call(n,s.id,!0,s.valid),t.mainViewInstance&&_({newSelectedBox:s,newPointCloudList:m})}if(O&&R(y(f({},O),{attribute:e})),j&&W(y(f({},j),{attribute:e})),w){const p=U(y(f({},w),{attribute:e}));t.mainViewInstance&&((d=t.mainViewInstance)==null||d.generateSpheres(p),_({newSelectedSphere:w,newSphereList:p}))}},i.current.setSubAttribute=(e,o)=>{var n;const a=t.selectedPointCloudBox;if(a){const d=(n=a==null?void 0:a.subAttribute)!=null?n:{};a.subAttribute=y(f({},d),{[e]:o}),k(a)}},i.current.clearResult=()=>{C==null||C()},i.current.redo=()=>{V()},i.current.undo=()=>{L()},i.current.setValid=e=>{i.current.valid=e,setTimeout(()=>{t.setPointCloudValid(e),e===!1&&C()})},i.current.setForbidOperation=e=>{var o,n;(n=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||n.setForbidOperation(e),e===!0&&t.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=e=>{var o,n;(n=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||n.setShowDefaultCursor(e)},i.current.asyncData=e=>{setTimeout(()=>{v==null||v(e)})}},[t.pointCloudBoxList,t.pointCloudSphereList,t.selectedID,t.valid,t.polygonList,t.lineList,t.mainViewInstance,t.ptSegmentInstance]),c(()=>{i.current.updateSegmentTool=e=>{var o;(o=t.ptSegmentInstance)==null||o.emit(e)},i.current.segmentInstance=t.ptSegmentInstance},[t.ptSegmentInstance]),c(()=>{i.current.history={pushHistory:e=>{M({pointCloudBoxList:e})},initRecord:()=>{}}},[]),c(()=>{var e;const o=(e=t.topViewInstance)==null?void 0:e.toolInstance;if(!o||u)return;const n=s=>{B(s)},a=s=>{S.error(s)},d=s=>{S.info(s)};return o.on("syncAttribute",n),o.on("messageError",a),o.on("messageInfo",d),()=>{o.unbind("syncAttribute",n),o.unbind("messageError",a),o.unbind("messageInfo",d)}},[t.topViewInstance]),null};var Oe=de(ce,null,null,{context:ve})(Be);export{Oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as J,MathUtils as B,getCuboidFromPointCloudBox as Rt}from"@labelbee/lb-annotation";import{EPerspectiveView as W,PointCloudUtils as I,DEFAULT_SPHERE_PARAMS as Nt}from"@labelbee/lb-utils";import{useContext as Et}from"react";import{PointCloudContext as Ht}from"../PointCloudContext.js";import{useSingleBox as lt}from"./useSingleBox.js";import{useSphere as Ft}from"./useSphere.js";import{useSelector as Zt,useDispatch as Wt}from"../../../store/ctx.js";import Mt from"../../../utils/StepUtils.js";import{jsonParser as dt}from"../../../utils/index.js";import{PreDataProcess as K,SetPointCloudLoading as at,SetLoadPCDFileLoading as ct}from"../../../store/annotation/actionCreators.js";import{message as Gt}from"antd";import{useTranslation as Qt}from"react-i18next";import{useHistory as Xt}from"./useHistory.js";import{usePolygon as Yt}from"./usePolygon.js";var qt=Object.defineProperty,Jt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,ut=Object.getOwnPropertySymbols,$t=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable,pt=(o,e,n)=>e in o?qt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,y=(o,e)=>{for(var n in e||(e={}))$t.call(e,n)&&pt(o,n,e[n]);if(ut)for(var n of ut(e))to.call(e,n)&&pt(o,n,e[n]);return o},k=(o,e)=>Jt(o,Kt(e)),$=(o,e,n)=>new Promise((l,t)=>{var d=u=>{try{a(n.next(u))}catch(C){t(C)}},f=u=>{try{a(n.throw(u))}catch(C){t(C)}},a=u=>u.done?l(u.value):Promise.resolve(u.value).then(d,f);a((n=n.apply(o,e)).next())});const Q=5,X=90,ft=.01,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},tt=(o,e,n,l,t)=>{const{x:d,y:f}=I.transferCanvas2World(o,e),{defaultZ:a}=Nt,u={center:{x:d,y:f,z:a},id:o.id},C=l?y(y({},l),u):k(y({},u),{attribute:"",valid:!0});return t&&Object.assign(C,t),C},ot=(o,e,n,l,t,d)=>{let f=o.pointList.map(h=>I.transferCanvas2World(h,e)),a=0,u=1,C={};if(n){const h=n.getSensesPointZAxisInPolygon(f,void 0,d);d&&h.fittedCoordinates.length>0&&(f=h.fittedCoordinates),a=(h.maxZ+h.minZ)/2,u=h.maxZ-h.minZ,C={count:h.zCount}}const[m,b,E]=f,V=B.getLineCenterPoint([m,E]),A=B.getLineLength(m,b),T=B.getLineLength(b,E),R=B.getRadiusFromQuadrangle(o.pointList);l&&(a=l.center.z,u=l.depth);const z={center:{x:V.x,y:V.y,z:a},width:d?T+ft:T,height:d?A+ft:A,depth:u,rotation:R,id:o.id},j=y(l?y(y({},l),z):k(y({},z),{attribute:"",valid:!0}),C);t&&Object.assign(j,t);const _=f.map(h=>I.transferWorld2Canvas(h,e));return{boxParams:j,newPointList:_}},gt=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x-l.x,y:n.center.y,z:n.center.z-l.y}})},Ct=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,C]=e.pointList,m=B.getLineCenterPoint([t,f]),b=B.getLineCenterPoint([a,C]),V={x:{x:m.x-b.x,y:m.y-b.y}.x,y:0,z:m.y-b.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,C),_=z-j,{newBoxParams:h}=l.getNewBoxBySideUpdate(V,_,R,n);return h},oo=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x,y:n.center.y-l.x,z:n.center.z-l.y}})},eo=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,C]=e.pointList,m=B.getLineCenterPoint([t,f]),b=B.getLineCenterPoint([a,C]),V={x:{x:m.x-b.x,y:m.y-b.y}.x,y:0,z:m.y-b.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,C),_=z-j;let{newBoxParams:h}=l.getNewBoxByBackUpdate(V,_,R,n);return h},Pt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Left);a.setInitCameraPosition(u);const{point2d:C,zoom:m}=a.getSphereSidePoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),C),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},mt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{width:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Left);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxSidePolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},xt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Back);a.setInitCameraPosition(u);const{point2d:C,zoom:m}=a.getSphereBackPoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),C),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},Lt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{height:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Back);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxBackPolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},yt=(o,e,n,l)=>{if(!n||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,W.Top),l.render();const{toolInstance:t,pointCloudInstance:d}=n,{point2d:f}=d.getSphereTopPoint2DCoordinate(o),a=[...t.pointList].map(u=>u.id===e.id?k(y(y({},e),f),{valid:o.valid,textAttribute:"",attribute:o.attribute}):u);t.setResult(a),t.setSelectedID(e.id)},et=(o,e,n,l)=>{var t,d;if(!n||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:f,pointCloudInstance:a}=n,{polygon2d:u}=a.getBoxTopPolygon2DCoordinate(o),C=[...f.polygonList],m=C.find(b=>b.id===e.id);m?(m.pointList=u,m.valid=(t=o.valid)!=null?t:!0):C.push({id:e.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=o.valid)!=null?d:!0}),f.setResultAndSelectedID(C,e.id)},no=()=>{const o=Et(Ht),{topViewInstance:e,sideViewInstance:n,backViewInstance:l,mainViewInstance:t,addPointCloudBox:d,addPointCloudSphere:f,setSelectedIDs:a,selectedIDs:u,pointCloudBoxList:C,pointCloudSphereList:m,hideAttributes:b,setHighlight2DDataList:E}=o,{addHistory:V,initHistory:A,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:R}=Xt(),{selectedPolygon:z}=Yt(),{updateSelectedBox:j,updateSelectedBoxes:_,getPointCloudByID:h}=lt(),{getPointCloudSphereByID:ht,updatePointCloudSphere:nt,selectedSphere:M}=Ft(),{currentData:H,config:w}=Zt(i=>{const{stepList:s,step:p,imgList:c,imgIndex:r}=i.annotation;return{currentData:c[r],config:dt(Mt.getCurrentStepInfo(p,s).config)}}),N=Wt(),{selectedBox:D}=lt(),{t:vt}=Qt(),it=D==null?void 0:D.info;if(!e||!n||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:Y}=e,Bt=i=>{t==null||t.generateBox(i),t==null||t.controls.update(),t==null||t.render()},wt=i=>{t==null||t.generateSphere(i),t==null||t.controls.update(),t==null||t.render()},bt=({newPoint:i,size:s,zoom:p,trackConfigurable:c})=>{var r;const g={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};c===!0&&Object.assign(g,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const P=tt(i,s,Y,void 0,g);a(i.id);const x=f(P);G(L.Top,i,P,p,x,w),V({newSphereParams:P})},St=({polygon:i,size:s,imgList:p,trackConfigurable:c,zoom:r,intelligentFit:g})=>{var P,x;const v={attribute:(P=e.toolInstance.defaultAttribute)!=null?P:""};c===!0&&Object.assign(v,{trackID:I.getNextTrackID({imgList:[],extraBoxList:C,extraSphereList:m})});const O=e==null?void 0:e.toolInstance,U=y({},i);let{boxParams:S,newPointList:Z}=ot(U,s,Y,void 0,v,g);if(S=N(K({tool:J.PointCloud,dataList:[S],stepConfig:w,action:"viewUpdateBox"}))[0],(w==null?void 0:w.lowerLimitPointsNumInBox)&&typeof S.count=="number"&&S.count<w.lowerLimitPointsNumInBox){Gt.info(vt("LowerLimitPointsNumInBox",{num:w.lowerLimitPointsNumInBox})),O.deletePolygon(S.id);return}g&&(Z==null?void 0:Z.length)&&(U.pointList=Z);const zt=b.includes(U.attribute),q=d(S),jt=(x=o==null?void 0:o.polygonList)!=null?x:[];e==null||e.updatePolygonList(q!=null?q:[],jt),zt?a([]):(a(S.id),O.selection.setSelectedIDs(U.id),F({omitView:L.Top,polygon:U,boxParams:S,zoom:r,newPointCloudBoxList:q}),g&&et(S,U,e,t)),V({newBoxParams:S})},It=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:p,newSphereList:c})=>{var r;const g=e==null?void 0:e.toolInstance;if(!(u.length===0||!g)){if(i||(D==null?void 0:D.info)){const P=i!=null?i:D==null?void 0:D.info;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(u[0]);const x=g.selectedPolygon;if(u.length===1&&P){F({omitView:L.Top,polygon:x,boxParams:P,newPointCloudBoxList:s});return}}if((p||M)&&u.length===1){const P=p!=null?p:M;g.setSelectedID(u[0]);const x=g.selectedPoint;P&&G(L.Top,x,P,void 0,c,w)}}},st=(i,s,p)=>{if(it){let c,r;switch(p){case L.Back:c=eo;break;case L.Side:c=Ct;break;default:c=Ct;break}r=c(i,s,it,n.pointCloudInstance);const P=N(K({tool:J.PointCloud,dataList:[r],stepConfig:w,action:"viewUpdateBox"}))[0],x=r.valid!==P.valid;if(r=P,t){const{count:O}=t.getSensesPointZAxisInPolygon(Rt(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=k(y({},r),{count:O})}const v=j(r);return r=v.find(O=>O.id===r.id),F({omitView:x?void 0:p,polygon:i,boxParams:r,newPointCloudBoxList:v}),v}},rt=(i,s,p)=>{if(M){let c,r;switch(p){case L.Back:c=oo;break;case L.Side:c=gt;break;default:c=gt;break}r=c(i,s,M);const g=nt(r);return G(p,i,r,void 0,g,w),g}},Dt=(i,s)=>{rt(i,s,L.Side)},Vt=(i,s)=>{rt(i,s,L.Back)},_t=(i,s)=>{st(i,s,L.Side)},Ot=(i,s)=>{st(i,s,L.Back)},Ut=(i,s)=>{R(i)},kt=(i,s)=>{const p=ht(i.id),c=tt(i,s,Y,p),r=nt(c);G(L.Top,i,c,void 0,r,w)},At=(i,s)=>{if(z){const c=i[0].newPolygon;c.pointList=c.pointList.map(r=>I.transferCanvas2World(r,s)),T(i[0].newPolygon);return}let p=i.map(({newPolygon:c})=>{const r=h(c.id),{boxParams:g}=ot(c,s,e.pointCloudInstance,r);return g});if(p=N(K({tool:J.PointCloud,dataList:p,stepConfig:w,action:"viewUpdateBox"})),p.length===1){const{newPolygon:c}=i[0],r=_(p);F({omitView:L.Top,polygon:c,boxParams:p[0],newPointCloudBoxList:r})}else{const c=_(p);c&&o.syncAllViewPointCloudColor(c)}},Tt=i=>{var s;if(D){const p=D==null?void 0:D.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(x=>(x==null?void 0:x.trackID)===p),g=k(y({},D.info),{width:Number(i.widthDefault),depth:Number(i.depthDefault),height:Number(i.heightDefault)}),P=_([g]);F({omitView:L["3D"],polygon:r,boxParams:g,newPointCloudBoxList:P})}},G=(i,s,p,c,r,g)=>$(void 0,null,function*(){const P=H==null?void 0:H.url,x={[L.Side]:()=>{Pt(p,s,n,P,g)},[L.Back]:()=>{l&&xt(p,s,l,P,g)},[L.Top]:()=>{yt(p,s,e,t)}};Object.keys(x).forEach(v=>{v!==i&&x[v]()}),c&&(t==null||t.updateCameraZoom(c)),wt(p)}),F=i=>$(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:c,zoom:r,newPointCloudBoxList:g}=i,P=H==null?void 0:H.url;g&&(yield o.syncAllViewPointCloudColor(g));const x={[L.Side]:()=>{mt(c,p,n,P)},[L.Back]:()=>{l&&Lt(c,p,l,P)},[L.Top]:()=>{et(c,p,e,t)}};Object.keys(x).forEach(v=>{v!==s&&x[v]()}),r&&(t==null||t.updateCameraZoom(r)),Bt(c)});return{topViewAddSphere:bt,topViewAddBox:St,topViewSelectedChanged:It,topViewUpdatePoint:kt,sideViewUpdatePoint:Dt,backViewUpdatePoint:Vt,topViewUpdateBox:At,topViewUpdateLine:Ut,sideViewUpdateBox:_t,backViewUpdateBox:Ot,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),t==null||t.generateBoxes(i)},initPointCloud3d:i=>{if(!t)return;const s=I.getDefaultOrthographicParams(i);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...i)=>$(void 0,[...i],function*(s=H){var p,c,r,g,P,x;if(!(s==null?void 0:s.url)||!t)return;E([]),at(N,!0),ct(N,!0),yield t.loadPCDFile(s.url,(p=w==null?void 0:w.radius)!=null?p:X),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],O=[],U=[],S=[];t.updateTopCamera();const Z=(r=(c=dt(s.result))==null?void 0:c.valid)!=null?r:!0;o.setPointCloudValid(Z),(g=o.sideViewInstance)==null||g.clearAllData(),(P=o.backViewInstance)==null||P.clearAllData(),e.updateData(s.url,s.result,{radius:(x=w==null?void 0:w.radius)!=null?x:X}),s.result&&(v=I.getBoxParamsFromResultList(s.result),U=I.getPolygonListFromResultList(s.result),O=I.getLineListFromResultList(s.result),S=I.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(S),yield o.syncAllViewPointCloudColor(v,[])),A({pointCloudBoxList:v,polygonList:U,lineList:O,pointCloudSphereList:S}),at(N,!1),ct(N,!1)}),updateViewsByDefaultSize:Tt}};export{xt as syncBackViewByPoint,Pt as syncSideViewByPoint,yt as syncTopViewByPoint,Lt as synchronizeBackView,mt as synchronizeSideView,et as synchronizeTopView,tt as topViewPoint2PointCloud,ot as topViewPolygon2PointCloud,no as usePointCloudViews};
|
|
1
|
+
import{EPointCloudName as J,MathUtils as B,getCuboidFromPointCloudBox as Rt}from"@labelbee/lb-annotation";import{EPerspectiveView as W,PointCloudUtils as I,DEFAULT_SPHERE_PARAMS as Nt}from"@labelbee/lb-utils";import{useContext as Et}from"react";import{PointCloudContext as Ht}from"../PointCloudContext.js";import{useSingleBox as lt}from"./useSingleBox.js";import{useSphere as Ft}from"./useSphere.js";import{useSelector as Zt,useDispatch as Wt}from"../../../store/ctx.js";import Mt from"../../../utils/StepUtils.js";import{jsonParser as dt}from"../../../utils/index.js";import{PreDataProcess as K,SetPointCloudLoading as at,SetLoadPCDFileLoading as ct}from"../../../store/annotation/actionCreators.js";import{message as Gt}from"antd";import{useTranslation as Qt}from"react-i18next";import{useHistory as Xt}from"./useHistory.js";import{usePolygon as Yt}from"./usePolygon.js";var qt=Object.defineProperty,Jt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,ut=Object.getOwnPropertySymbols,$t=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable,pt=(o,e,n)=>e in o?qt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,y=(o,e)=>{for(var n in e||(e={}))$t.call(e,n)&&pt(o,n,e[n]);if(ut)for(var n of ut(e))to.call(e,n)&&pt(o,n,e[n]);return o},k=(o,e)=>Jt(o,Kt(e)),$=(o,e,n)=>new Promise((l,t)=>{var d=u=>{try{a(n.next(u))}catch(C){t(C)}},f=u=>{try{a(n.throw(u))}catch(C){t(C)}},a=u=>u.done?l(u.value):Promise.resolve(u.value).then(d,f);a((n=n.apply(o,e)).next())});const Q=5,X=90,ft=.01,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},tt=(o,e,n,l,t)=>{const{x:d,y:f}=I.transferCanvas2World(o,e),{defaultZ:a}=Nt,u={center:{x:d,y:f,z:a},id:o.id},C=l?y(y({},l),u):k(y({},u),{attribute:"",valid:!0});return t&&Object.assign(C,t),C},ot=(o,e,n,l,t,d)=>{let f=o.pointList.map(h=>I.transferCanvas2World(h,e)),a=0,u=1,C={};if(n){const h=n.getSensesPointZAxisInPolygon(f,void 0,d);d&&h.fittedCoordinates.length>0&&(f=h.fittedCoordinates),a=(h.maxZ+h.minZ)/2,u=h.maxZ-h.minZ,C={count:h.zCount}}const[m,w,E]=f,V=B.getLineCenterPoint([m,E]),A=B.getLineLength(m,w),T=B.getLineLength(w,E),R=B.getRadiusFromQuadrangle(o.pointList);l&&(a=l.center.z,u=l.depth);const z={center:{x:V.x,y:V.y,z:a},width:d?T+ft:T,height:d?A+ft:A,depth:u,rotation:R,id:o.id},j=y(l?y(y({},l),z):k(y({},z),{attribute:"",valid:!0}),C);t&&Object.assign(j,t);const _=f.map(h=>I.transferWorld2Canvas(h,e));return{boxParams:j,newPointList:_}},gt=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x-l.x,y:n.center.y,z:n.center.z-l.y}})},Ct=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,C]=e.pointList,m=B.getLineCenterPoint([t,f]),w=B.getLineCenterPoint([a,C]),V={x:{x:m.x-w.x,y:m.y-w.y}.x,y:0,z:m.y-w.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,C),_=z-j,{newBoxParams:h}=l.getNewBoxBySideUpdate(V,_,R,n);return h},oo=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x,y:n.center.y-l.x,z:n.center.z-l.y}})},eo=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,C]=e.pointList,m=B.getLineCenterPoint([t,f]),w=B.getLineCenterPoint([a,C]),V={x:{x:m.x-w.x,y:m.y-w.y}.x,y:0,z:m.y-w.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,C),_=z-j;let{newBoxParams:h}=l.getNewBoxByBackUpdate(V,_,R,n);return h},Pt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Left);a.setInitCameraPosition(u);const{point2d:C,zoom:m}=a.getSphereSidePoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),C),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},mt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{width:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Left);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxSidePolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},xt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Back);a.setInitCameraPosition(u);const{point2d:C,zoom:m}=a.getSphereBackPoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),C),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},Lt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{height:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Back);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxBackPolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},yt=(o,e,n,l)=>{if(!n||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,W.Top),l.render();const{toolInstance:t,pointCloudInstance:d}=n,{point2d:f}=d.getSphereTopPoint2DCoordinate(o),a=[...t.pointList].map(u=>u.id===e.id?k(y(y({},e),f),{valid:o.valid,textAttribute:"",attribute:o.attribute}):u);t.setResult(a),t.setSelectedID(e.id)},et=(o,e,n,l)=>{var t,d;if(!n||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:f,pointCloudInstance:a}=n,{polygon2d:u}=a.getBoxTopPolygon2DCoordinate(o),C=[...f.polygonList],m=C.find(w=>w.id===e.id);m?(m.pointList=u,m.valid=(t=o.valid)!=null?t:!0):C.push({id:e.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=o.valid)!=null?d:!0}),f.setResultAndSelectedID(C,e.id)},no=()=>{const o=Et(Ht),{topViewInstance:e,sideViewInstance:n,backViewInstance:l,mainViewInstance:t,addPointCloudBox:d,addPointCloudSphere:f,setSelectedIDs:a,selectedIDs:u,pointCloudBoxList:C,pointCloudSphereList:m,hideAttributes:w,setHighlight2DDataList:E}=o,{addHistory:V,initHistory:A,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:R}=Xt(),{selectedPolygon:z}=Yt(),{updateSelectedBox:j,updateSelectedBoxes:_,getPointCloudByID:h}=lt(),{getPointCloudSphereByID:ht,updatePointCloudSphere:nt,selectedSphere:M}=Ft(),{currentData:H,config:b}=Zt(i=>{const{stepList:s,step:p,imgList:c,imgIndex:r}=i.annotation;return{currentData:c[r],config:dt(Mt.getCurrentStepInfo(p,s).config)}}),N=Wt(),{selectedBox:D}=lt(),{t:vt}=Qt(),it=D==null?void 0:D.info;if(!e||!n||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:Y}=e,Bt=i=>{t==null||t.generateBox(i),t==null||t.controls.update(),t==null||t.render()},bt=i=>{t==null||t.generateSphere(i),t==null||t.controls.update(),t==null||t.render()},wt=({newPoint:i,size:s,zoom:p,trackConfigurable:c})=>{var r;const g={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};c===!0&&Object.assign(g,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const P=tt(i,s,Y,void 0,g);a(i.id);const x=f(P);G(L.Top,i,P,p,x,b),V({newSphereParams:P})},St=({polygon:i,size:s,imgList:p,trackConfigurable:c,zoom:r,intelligentFit:g})=>{var P,x;const v={attribute:(P=e.toolInstance.defaultAttribute)!=null?P:""};c===!0&&Object.assign(v,{trackID:I.getNextTrackID({imgList:[],extraBoxList:C,extraSphereList:m})});const O=e==null?void 0:e.toolInstance,U=y({},i);let{boxParams:S,newPointList:Z}=ot(U,s,Y,void 0,v,g);if(S=N(K({tool:J.PointCloud,dataList:[S],stepConfig:b,action:"viewUpdateBox"}))[0],(b==null?void 0:b.lowerLimitPointsNumInBox)&&typeof S.count=="number"&&S.count<b.lowerLimitPointsNumInBox){Gt.info(vt("LowerLimitPointsNumInBox",{num:b.lowerLimitPointsNumInBox})),O.deletePolygon(S.id);return}g&&(Z==null?void 0:Z.length)&&(U.pointList=Z);const zt=w.includes(U.attribute),q=d(S),jt=(x=o==null?void 0:o.polygonList)!=null?x:[];e==null||e.updatePolygonList(q!=null?q:[],jt),zt?a([]):(a(S.id),O.selection.setSelectedIDs(U.id),F({omitView:L.Top,polygon:U,boxParams:S,zoom:r,newPointCloudBoxList:q}),g&&et(S,U,e,t)),V({newBoxParams:S})},It=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:p,newSphereList:c})=>{var r;const g=e==null?void 0:e.toolInstance;if(!(u.length===0||!g)){if(i||(D==null?void 0:D.info)){const P=i!=null?i:D==null?void 0:D.info;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(u[0]);const x=g.selectedPolygon;if(u.length===1&&P){F({omitView:L.Top,polygon:x,boxParams:P,newPointCloudBoxList:s});return}}if((p||M)&&u.length===1){const P=p!=null?p:M;g.setSelectedID(u[0]);const x=g.selectedPoint;P&&G(L.Top,x,P,void 0,c,b)}}},st=(i,s,p)=>{if(it){let c,r;switch(p){case L.Back:c=eo;break;case L.Side:c=Ct;break;default:c=Ct;break}r=c(i,s,it,n.pointCloudInstance);const P=N(K({tool:J.PointCloud,dataList:[r],stepConfig:b,action:"viewUpdateBox"}))[0],x=r.valid!==P.valid;if(r=P,t){const{count:O}=t.getSensesPointZAxisInPolygon(Rt(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=k(y({},r),{count:O})}const v=j(r);return r=v.find(O=>O.id===r.id),F({omitView:x?void 0:p,polygon:i,boxParams:r,newPointCloudBoxList:v}),v}},rt=(i,s,p)=>{if(M){let c,r;switch(p){case L.Back:c=oo;break;case L.Side:c=gt;break;default:c=gt;break}r=c(i,s,M);const g=nt(r);return G(p,i,r,void 0,g,b),g}},Dt=(i,s)=>{rt(i,s,L.Side)},Vt=(i,s)=>{rt(i,s,L.Back)},_t=(i,s)=>{st(i,s,L.Side)},Ot=(i,s)=>{st(i,s,L.Back)},Ut=(i,s)=>{R(i)},kt=(i,s)=>{const p=ht(i.id),c=tt(i,s,Y,p),r=nt(c);G(L.Top,i,c,void 0,r,b)},At=(i,s)=>{if(z){const c=i[0].newPolygon;c.pointList=c.pointList.map(r=>I.transferCanvas2World(r,s)),T(i[0].newPolygon);return}let p=i.map(({newPolygon:c})=>{const r=h(c.id),{boxParams:g}=ot(c,s,e.pointCloudInstance,r);return g});if(p=N(K({tool:J.PointCloud,dataList:p,stepConfig:b,action:"viewUpdateBox"})),p.length===1){const{newPolygon:c}=i[0],r=_(p);F({polygon:c,boxParams:p[0],newPointCloudBoxList:r})}else{const c=_(p);c&&o.syncAllViewPointCloudColor(c)}},Tt=i=>{var s;if(D){const p=D==null?void 0:D.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(x=>(x==null?void 0:x.trackID)===p),g=k(y({},D.info),{width:Number(i.widthDefault),depth:Number(i.depthDefault),height:Number(i.heightDefault),valid:!0}),P=_([g]);F({omitView:L["3D"],polygon:r,boxParams:g,newPointCloudBoxList:P})}},G=(i,s,p,c,r,g)=>$(void 0,null,function*(){const P=H==null?void 0:H.url,x={[L.Side]:()=>{Pt(p,s,n,P,g)},[L.Back]:()=>{l&&xt(p,s,l,P,g)},[L.Top]:()=>{yt(p,s,e,t)}};Object.keys(x).forEach(v=>{v!==i&&x[v]()}),c&&(t==null||t.updateCameraZoom(c)),bt(p)}),F=i=>$(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:c,zoom:r,newPointCloudBoxList:g}=i,P=H==null?void 0:H.url;g&&(yield o.syncAllViewPointCloudColor(g));const x={[L.Side]:()=>{mt(c,p,n,P)},[L.Back]:()=>{l&&Lt(c,p,l,P)},[L.Top]:()=>{et(c,p,e,t)}};Object.keys(x).forEach(v=>{v!==s&&x[v]()}),r&&(t==null||t.updateCameraZoom(r)),Bt(c)});return{topViewAddSphere:wt,topViewAddBox:St,topViewSelectedChanged:It,topViewUpdatePoint:kt,sideViewUpdatePoint:Dt,backViewUpdatePoint:Vt,topViewUpdateBox:At,topViewUpdateLine:Ut,sideViewUpdateBox:_t,backViewUpdateBox:Ot,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),t==null||t.generateBoxes(i)},initPointCloud3d:i=>{if(!t)return;const s=I.getDefaultOrthographicParams(i);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...i)=>$(void 0,[...i],function*(s=H){var p,c,r,g,P,x;if(!(s==null?void 0:s.url)||!t)return;E([]),at(N,!0),ct(N,!0),yield t.loadPCDFile(s.url,(p=b==null?void 0:b.radius)!=null?p:X),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],O=[],U=[],S=[];t.updateTopCamera();const Z=(r=(c=dt(s.result))==null?void 0:c.valid)!=null?r:!0;o.setPointCloudValid(Z),(g=o.sideViewInstance)==null||g.clearAllData(),(P=o.backViewInstance)==null||P.clearAllData(),e.updateData(s.url,s.result,{radius:(x=b==null?void 0:b.radius)!=null?x:X}),s.result&&(v=I.getBoxParamsFromResultList(s.result),U=I.getPolygonListFromResultList(s.result),O=I.getLineListFromResultList(s.result),S=I.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(S),yield o.syncAllViewPointCloudColor(v,[])),A({pointCloudBoxList:v,polygonList:U,lineList:O,pointCloudSphereList:S}),at(N,!1),ct(N,!1)}),updateViewsByDefaultSize:Tt}};export{xt as syncBackViewByPoint,Pt as syncSideViewByPoint,yt as syncTopViewByPoint,Lt as synchronizeBackView,mt as synchronizeSideView,et as synchronizeTopView,tt as topViewPoint2PointCloud,ot as topViewPolygon2PointCloud,no as usePointCloudViews};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.14.0-alpha.
|
|
3
|
+
"version": "1.14.0-alpha.9",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.18.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.18.0-alpha.7",
|
|
47
47
|
"@labelbee/lb-utils": "1.10.0-alpha.4",
|
|
48
48
|
"ahooks": "^3.4.0",
|
|
49
49
|
"classnames": "^2.3.0",
|