@labelbee/lb-components 1.23.0-alpha.28 → 1.23.0-alpha.29
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/audioPlayer/useAudioSegment/index.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/audioPlayer/useAudioSegment/index.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var React=require("react"),antd=require("antd"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("../../audioAnnotate/audioContext/index.js"),ahooks=require("ahooks"),dataTransform=require("../../audioAnnotate/utils/dataTransform.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,e,t)=>e in r?__defProp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,__spreadValues=(r,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(r,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(r,t,e[t]);return r},__spreadProps=(r,e)=>__defProps(r,__getOwnPropDescs(e));const EKeyCode=lbAnnotation.cKeyCode.default,useAudioSegment=r=>{const{waveRef:e,regionMap:t,updateRegion:d,removeRegion:y,generateRegions:
|
|
1
|
+
"use strict";var React=require("react"),antd=require("antd"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("../../audioAnnotate/audioContext/index.js"),ahooks=require("ahooks"),dataTransform=require("../../audioAnnotate/utils/dataTransform.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,e,t)=>e in r?__defProp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,__spreadValues=(r,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(r,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(r,t,e[t]);return r},__spreadProps=(r,e)=>__defProps(r,__getOwnPropDescs(e));const EKeyCode=lbAnnotation.cKeyCode.default,useAudioSegment=r=>{const{waveRef:e,regionMap:t,updateRegion:d,removeRegion:y,generateRegions:R,setSelectedRegion:w}=r,{audioClipState:O,setAudioClipState:v}=index.useAudioClipStore(),{selectedRegion:P,clipConfigurable:T,segment:p,clipTextList:C,subAttributeList:A,secondaryAttributeConfigurable:E=!1}=O,{id:n}=P,m=React.useRef(null),g=React.useRef(null);React.useEffect(()=>{var u,o,i,l,c,s,f;if(g.current&&e.current&&p&&n){const a=(s=(i=(o=(u=e.current)==null?void 0:u.regions)==null?void 0:o.util)==null?void 0:i.getRegionSnapToGridValue)==null?void 0:s.call(i,((l=e.current)==null?void 0:l.drawer.handleEvent(g.current))*((c=e.current)==null?void 0:c.getDuration())),_=(f=t[n])!=null?f:{},{start:b,end:B}=_;if(a>b&&a<B){m.current=a;return}}m.current=null},[g.current,p]);const x=ahooks.useMemoizedFn((u,o)=>{var i,l,c;if(!n||n!==u.id){antd.message.info("\u8BF7\u70B9\u51FB\u6240\u9009\u533A\u95F4");return}const s=t[n],f=dataTransform.getClipTextByConfig(s,C),a=__spreadProps(__spreadValues({},f),{id:(i=e.current)==null?void 0:i.util.getId("segment_"),end:o,subAttribute:(l=s.subAttribute)!=null?l:{}}),_=dataTransform.getClipTextByConfig(s,C,!0),b=__spreadProps(__spreadValues({},_),{id:(c=e.current)==null?void 0:c.util.getId("segment_"),start:o,subAttribute:lbAnnotation.TagUtils.getDefaultResultByConfig(E?A!=null?A:[]:[])});d==null||d(a),d==null||d(b),y==null||y(n),R(),v({segment:!1}),w({id:a.id,playImmediately:!0})}),F=ahooks.useMemoizedFn(u=>{if(!!T&&u.altKey&&u.keyCode===EKeyCode.X){if(!n){antd.message.info("\u8BF7\u5148\u9009\u62E9\u9700\u8981\u5206\u5272\u7684\u533A\u95F4");return}v({segment:!0,combined:!1})}}),S=ahooks.useMemoizedFn((u,o)=>{g.current=o});return ahooks.useEventListener("keydown",F),React.useEffect(()=>{p&&v({segment:!1})},[n]),{segmentInstance:x,onRegionMouseMove:S,segmentTimeTip:m.current}};module.exports=useAudioSegment;
|
|
@@ -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"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,r)=>new Promise((a,o)=>{var c=p=>{try{u(r.next(p))}catch(f){o(f)}},P=p=>{try{u(r.throw(p))}catch(f){o(f)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,P);u((r=r.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,r,a,o)=>{const{x:c,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:u}=lbUtils.DEFAULT_SPHERE_PARAMS,p={center:{x:c,y:P,z:u},id:e.id},f=a?__spreadValues(__spreadValues({},a),p):__spreadProps(__spreadValues({},p),{attribute:"",valid:!0});return o&&Object.assign(f,o),f},topViewPolygon2PointCloud=(e,t,r,a,o,c)=>{let P=e.pointList.map(L=>lbUtils.PointCloudUtils.transferCanvas2World(L,t)),u=0,p=1,f={};if(r){const L=r.getSensesPointZAxisInPolygon(P,void 0,c);c&&L.fittedCoordinates.length>0&&(P=L.fittedCoordinates),u=(L.maxZ+L.minZ)/2,p=L.maxZ-L.minZ,f={count:L.zCount}}const[x,B,z]=P,U=lbAnnotation.MathUtils.getLineCenterPoint([x,z]),V=lbAnnotation.MathUtils.getLineLength(x,B),I=lbAnnotation.MathUtils.getLineLength(B,z),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const _={center:{x:U.x,y:U.y,z:u},width:c?I+INTELLIGENT_FIT_MARGIN:I,height:c?V+INTELLIGENT_FIT_MARGIN:V,depth:p,rotation:k,id:e.id},O=__spreadValues(a?__spreadValues(__spreadValues({},a),_):__spreadProps(__spreadValues({},_),{attribute:"",valid:!0}),f);o&&Object.assign(O,o);const R=P.map(L=>lbUtils.PointCloudUtils.transferWorld2Canvas(L,t));return{boxParams:O,newPointList:R}},sideViewPoint2PointCloud=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},r),{center:{x:r.center.x-a.x,y:r.center.y,z:r.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,r,a)=>{const[o,c,P]=e.pointList,[u,p,f]=t.pointList,x=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([u,f]),U={x:{x:x.x-B.x,y:x.y-B.y}.x,y:0,z:x.y-B.y},V=lbAnnotation.MathUtils.getLineLength(o,c),I=lbAnnotation.MathUtils.getLineLength(u,p),k=V-I,_=lbAnnotation.MathUtils.getLineLength(c,P),O=lbAnnotation.MathUtils.getLineLength(p,f),R=_-O,{newBoxParams:L}=a.getNewBoxBySideUpdate(U,R,k,r);return L},backViewPoint2PointCloud=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},r),{center:{x:r.center.x,y:r.center.y-a.x,z:r.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,r,a)=>{const[o,c,P]=e.pointList,[u,p,f]=t.pointList,x=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([u,f]),U={x:{x:x.x-B.x,y:x.y-B.y}.x,y:0,z:x.y-B.y},V=lbAnnotation.MathUtils.getLineLength(o,c),I=lbAnnotation.MathUtils.getLineLength(u,p),k=V-I,_=lbAnnotation.MathUtils.getLineLength(c,P),O=lbAnnotation.MathUtils.getLineLength(p,f),R=_-O;let{newBoxParams:L}=a.getNewBoxByBackUpdate(U,R,k,r);return L},syncSideViewByPoint=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:P,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(p);const{point2d:f,zoom:x}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(x),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=c.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(P);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:P,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(p);const{point2d:f,zoom:x}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(x),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=c.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(P);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,r,a)=>{if(!r||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=r,{point2d:P}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},synchronizeTopView=(e,t,r,a)=>{var o,c;if(!r||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:u}=r,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),f=[...P.polygonList],x=f.find(B=>B.id===t.id);x?(x.pointList=p,x.valid=(o=e.valid)!=null?o:!0):f.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),P.setResultAndSelectedID(f,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:r,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:P,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:f,pointCloudSphereList:x,hideAttributes:B,setHighlight2DDataList:z,cuboidBoxIn2DView:U,imageSizes:V}=e,{addHistory:I,initHistory:k,pushHistoryUnderUpdatePolygon:_}=useHistory.useHistory(),{selectedPolygon:O}=usePolygon.usePolygon(),{getPointCloudSphereByID:R,updatePointCloudSphere:L,selectedSphere:N}=useSphere.useSphere(),{currentData:T,config:w}=ctx.useSelector(i=>{const{stepList:n,step:d,imgList:s,imgIndex:l}=i.annotation;return{currentData:s[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,n).config)}}),A=ctx.useDispatch(),tt=ahooks.useLatest(U),W=i=>{if(!tt.current){const{mappingImgList:n=[]}=T,d=n.map(s=>index.getRectPointCloudBox({pointCloudBox:i,mappingData:s,imageSizes:V}));Object.assign(i,{rects:d.filter(s=>s!==void 0)})}},{selectedBox:b,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),Q=b==null?void 0:b.info;if(!t||!r||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},nt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:i,size:n,zoom:d,trackConfigurable:s})=>{var l;const C={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};s===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:x})});const h=topViewPoint2PointCloud(i,n,G,void 0,C);u(i.id);const g=P(h);q(PointCloudView.Top,i,h,d,g,w),I({newSphereParams:h})},rt=({polygon:i,size:n,imgList:d,trackConfigurable:s,zoom:l,intelligentFit:C})=>{var h,g;const v={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};s===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:x})});const S=t==null?void 0:t.toolInstance,D=__spreadValues({},i);let{boxParams:y,newPointList:m}=topViewPolygon2PointCloud(D,n,G,void 0,v,C);y=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[y],stepConfig:w,action:"viewUpdateBox"}))[0],C&&(m==null?void 0:m.length)&&(D.pointList=m);const F=B.includes(D.attribute);W(y);const E=c(y),J=(g=e==null?void 0:e.polygonList)!=null?g:[];t==null||t.updatePolygonList(E!=null?E:[],J),F?u([]):(u(y.id),S.selection.setSelectedIDs(D.id),j({omitView:PointCloudView.Top,polygon:D,boxParams:y,zoom:l,newPointCloudBoxList:E}),C&&synchronizeTopView(y,D,t,o)),I({newBoxParams:y})},lt=i=>{const{boxID:n,imageName:d,width:s,height:l,x:C,y:h}=i,g=f.find(m=>m.id===n);if(!(g==null?void 0:g.rects)||!g.rects.find(m=>m.imageName===d))return;const S=g.rects.map(m=>m.imageName===d?__spreadProps(__spreadValues({},m),{width:s,height:l,x:C,y:h}):m),D=__spreadProps(__spreadValues({},g),{rects:S}),y=f.map(m=>m.id===n?D:m);return t==null||t.updatePolygonList(y!=null?y:[]),y},dt=i=>{const{boxID:n,imageName:d}=i,s=f.find(g=>g.id===n);if(!(s==null?void 0:s.rects))return;const l=s.rects.filter(g=>g.imageName!==d),C=__spreadProps(__spreadValues({},s),{rects:l}),h=f.map(g=>g.id===n?C:g);return t==null||t.updatePolygonList(h!=null?h:[]),h},at=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:s})=>{var l;const C=t==null?void 0:t.toolInstance;if(!(p.length===0||!C)){if(i||(b==null?void 0:b.info)){const h=i!=null?i:b==null?void 0:b.info;(l=C==null?void 0:C.selection)==null||l.setSelectedIDs(p[0]);const g=C.selectedPolygon;if(p.length===1&&h){j({omitView:PointCloudView.Top,polygon:g,boxParams:h,newPointCloudBoxList:n});return}}if((d||N)&&p.length===1){const h=d!=null?d:N;C.setSelectedID(p[0]);const g=C.selectedPoint;h&&q(PointCloudView.Top,g,h,void 0,s,w)}}},X=(i,n,d)=>{if(Q){let s,l;switch(d){case PointCloudView.Back:s=backViewPolygon2PointCloud;break;case PointCloudView.Side:s=sideViewPolygon2PointCloud;break;default:s=sideViewPolygon2PointCloud;break}if(l=s(i,n,Q,r.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:S})}const h=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:w,action:"viewUpdateBox"}))[0],g=l.valid!==h.valid;l=h;const v=ot(l);return l=v.find(S=>S.id===l.id),j({omitView:g?void 0:d,polygon:i,boxParams:l,newPointCloudBoxList:v}),v}},Y=(i,n,d)=>{if(N){let s,l;switch(d){case PointCloudView.Back:s=backViewPoint2PointCloud;break;case PointCloudView.Side:s=sideViewPoint2PointCloud;break;default:s=sideViewPoint2PointCloud;break}l=s(i,n,N);const C=L(l);return q(d,i,l,void 0,C,w),C}},ct=(i,n)=>{Y(i,n,PointCloudView.Side)},ut=(i,n)=>{Y(i,n,PointCloudView.Back)},pt=(i,n)=>{X(i,n,PointCloudView.Side)},Pt=(i,n)=>{X(i,n,PointCloudView.Back)},Ct=(i,n)=>{const d=R(i.id),s=topViewPoint2PointCloud(i,n,G,d),l=L(s);q(PointCloudView.Top,i,s,void 0,l,w)},gt=(i,n)=>{if(O){const s=__spreadValues({},i[0].newPolygon);s.pointList=s.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,n)),_(s);return}let d=i.map(({newPolygon:s})=>{const l=et(s.id),{boxParams:C}=topViewPolygon2PointCloud(s,n,t.pointCloudInstance,l);return C});if(d=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:w,action:"viewUpdateBox"})),d.length===1){const{newPolygon:s}=i[0],l=Z(d);j({polygon:s,boxParams:d[0],newPointCloudBoxList:l})}else{const s=Z(d);s&&e.syncAllViewPointCloudColor(s)}},ht=i=>{var n,d,s,l,C;if(b){const h=Number(i.widthDefault),g=Number(i.depthDefault),v=Number(i.heightDefault),S=b==null?void 0:b.info.trackID,y=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(H=>(H==null?void 0:H.trackID)===S),m={width:(s=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:s.width,height:(C=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:C.height},M=y.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,m)),F=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(M,v,h),E=F[0],J=F[2],K=lbAnnotation.MathUtils.getLineCenterPoint([E,J]),ft=b.info.center.z-b.info.depth/2,$=__spreadProps(__spreadValues({},b.info),{center:{x:K.x,y:K.y,z:ft+g/2},width:h,height:v,depth:g,valid:!0}),vt=Z([$]);j({omitView:PointCloudView["3D"],polygon:y,boxParams:$,newPointCloudBoxList:vt})}},q=(i,n,d,s,l,C)=>__async(void 0,null,function*(){const h=T==null?void 0:T.url,g={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,n,r,h,C)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(d,n,a,h,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,n,t,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),s&&(o==null||o.updateCameraZoom(s)),nt(d)}),j=i=>__async(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:s,zoom:l,newPointCloudBoxList:C}=i,h=T==null?void 0:T.url;C&&(yield e.syncAllViewPointCloudColor(C));const g={[PointCloudView.Side]:()=>{synchronizeSideView(s,d,r,h)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(s,d,a,h)},[PointCloudView.Top]:()=>{synchronizeTopView(s,d,t,o)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),l&&(o==null||o.updateCameraZoom(l)),it(s)});return{topViewAddSphere:st,topViewAddBox:rt,topViewSelectedChanged:at,topViewUpdatePoint:Ct,sideViewUpdatePoint:ct,backViewUpdatePoint:ut,topViewUpdateBox:gt,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=lbUtils.PointCloudUtils.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(n=T){var d,s,l,C,h,g;if(!(n==null?void 0:n.url)||!o)return;z([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(n.url,(d=w==null?void 0:w.radius)!=null?d:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],S=[],D=[],y=[];o.updateTopCamera();const m=(l=(s=index.jsonParser(n.result))==null?void 0:s.valid)!=null?l:!0;if(e.setPointCloudValid(m),(C=e.sideViewInstance)==null||C.clearAllData(),(h=e.backViewInstance)==null||h.clearAllData(),n.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),(v==null?void 0:v.length)>0&&n.isPreResult&&(w==null?void 0:w.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(n.url,w,v);const M=index.jsonParser(n.result);M[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,n.result=JSON.stringify(M),e.setPointCloudResult(v)}D=lbUtils.PointCloudUtils.getPolygonListFromResultList(n.result),S=lbUtils.PointCloudUtils.getLineListFromResultList(n.result),y=lbUtils.PointCloudUtils.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(g=w==null?void 0:w.radius)!=null?g:DEFAULT_RADIUS}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(v,[])}k({pointCloudBoxList:v,polygonList:D,lineList:S,pointCloudSphereList:y}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:ht,generateRects:W,update2DViewRect:lt,remove2DViewRect:dt}};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"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,l)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,__spreadValues=(e,t)=>{for(var l in t||(t={}))__hasOwnProp.call(t,l)&&__defNormalProp(e,l,t[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(t))__propIsEnum.call(t,l)&&__defNormalProp(e,l,t[l]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,l)=>new Promise((a,o)=>{var c=p=>{try{u(l.next(p))}catch(h){o(h)}},P=p=>{try{u(l.throw(p))}catch(h){o(h)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,P);u((l=l.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,l,a,o)=>{const{x:c,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:u}=lbUtils.DEFAULT_SPHERE_PARAMS,p={center:{x:c,y:P,z:u},id:e.id},h=a?__spreadValues(__spreadValues({},a),p):__spreadProps(__spreadValues({},p),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,l,a,o,c)=>{let P=e.pointList.map(L=>lbUtils.PointCloudUtils.transferCanvas2World(L,t)),u=0,p=1,h={};if(l){const L=l.getSensesPointZAxisInPolygon(P,void 0,c);c&&L.fittedCoordinates.length>0&&(P=L.fittedCoordinates),u=(L.maxZ+L.minZ)/2,p=L.maxZ-L.minZ,h={count:L.zCount}}const[y,w,T]=P,U=lbAnnotation.MathUtils.getLineCenterPoint([y,T]),I=lbAnnotation.MathUtils.getLineLength(y,w),D=lbAnnotation.MathUtils.getLineLength(w,T),R=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const V={center:{x:U.x,y:U.y,z:u},width:c?D+INTELLIGENT_FIT_MARGIN:D,height:c?I+INTELLIGENT_FIT_MARGIN:I,depth:p,rotation:R,id:e.id},_=__spreadValues(a?__spreadValues(__spreadValues({},a),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);o&&Object.assign(_,o);const k=P.map(L=>lbUtils.PointCloudUtils.transferWorld2Canvas(L,t));return{boxParams:_,newPointList:k}},sideViewPoint2PointCloud=(e,t,l)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},l),{center:{x:l.center.x-a.x,y:l.center.y,z:l.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,l,a)=>{const[o,c,P]=e.pointList,[u,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),w=lbAnnotation.MathUtils.getLineCenterPoint([u,h]),U={x:{x:y.x-w.x,y:y.y-w.y}.x,y:0,z:y.y-w.y},I=lbAnnotation.MathUtils.getLineLength(o,c),D=lbAnnotation.MathUtils.getLineLength(u,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(c,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_,{newBoxParams:L}=a.getNewBoxBySideUpdate(U,k,R,l);return L},backViewPoint2PointCloud=(e,t,l)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},l),{center:{x:l.center.x,y:l.center.y-a.x,z:l.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,l,a)=>{const[o,c,P]=e.pointList,[u,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),w=lbAnnotation.MathUtils.getLineCenterPoint([u,h]),U={x:{x:y.x-w.x,y:y.y-w.y}.x,y:0,z:y.y-w.y},I=lbAnnotation.MathUtils.getLineLength(o,c),D=lbAnnotation.MathUtils.getLineLength(u,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(c,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_;let{newBoxParams:L}=a.getNewBoxByBackUpdate(U,k,R,l);return L},syncSideViewByPoint=(e,t,l,a,o)=>{var c;if(!l)return;const{toolInstance:P,pointCloudInstance:u}=l;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(p);const{point2d:h,zoom:y}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=y,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,l,a)=>{if(!l)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=l;c.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=c.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(P);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,l,a,o)=>{var c;if(!l)return;const{toolInstance:P,pointCloudInstance:u}=l;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(p);const{point2d:h,zoom:y}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=y,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,l,a)=>{if(!l)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=l;c.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=c.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(P);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,l,a)=>{if(!l||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=l,{point2d:P}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},synchronizeTopView=(e,t,l,a)=>{var o,c;if(!l||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:u}=l,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],y=h.find(w=>w.id===t.id);y?(y.pointList=p,y.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:l,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:P,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:h,pointCloudSphereList:y,hideAttributes:w,setHighlight2DDataList:T,cuboidBoxIn2DView:U,imageSizes:I}=e,{addHistory:D,initHistory:R,pushHistoryUnderUpdatePolygon:V}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{getPointCloudSphereByID:k,updatePointCloudSphere:L,selectedSphere:N}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(i=>{const{stepList:n,step:d,imgList:s,imgIndex:r}=i.annotation;return{currentData:s[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,n).config)}}),A=ctx.useDispatch(),tt=ahooks.useLatest(U),W=i=>{if(!tt.current){const{mappingImgList:n=[]}=j,d=n.map(s=>index.getRectPointCloudBox({pointCloudBox:i,mappingData:s,imageSizes:I}));Object.assign(i,{rects:d.filter(s=>s!==void 0)})}},{selectedBox:S,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),X=S==null?void 0:S.info;if(!t||!l||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},nt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:i,size:n,zoom:d,trackConfigurable:s})=>{var r;const g={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};s===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const f=topViewPoint2PointCloud(i,n,G,void 0,g);u(i.id);const C=P(f);q(PointCloudView.Top,i,f,d,C,m),D({newSphereParams:f})},lt=({polygon:i,size:n,imgList:d,trackConfigurable:s,zoom:r,intelligentFit:g})=>{var f,C,v;const b={attribute:(f=t.toolInstance.defaultAttribute)!=null?f:""};s===!0&&Object.assign(b,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:y})});const z=t==null?void 0:t.toolInstance,B=__spreadValues({},i);let{boxParams:x,newPointList:O}=topViewPolygon2PointCloud(B,n,G,void 0,b,g);x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[x],stepConfig:m,action:"viewUpdateBox"}))[0],g&&(O==null?void 0:O.length)&&(B.pointList=O);const Q=w.includes(B.attribute);W(x);const E=c(x),F=(C=e==null?void 0:e.polygonList)!=null?C:[];x.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((m==null?void 0:m.secondaryAttributeConfigurable)?(v=m==null?void 0:m.inputList)!=null?v:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],F),Q?u([]):(u(x.id),z.selection.setSelectedIDs(B.id),M({omitView:PointCloudView.Top,polygon:B,boxParams:x,zoom:r,newPointCloudBoxList:E}),g&&synchronizeTopView(x,B,t,o)),D({newBoxParams:x})},rt=i=>{const{boxID:n,imageName:d,width:s,height:r,x:g,y:f}=i,C=h.find(x=>x.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(x=>x.imageName===d))return;const b=C.rects.map(x=>x.imageName===d?__spreadProps(__spreadValues({},x),{width:s,height:r,x:g,y:f}):x),z=__spreadProps(__spreadValues({},C),{rects:b}),B=h.map(x=>x.id===n?z:x);return t==null||t.updatePolygonList(B!=null?B:[]),B},dt=i=>{const{boxID:n,imageName:d}=i,s=h.find(C=>C.id===n);if(!(s==null?void 0:s.rects))return;const r=s.rects.filter(C=>C.imageName!==d),g=__spreadProps(__spreadValues({},s),{rects:r}),f=h.map(C=>C.id===n?g:C);return t==null||t.updatePolygonList(f!=null?f:[]),f},at=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:s})=>{var r;const g=t==null?void 0:t.toolInstance;if(!(p.length===0||!g)){if(i||(S==null?void 0:S.info)){const f=i!=null?i:S==null?void 0:S.info;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(p[0]);const C=g.selectedPolygon;if(p.length===1&&f){M({omitView:PointCloudView.Top,polygon:C,boxParams:f,newPointCloudBoxList:n});return}}if((d||N)&&p.length===1){const f=d!=null?d:N;g.setSelectedID(p[0]);const C=g.selectedPoint;f&&q(PointCloudView.Top,C,f,void 0,s,m)}}},Y=(i,n,d)=>{if(X){let s,r;switch(d){case PointCloudView.Back:s=backViewPolygon2PointCloud;break;case PointCloudView.Side:s=sideViewPolygon2PointCloud;break;default:s=sideViewPolygon2PointCloud;break}if(r=s(i,n,X,l.pointCloudInstance),o){const{count:b}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:b})}const f=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:m,action:"viewUpdateBox"}))[0],C=r.valid!==f.valid;r=f;const v=ot(r);return r=v.find(b=>b.id===r.id),M({omitView:C?void 0:d,polygon:i,boxParams:r,newPointCloudBoxList:v}),v}},K=(i,n,d)=>{if(N){let s,r;switch(d){case PointCloudView.Back:s=backViewPoint2PointCloud;break;case PointCloudView.Side:s=sideViewPoint2PointCloud;break;default:s=sideViewPoint2PointCloud;break}r=s(i,n,N);const g=L(r);return q(d,i,r,void 0,g,m),g}},ct=(i,n)=>{K(i,n,PointCloudView.Side)},ut=(i,n)=>{K(i,n,PointCloudView.Back)},pt=(i,n)=>{Y(i,n,PointCloudView.Side)},Pt=(i,n)=>{Y(i,n,PointCloudView.Back)},gt=(i,n)=>{const d=k(i.id),s=topViewPoint2PointCloud(i,n,G,d),r=L(s);q(PointCloudView.Top,i,s,void 0,r,m)},Ct=(i,n)=>{if(_){const s=__spreadValues({},i[0].newPolygon);s.pointList=s.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,n)),V(s);return}let d=i.map(({newPolygon:s})=>{const r=et(s.id),{boxParams:g}=topViewPolygon2PointCloud(s,n,t.pointCloudInstance,r);return g});if(d=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:m,action:"viewUpdateBox"})),d.length===1){const{newPolygon:s}=i[0],r=Z(d);M({polygon:s,boxParams:d[0],newPointCloudBoxList:r})}else{const s=Z(d);s&&e.syncAllViewPointCloudColor(s)}},ft=i=>{var n,d,s,r,g;if(S){const f=Number(i.widthDefault),C=Number(i.depthDefault),v=Number(i.heightDefault),b=S==null?void 0:S.info.trackID,B=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(H=>(H==null?void 0:H.trackID)===b),x={width:(s=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:s.width,height:(g=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:g.height},O=B.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,x)),J=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(O,v,f),Q=J[0],E=J[2],F=lbAnnotation.MathUtils.getLineCenterPoint([Q,E]),ht=S.info.center.z-S.info.depth/2,$=__spreadProps(__spreadValues({},S.info),{center:{x:F.x,y:F.y,z:ht+C/2},width:f,height:v,depth:C,valid:!0}),vt=Z([$]);M({omitView:PointCloudView["3D"],polygon:B,boxParams:$,newPointCloudBoxList:vt})}},q=(i,n,d,s,r,g)=>__async(void 0,null,function*(){const f=j==null?void 0:j.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,n,l,f,g)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(d,n,a,f,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,n,t,o)}};Object.keys(C).forEach(v=>{v!==i&&C[v]()}),s&&(o==null||o.updateCameraZoom(s)),nt(d)}),M=i=>__async(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:s,zoom:r,newPointCloudBoxList:g}=i,f=j==null?void 0:j.url;g&&(yield e.syncAllViewPointCloudColor(g));const C={[PointCloudView.Side]:()=>{synchronizeSideView(s,d,l,f)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(s,d,a,f)},[PointCloudView.Top]:()=>{synchronizeTopView(s,d,t,o)}};Object.keys(C).forEach(v=>{v!==n&&C[v]()}),r&&(o==null||o.updateCameraZoom(r)),it(s)});return{topViewAddSphere:st,topViewAddBox:lt,topViewSelectedChanged:at,topViewUpdatePoint:gt,sideViewUpdatePoint:ct,backViewUpdatePoint:ut,topViewUpdateBox:Ct,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=lbUtils.PointCloudUtils.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(n=j){var d,s,r,g,f,C;if(!(n==null?void 0:n.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(n.url,(d=m==null?void 0:m.radius)!=null?d:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],b=[],z=[],B=[];o.updateTopCamera();const x=(r=(s=index.jsonParser(n.result))==null?void 0:s.valid)!=null?r:!0;if(e.setPointCloudValid(x),(g=e.sideViewInstance)==null||g.clearAllData(),(f=e.backViewInstance)==null||f.clearAllData(),n.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),(v==null?void 0:v.length)>0&&n.isPreResult&&(m==null?void 0:m.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(n.url,m,v);const O=index.jsonParser(n.result);O[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,n.result=JSON.stringify(O),e.setPointCloudResult(v)}z=lbUtils.PointCloudUtils.getPolygonListFromResultList(n.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(n.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(C=m==null?void 0:m.radius)!=null?C:DEFAULT_RADIUS}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(B),yield e.syncAllViewPointCloudColor(v,[])}R({pointCloudBoxList:v,polygonList:z,lineList:b,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:ft,generateRects:W,update2DViewRect:rt,remove2DViewRect:dt}};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{useRef as
|
|
1
|
+
import{useRef as O,useEffect as P}from"react";import{message as T}from"antd";import{cKeyCode as z,TagUtils as G}from"@labelbee/lb-annotation";import{useAudioClipStore as N}from"../../audioAnnotate/audioContext/index.js";import{useMemoizedFn as y,useEventListener as U}from"ahooks";import R from"../../audioAnnotate/utils/dataTransform.js";var X=Object.defineProperty,q=Object.defineProperties,H=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,S=(r,e,t)=>e in r?X(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,x=(r,e)=>{for(var t in e||(e={}))J.call(e,t)&&S(r,t,e[t]);if(E)for(var t of E(e))Q.call(e,t)&&S(r,t,e[t]);return r},B=(r,e)=>q(r,H(e));const W=z.default,Y=r=>{const{waveRef:e,regionMap:t,updateRegion:d,removeRegion:C,generateRegions:D,setSelectedRegion:j}=r,{audioClipState:F,setAudioClipState:p}=N(),{selectedRegion:I,clipConfigurable:h,segment:m,clipTextList:w,subAttributeList:A,secondaryAttributeConfigurable:L=!1}=F,{id:n}=I,v=O(null),f=O(null);P(()=>{var o,u,i,a,c,s,g;if(f.current&&e.current&&m&&n){const l=(s=(i=(u=(o=e.current)==null?void 0:o.regions)==null?void 0:u.util)==null?void 0:i.getRegionSnapToGridValue)==null?void 0:s.call(i,((a=e.current)==null?void 0:a.drawer.handleEvent(f.current))*((c=e.current)==null?void 0:c.getDuration())),_=(g=t[n])!=null?g:{},{start:b,end:V}=_;if(l>b&&l<V){v.current=l;return}}v.current=null},[f.current,m]);const M=y((o,u)=>{var i,a,c;if(!n||n!==o.id){T.info("\u8BF7\u70B9\u51FB\u6240\u9009\u533A\u95F4");return}const s=t[n],g=R.getClipTextByConfig(s,w),l=B(x({},g),{id:(i=e.current)==null?void 0:i.util.getId("segment_"),end:u,subAttribute:(a=s.subAttribute)!=null?a:{}}),_=R.getClipTextByConfig(s,w,!0),b=B(x({},_),{id:(c=e.current)==null?void 0:c.util.getId("segment_"),start:u,subAttribute:G.getDefaultResultByConfig(L?A!=null?A:[]:[])});d==null||d(l),d==null||d(b),C==null||C(n),D(),p({segment:!1}),j({id:l.id,playImmediately:!0})}),K=y(o=>{if(!!h&&o.altKey&&o.keyCode===W.X){if(!n){T.info("\u8BF7\u5148\u9009\u62E9\u9700\u8981\u5206\u5272\u7684\u533A\u95F4");return}p({segment:!0,combined:!1})}}),k=y((o,u)=>{f.current=u});return U("keydown",K),P(()=>{m&&p({segment:!1})},[n]),{segmentInstance:M,onRegionMouseMove:k,segmentTimeTip:v.current}};export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as nt,MathUtils as w,getCuboidFromPointCloudBox as Gt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as Jt,DEFAULT_SPHERE_PARAMS as Qt}from"@labelbee/lb-utils";import{useContext as Xt}from"react";import{PointCloudContext as Yt}from"../PointCloudContext.js";import{useSingleBox as qt}from"./useSingleBox.js";import{useSphere as Kt}from"./useSphere.js";import{useSelector as $t,useDispatch as to}from"../../../store/ctx.js";import oo from"../../../utils/StepUtils.js";import{jsonParser as it,getRectPointCloudBox as eo}from"../../../utils/index.js";import{PreDataProcess as st,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as no}from"./useHistory.js";import{usePolygon as io}from"./usePolygon.js";import{useLatest as so}from"ahooks";var ro=Object.defineProperty,lo=Object.defineProperties,ao=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,co=Object.prototype.hasOwnProperty,uo=Object.prototype.propertyIsEnumerable,ht=(e,t,r)=>t in e?ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))co.call(t,r)&&ht(e,r,t[r]);if(mt)for(var r of mt(t))uo.call(t,r)&&ht(e,r,t[r]);return e},R=(e,t)=>lo(e,ao(t)),rt=(e,t,r)=>new Promise((a,o)=>{var c=p=>{try{u(r.next(p))}catch(m){o(m)}},g=p=>{try{u(r.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((r=r.apply(e,t)).next())});const q=5,K=90,xt=.01,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(e,t,r,a,o)=>{const{x:c,y:g}=O.transferCanvas2World(e,t),{defaultZ:u}=Qt,p={center:{x:c,y:g,z:u},id:e.id},m=a?v(v({},a),p):R(v({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},dt=(e,t,r,a,o,c)=>{let g=e.pointList.map(B=>O.transferCanvas2World(B,t)),u=0,p=1,m={};if(r){const B=r.getSensesPointZAxisInPolygon(g,void 0,c);c&&B.fittedCoordinates.length>0&&(g=B.fittedCoordinates),u=(B.maxZ+B.minZ)/2,p=B.maxZ-B.minZ,m={count:B.zCount}}const[x,I,F]=g,A=w.getLineCenterPoint([x,F]),U=w.getLineLength(x,I),k=w.getLineLength(I,F),j=w.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const z={center:{x:A.x,y:A.y,z:u},width:c?k+xt:k,height:c?U+xt:U,depth:p,rotation:j,id:e.id},T=v(a?v(v({},a),z):R(v({},z),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(B=>O.transferWorld2Canvas(B,t));return{boxParams:T,newPointList:N}},vt=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(v({},r),{center:{x:r.center.x-a.x,y:r.center.y,z:r.center.z-a.y}})},Lt=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,x=w.getLineCenterPoint([o,g]),I=w.getLineCenterPoint([u,m]),A={x:{x:x.x-I.x,y:x.y-I.y}.x,y:0,z:x.y-I.y},U=w.getLineLength(o,c),k=w.getLineLength(u,p),j=U-k,z=w.getLineLength(c,g),T=w.getLineLength(p,m),N=z-T,{newBoxParams:B}=a.getNewBoxBySideUpdate(A,N,j,r);return B},po=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(v({},r),{center:{x:r.center.x,y:r.center.y-a.x,z:r.center.z-a.y}})},go=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,x=w.getLineCenterPoint([o,g]),I=w.getLineCenterPoint([u,m]),A={x:{x:x.x-I.x,y:x.y-I.y}.x,y:0,z:x.y-I.y},U=w.getLineLength(o,c),k=w.getLineLength(u,p),j=U-k,z=w.getLineLength(c,g),T=w.getLineLength(p,m),N=z-T;let{newBoxParams:B}=a.getNewBoxByBackUpdate(A,N,j,r);return B},yt=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Left);u.setInitCameraPosition(p);const{point2d:m,zoom:x}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(x),g.setResult([R(v(v({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{width:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Left);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Back);u.setInitCameraPosition(p);const{point2d:m,zoom:x}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(x),g.setResult([R(v(v({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{height:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Back);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,r,a)=>{if(!r||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=r,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?R(v(v({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},at=(e,t,r,a)=>{var o,c;if(!r||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=r,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],x=m.find(I=>I.id===t.id);x?(x.pointList=p,x.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),g.setResultAndSelectedID(m,t.id)},fo=()=>{const e=Xt(Yt),{topViewInstance:t,sideViewInstance:r,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:x,hideAttributes:I,setHighlight2DDataList:F,cuboidBoxIn2DView:A,imageSizes:U}=e,{addHistory:k,initHistory:j,pushHistoryUnderUpdatePolygon:z}=no(),{selectedPolygon:T}=io(),{getPointCloudSphereByID:N,updatePointCloudSphere:B,selectedSphere:J}=Kt(),{currentData:H,config:S}=$t(n=>{const{stepList:i,step:d,imgList:s,imgIndex:l}=n.annotation;return{currentData:s[l],config:it(oo.getCurrentStepInfo(d,i).config)}}),E=to(),St=so(A),$=n=>{if(!St.current){const{mappingImgList:i=[]}=H,d=i.map(s=>eo({pointCloudBox:n,mappingData:s,imageSizes:U}));Object.assign(n,{rects:d.filter(s=>s!==void 0)})}},{selectedBox:D,updateSelectedBox:Dt,updateSelectedBoxes:tt,getPointCloudByID:_t}=qt({generateRects:$}),ct=D==null?void 0:D.info;if(!t||!r||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ot=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},Rt=({newPoint:n,size:i,zoom:d,trackConfigurable:s})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};s===!0&&Object.assign(f,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:x})});const P=lt(n,i,ot,void 0,f);u(n.id);const C=g(P);Q(L.Top,n,P,d,C,S),k({newSphereParams:P})},kt=({polygon:n,size:i,imgList:d,trackConfigurable:s,zoom:l,intelligentFit:f})=>{var P,C;const h={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};s===!0&&Object.assign(h,{trackID:O.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:x})});const _=t==null?void 0:t.toolInstance,V=v({},n);let{boxParams:y,newPointList:b}=dt(V,i,ot,void 0,h,f);y=E(st({tool:nt.PointCloud,dataList:[y],stepConfig:S,action:"viewUpdateBox"}))[0],f&&(b==null?void 0:b.length)&&(V.pointList=b);const X=I.includes(V.attribute);$(y);const M=c(y),et=(C=e==null?void 0:e.polygonList)!=null?C:[];t==null||t.updatePolygonList(M!=null?M:[],et),X?u([]):(u(y.id),_.selection.setSelectedIDs(V.id),W({omitView:L.Top,polygon:V,boxParams:y,zoom:l,newPointCloudBoxList:M}),f&&at(y,V,t,o)),k({newBoxParams:y})},At=n=>{const{boxID:i,imageName:d,width:s,height:l,x:f,y:P}=n,C=m.find(b=>b.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(b=>b.imageName===d))return;const _=C.rects.map(b=>b.imageName===d?R(v({},b),{width:s,height:l,x:f,y:P}):b),V=R(v({},C),{rects:_}),y=m.map(b=>b.id===i?V:b);return t==null||t.updatePolygonList(y!=null?y:[]),y},Ut=n=>{const{boxID:i,imageName:d}=n,s=m.find(C=>C.id===i);if(!(s==null?void 0:s.rects))return;const l=s.rects.filter(C=>C.imageName!==d),f=R(v({},s),{rects:l}),P=m.map(C=>C.id===i?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},zt=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:d,newSphereList:s})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(n||(D==null?void 0:D.info)){const P=n!=null?n:D==null?void 0:D.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){W({omitView:L.Top,polygon:C,boxParams:P,newPointCloudBoxList:i});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(L.Top,C,P,void 0,s,S)}}},ut=(n,i,d)=>{if(ct){let s,l;switch(d){case L.Back:s=go;break;case L.Side:s=Lt;break;default:s=Lt;break}if(l=s(n,i,ct,r.pointCloudInstance),o){const{count:_}=o.getSensesPointZAxisInPolygon(Gt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=R(v({},l),{count:_})}const P=E(st({tool:nt.PointCloud,dataList:[l],stepConfig:S,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const h=Dt(l);return l=h.find(_=>_.id===l.id),W({omitView:C?void 0:d,polygon:n,boxParams:l,newPointCloudBoxList:h}),h}},pt=(n,i,d)=>{if(J){let s,l;switch(d){case L.Back:s=po;break;case L.Side:s=vt;break;default:s=vt;break}l=s(n,i,J);const f=B(l);return Q(d,n,l,void 0,f,S),f}},Tt=(n,i)=>{pt(n,i,L.Side)},jt=(n,i)=>{pt(n,i,L.Back)},Nt=(n,i)=>{ut(n,i,L.Side)},Et=(n,i)=>{ut(n,i,L.Back)},Ft=(n,i)=>{const d=N(n.id),s=lt(n,i,ot,d),l=B(s);Q(L.Top,n,s,void 0,l,S)},Ht=(n,i)=>{if(T){const s=v({},n[0].newPolygon);s.pointList=s.pointList.map(l=>O.transferCanvas2World(l,i)),z(s);return}let d=n.map(({newPolygon:s})=>{const l=_t(s.id),{boxParams:f}=dt(s,i,t.pointCloudInstance,l);return f});if(d=E(st({tool:nt.PointCloud,dataList:d,stepConfig:S,action:"viewUpdateBox"})),d.length===1){const{newPolygon:s}=n[0],l=tt(d);W({polygon:s,boxParams:d[0],newPointCloudBoxList:l})}else{const s=tt(d);s&&e.syncAllViewPointCloudColor(s)}},Wt=n=>{var i,d,s,l,f;if(D){const P=Number(n.widthDefault),C=Number(n.depthDefault),h=Number(n.heightDefault),_=D==null?void 0:D.info.trackID,y=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===_),b={width:(s=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:s.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},Z=y.pointList.map(Y=>O.transferCanvas2World(Y,b)),X=w.getModifiedRectangleCoordinates(Z,h,P),M=X[0],et=X[2],gt=w.getLineCenterPoint([M,et]),Zt=D.info.center.z-D.info.depth/2,ft=R(v({},D.info),{center:{x:gt.x,y:gt.y,z:Zt+C/2},width:P,height:h,depth:C,valid:!0}),Mt=tt([ft]);W({omitView:L["3D"],polygon:y,boxParams:ft,newPointCloudBoxList:Mt})}},Q=(n,i,d,s,l,f)=>rt(void 0,null,function*(){const P=H==null?void 0:H.url,C={[L.Side]:()=>{yt(d,i,r,P,f)},[L.Back]:()=>{a&&bt(d,i,a,P,f)},[L.Top]:()=>{It(d,i,t,o)}};Object.keys(C).forEach(h=>{h!==n&&C[h]()}),s&&(o==null||o.updateCameraZoom(s)),Ot(d)}),W=n=>rt(void 0,null,function*(){const{omitView:i,polygon:d,boxParams:s,zoom:l,newPointCloudBoxList:f}=n,P=H==null?void 0:H.url;f&&(yield e.syncAllViewPointCloudColor(f));const C={[L.Side]:()=>{Bt(s,d,r,P)},[L.Back]:()=>{a&&wt(s,d,a,P)},[L.Top]:()=>{at(s,d,t,o)}};Object.keys(C).forEach(h=>{h!==i&&C[h]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(s)});return{topViewAddSphere:Rt,topViewAddBox:kt,topViewSelectedChanged:zt,topViewUpdatePoint:Ft,sideViewUpdatePoint:Tt,backViewUpdatePoint:jt,topViewUpdateBox:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=O.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>rt(void 0,[...n],function*(i=H){var d,s,l,f,P,C;if(!(i==null?void 0:i.url)||!o)return;F([]),Ct(E,!0),Pt(E,!0),yield o.loadPCDFile(i.url,(d=S==null?void 0:S.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let h=[],_=[],V=[],y=[];o.updateTopCamera();const b=(l=(s=it(i.result))==null?void 0:s.valid)!=null?l:!0;if(e.setPointCloudValid(b),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),i.result){if(h=O.getBoxParamsFromResultList(i.result),(h==null?void 0:h.length)>0&&i.isPreResult&&(S==null?void 0:S.lowerLimitPointsNumInBox)>0){h=yield o==null?void 0:o.filterPreResult(i.url,S,h);const Z=it(i.result);Z[Jt].result=h,i.result=JSON.stringify(Z),e.setPointCloudResult(h)}V=O.getPolygonListFromResultList(i.result),_=O.getLineListFromResultList(i.result),y=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(C=S==null?void 0:S.radius)!=null?C:K}),o==null||o.generateBoxes(h),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(h,[])}j({pointCloudBoxList:h,polygonList:V,lineList:_,pointCloudSphereList:y}),Ct(E,!1),Pt(E,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:At,remove2DViewRect:Ut}};export{bt as syncBackViewByPoint,yt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,fo as usePointCloudViews};
|
|
1
|
+
import{EPointCloudName as it,TagUtils as Gt,MathUtils as w,getCuboidFromPointCloudBox as Jt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Qt,DEFAULT_SPHERE_PARAMS as Xt}from"@labelbee/lb-utils";import{useContext as Yt}from"react";import{PointCloudContext as qt}from"../PointCloudContext.js";import{useSingleBox as Kt}from"./useSingleBox.js";import{useSphere as $t}from"./useSphere.js";import{useSelector as to,useDispatch as oo}from"../../../store/ctx.js";import eo from"../../../utils/StepUtils.js";import{jsonParser as st,getRectPointCloudBox as no}from"../../../utils/index.js";import{PreDataProcess as rt,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as io}from"./useHistory.js";import{usePolygon as so}from"./usePolygon.js";import{useLatest as ro}from"ahooks";var lo=Object.defineProperty,ao=Object.defineProperties,co=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,ht=(e,t,r)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,L=(e,t)=>{for(var r in t||(t={}))uo.call(t,r)&&ht(e,r,t[r]);if(mt)for(var r of mt(t))po.call(t,r)&&ht(e,r,t[r]);return e},O=(e,t)=>ao(e,co(t)),lt=(e,t,r)=>new Promise((a,o)=>{var c=p=>{try{u(r.next(p))}catch(m){o(m)}},g=p=>{try{u(r.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((r=r.apply(e,t)).next())});const q=5,K=90,xt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,t,r,a,o)=>{const{x:c,y:g}=V.transferCanvas2World(e,t),{defaultZ:u}=Xt,p={center:{x:c,y:g,z:u},id:e.id},m=a?L(L({},a),p):O(L({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},at=(e,t,r,a,o,c)=>{let g=e.pointList.map(B=>V.transferCanvas2World(B,t)),u=0,p=1,m={};if(r){const B=r.getSensesPointZAxisInPolygon(g,void 0,c);c&&B.fittedCoordinates.length>0&&(g=B.fittedCoordinates),u=(B.maxZ+B.minZ)/2,p=B.maxZ-B.minZ,m={count:B.zCount}}const[v,D,H]=g,A=w.getLineCenterPoint([v,H]),k=w.getLineLength(v,D),R=w.getLineLength(D,H),j=w.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const U={center:{x:A.x,y:A.y,z:u},width:c?R+xt:R,height:c?k+xt:k,depth:p,rotation:j,id:e.id},T=L(a?L(L({},a),U):O(L({},U),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(B=>V.transferWorld2Canvas(B,t));return{boxParams:T,newPointList:N}},vt=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},r),{center:{x:r.center.x-a.x,y:r.center.y,z:r.center.z-a.y}})},Lt=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T,{newBoxParams:B}=a.getNewBoxBySideUpdate(A,N,j,r);return B},go=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},r),{center:{x:r.center.x,y:r.center.y-a.x,z:r.center.z-a.y}})},fo=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T;let{newBoxParams:B}=a.getNewBoxByBackUpdate(A,N,j,r);return B},yt=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Left);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{width:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Left);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Back);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;c.loadPCDFileByBox(a,e,{height:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Back);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,r,a)=>{if(!r||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=r,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},ct=(e,t,r,a)=>{var o,c;if(!r||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=r,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],v=m.find(D=>D.id===t.id);v?(v.pointList=p,v.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),g.setResultAndSelectedID(m,t.id)},Co=()=>{const e=Yt(qt),{topViewInstance:t,sideViewInstance:r,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:v,hideAttributes:D,setHighlight2DDataList:H,cuboidBoxIn2DView:A,imageSizes:k}=e,{addHistory:R,initHistory:j,pushHistoryUnderUpdatePolygon:U}=io(),{selectedPolygon:T}=so(),{getPointCloudSphereByID:N,updatePointCloudSphere:B,selectedSphere:J}=$t(),{currentData:W,config:b}=to(n=>{const{stepList:i,step:d,imgList:s,imgIndex:l}=n.annotation;return{currentData:s[l],config:st(eo.getCurrentStepInfo(d,i).config)}}),E=oo(),Dt=ro(A),$=n=>{if(!Dt.current){const{mappingImgList:i=[]}=W,d=i.map(s=>no({pointCloudBox:n,mappingData:s,imageSizes:k}));Object.assign(n,{rects:d.filter(s=>s!==void 0)})}},{selectedBox:_,updateSelectedBox:St,updateSelectedBoxes:tt,getPointCloudByID:_t}=Kt({generateRects:$}),ut=_==null?void 0:_.info;if(!t||!r||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ot=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},Rt=({newPoint:n,size:i,zoom:d,trackConfigurable:s})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};s===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const P=dt(n,i,ot,void 0,f);u(n.id);const C=g(P);Q(y.Top,n,P,d,C,b),R({newSphereParams:P})},At=({polygon:n,size:i,imgList:d,trackConfigurable:s,zoom:l,intelligentFit:f})=>{var P,C,h;const S={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};s===!0&&Object.assign(S,{trackID:V.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:v})});const F=t==null?void 0:t.toolInstance,I=L({},n);let{boxParams:x,newPointList:z}=at(I,i,ot,void 0,S,f);x=E(rt({tool:it.PointCloud,dataList:[x],stepConfig:b,action:"viewUpdateBox"}))[0],f&&(z==null?void 0:z.length)&&(I.pointList=z);const nt=D.includes(I.attribute);$(x);const M=c(x),X=(C=e==null?void 0:e.polygonList)!=null?C:[];x.subAttribute=Gt.getDefaultResultByConfig((b==null?void 0:b.secondaryAttributeConfigurable)?(h=b==null?void 0:b.inputList)!=null?h:[]:[]),t==null||t.updatePolygonList(M!=null?M:[],X),nt?u([]):(u(x.id),F.selection.setSelectedIDs(I.id),Z({omitView:y.Top,polygon:I,boxParams:x,zoom:l,newPointCloudBoxList:M}),f&&ct(x,I,t,o)),R({newBoxParams:x})},kt=n=>{const{boxID:i,imageName:d,width:s,height:l,x:f,y:P}=n,C=m.find(x=>x.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(x=>x.imageName===d))return;const S=C.rects.map(x=>x.imageName===d?O(L({},x),{width:s,height:l,x:f,y:P}):x),F=O(L({},C),{rects:S}),I=m.map(x=>x.id===i?F:x);return t==null||t.updatePolygonList(I!=null?I:[]),I},Ut=n=>{const{boxID:i,imageName:d}=n,s=m.find(C=>C.id===i);if(!(s==null?void 0:s.rects))return;const l=s.rects.filter(C=>C.imageName!==d),f=O(L({},s),{rects:l}),P=m.map(C=>C.id===i?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},Tt=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:d,newSphereList:s})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(n||(_==null?void 0:_.info)){const P=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){Z({omitView:y.Top,polygon:C,boxParams:P,newPointCloudBoxList:i});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(y.Top,C,P,void 0,s,b)}}},pt=(n,i,d)=>{if(ut){let s,l;switch(d){case y.Back:s=fo;break;case y.Side:s=Lt;break;default:s=Lt;break}if(l=s(n,i,ut,r.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(Jt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:S})}const P=E(rt({tool:it.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const h=St(l);return l=h.find(S=>S.id===l.id),Z({omitView:C?void 0:d,polygon:n,boxParams:l,newPointCloudBoxList:h}),h}},gt=(n,i,d)=>{if(J){let s,l;switch(d){case y.Back:s=go;break;case y.Side:s=vt;break;default:s=vt;break}l=s(n,i,J);const f=B(l);return Q(d,n,l,void 0,f,b),f}},zt=(n,i)=>{gt(n,i,y.Side)},jt=(n,i)=>{gt(n,i,y.Back)},Nt=(n,i)=>{pt(n,i,y.Side)},Et=(n,i)=>{pt(n,i,y.Back)},Ft=(n,i)=>{const d=N(n.id),s=dt(n,i,ot,d),l=B(s);Q(y.Top,n,s,void 0,l,b)},Ht=(n,i)=>{if(T){const s=L({},n[0].newPolygon);s.pointList=s.pointList.map(l=>V.transferCanvas2World(l,i)),U(s);return}let d=n.map(({newPolygon:s})=>{const l=_t(s.id),{boxParams:f}=at(s,i,t.pointCloudInstance,l);return f});if(d=E(rt({tool:it.PointCloud,dataList:d,stepConfig:b,action:"viewUpdateBox"})),d.length===1){const{newPolygon:s}=n[0],l=tt(d);Z({polygon:s,boxParams:d[0],newPointCloudBoxList:l})}else{const s=tt(d);s&&e.syncAllViewPointCloudColor(s)}},Wt=n=>{var i,d,s,l,f;if(_){const P=Number(n.widthDefault),C=Number(n.depthDefault),h=Number(n.heightDefault),S=_==null?void 0:_.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===S),x={width:(s=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:s.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},z=I.pointList.map(Y=>V.transferCanvas2World(Y,x)),et=w.getModifiedRectangleCoordinates(z,h,P),nt=et[0],M=et[2],X=w.getLineCenterPoint([nt,M]),Zt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:X.x,y:X.y,z:Zt+C/2},width:P,height:h,depth:C,valid:!0}),Mt=tt([ft]);Z({omitView:y["3D"],polygon:I,boxParams:ft,newPointCloudBoxList:Mt})}},Q=(n,i,d,s,l,f)=>lt(void 0,null,function*(){const P=W==null?void 0:W.url,C={[y.Side]:()=>{yt(d,i,r,P,f)},[y.Back]:()=>{a&&bt(d,i,a,P,f)},[y.Top]:()=>{It(d,i,t,o)}};Object.keys(C).forEach(h=>{h!==n&&C[h]()}),s&&(o==null||o.updateCameraZoom(s)),Ot(d)}),Z=n=>lt(void 0,null,function*(){const{omitView:i,polygon:d,boxParams:s,zoom:l,newPointCloudBoxList:f}=n,P=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const C={[y.Side]:()=>{Bt(s,d,r,P)},[y.Back]:()=>{a&&wt(s,d,a,P)},[y.Top]:()=>{ct(s,d,t,o)}};Object.keys(C).forEach(h=>{h!==i&&C[h]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(s)});return{topViewAddSphere:Rt,topViewAddBox:At,topViewSelectedChanged:Tt,topViewUpdatePoint:Ft,sideViewUpdatePoint:zt,backViewUpdatePoint:jt,topViewUpdateBox:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>lt(void 0,[...n],function*(i=W){var d,s,l,f,P,C;if(!(i==null?void 0:i.url)||!o)return;H([]),Ct(E,!0),Pt(E,!0),yield o.loadPCDFile(i.url,(d=b==null?void 0:b.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let h=[],S=[],F=[],I=[];o.updateTopCamera();const x=(l=(s=st(i.result))==null?void 0:s.valid)!=null?l:!0;if(e.setPointCloudValid(x),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),i.result){if(h=V.getBoxParamsFromResultList(i.result),(h==null?void 0:h.length)>0&&i.isPreResult&&(b==null?void 0:b.lowerLimitPointsNumInBox)>0){h=yield o==null?void 0:o.filterPreResult(i.url,b,h);const z=st(i.result);z[Qt].result=h,i.result=JSON.stringify(z),e.setPointCloudResult(h)}F=V.getPolygonListFromResultList(i.result),S=V.getLineListFromResultList(i.result),I=V.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(C=b==null?void 0:b.radius)!=null?C:K}),o==null||o.generateBoxes(h),o==null||o.generateSpheres(I),yield e.syncAllViewPointCloudColor(h,[])}j({pointCloudBoxList:h,polygonList:F,lineList:S,pointCloudSphereList:I}),Ct(E,!1),Pt(E,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:kt,remove2DViewRect:Ut}};export{bt as syncBackViewByPoint,yt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,Co as usePointCloudViews};
|