@labelbee/lb-components 1.10.0 → 1.11.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";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=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o)),__async=(t,o,i)=>new Promise((l,e)=>{var a=d=>{try{r(i.next(d))}catch(h){e(h)}},p=d=>{try{r(i.throw(d))}catch(h){e(h)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((i=i.apply(t,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(t,o,i,l,e)=>{const{x:a,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(t,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:a,y:p,z:r},id:t.id},h=l?__spreadValues(__spreadValues({},l),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return e&&Object.assign(h,e),h},topViewPolygon2PointCloud=(t,o,i,l,e,a)=>{let p=t.pointList.map(y=>lbUtils.PointCloudUtils.transferCanvas2World(y,o)),r=0,d=1,h={};if(i){const y=i.getSensesPointZAxisInPolygon(p,void 0,a);a&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),r=(y.maxZ+y.minZ)/2,d=y.maxZ-y.minZ,h={count:y.zCount}}const[f,x,_]=p,U=lbAnnotation.MathUtils.getLineCenterPoint([f,_]),D=lbAnnotation.MathUtils.getLineLength(f,x),O=lbAnnotation.MathUtils.getLineLength(x,_),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(t.pointList);l&&(r=l.center.z,d=l.depth);const V={center:{x:U.x,y:U.y,z:r},width:O,height:D,depth:d,rotation:k,id:t.id},S=__spreadValues(l?__spreadValues(__spreadValues({},l),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);e&&Object.assign(S,e);const A=p.map(y=>lbUtils.PointCloudUtils.transferWorld2Canvas(y,o));return{boxParams:S,newPointList:A}},sideViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(t,o,i,l)=>{const[e,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,p),S=lbAnnotation.MathUtils.getLineLength(d,h),A=V-S,{newBoxParams:y}=l.getNewBoxBySideUpdate(U,A,k,i);return y},backViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(t,o,i,l)=>{const[e,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,p),S=lbAnnotation.MathUtils.getLineLength(d,h),A=V-S;let{newBoxParams:y}=l.getNewBoxByBackUpdate(U,A,k,i);return y},syncSideViewByPoint=(t,o,i,l,e)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,t,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncBackViewByPoint=(t,o,i,l,e)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,t,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncTopViewByPoint=(t,o,i,l)=>{if(!i||!l)return;l.generateSphere(t),l.updateCameraBySphere(t,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:e,pointCloudInstance:a}=i,{point2d:p}=a.getSphereTopPoint2DCoordinate(t),r=[...e.pointList].map(d=>d.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):d);e.setResult(r),e.setSelectedID(o.id)},synchronizeTopView=(t,o,i,l)=>{var e;if(!i||!l)return;l.generateBox(t,o.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),d=[...a.polygonList],h=d.find(f=>f.id===o.id);h?h.pointList=r:d.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(e=t.valid)!=null?e:!0}),a.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const t=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:e,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:h,pointCloudSphereList:f,hideAttributes:x}=t,{addHistory:_,initHistory:U,pushHistoryUnderUpdatePolygon:D,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:k}=usePolygon.usePolygon(),{updateSelectedBox:V,updateSelectedBoxes:S,getPointCloudByID:A}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:y,updatePointCloudSphere:H,selectedSphere:z}=useSphere.useSphere(),{currentData:T,config:L}=ctx.useSelector(n=>{const{stepList:s,step:P,imgList:c,imgIndex:u}=n.annotation;return{currentData:c[u],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,s).config)}}),F=ctx.useDispatch(),{selectedBox:j}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),N=j==null?void 0:j.info;if(!o||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{e==null||e.generateBox(n),e==null||e.controls.update(),e==null||e.render()},X=n=>{e==null||e.generateSphere(n),e==null||e.controls.update(),e==null||e.render()},Y=({newPoint:n,size:s,zoom:P,trackConfigurable:c})=>{var u;const C={attribute:(u=o.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const g=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const v=p(g);M(PointCloudView.Top,n,g,P,v,L),_({newSphereParams:g})},J=({polygon:n,size:s,imgList:P,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=o.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:f})});const m=o==null?void 0:o.toolInstance,w=__spreadValues({},n),{boxParams:B,newPointList:I}=topViewPolygon2PointCloud(w,s,E,void 0,v,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),m.deletePolygon(B.id);return}C&&(I==null?void 0:I.length)&&(w.pointList=I);const q=x.includes(w.attribute),b=a(B);q?r([]):(r(B.id),m.selection.setSelectedIDs(w.id),R(PointCloudView.Top,w,B,u,b),C&&synchronizeTopView(B,w,o,e)),_({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:c})=>{var u;const C=o==null?void 0:o.toolInstance;if(!(d.length===0||!C)){if(n||(j==null?void 0:j.info)){const g=n!=null?n:j==null?void 0:j.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const v=C.selectedPolygon;if(d.length===1&&g){R(PointCloudView.Top,v,g,void 0,s);return}}if((P||z)&&d.length===1){const g=P!=null?P:z;C.setSelectedID(d[0]);const v=C.selectedPoint;g&&M(PointCloudView.Top,v,g,void 0,c,L)}}},Z=(n,s,P)=>{if(N){let c,u;switch(P){case PointCloudView.Back:c=backViewPolygon2PointCloud;break;case PointCloudView.Side:c=sideViewPolygon2PointCloud;break;default:c=sideViewPolygon2PointCloud;break}if(u=c(n,s,N,i.pointCloudInstance),e){const{count:g}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=__spreadProps(__spreadValues({},u),{count:g})}const C=V(u);return R(P,n,u,void 0,C),C}},W=(n,s,P)=>{if(z){let c,u;switch(P){case PointCloudView.Back:c=backViewPoint2PointCloud;break;case PointCloudView.Side:c=sideViewPoint2PointCloud;break;default:c=sideViewPoint2PointCloud;break}u=c(n,s,z);const C=H(u);return M(P,n,u,void 0,C,L),C}},$=(n,s)=>{W(n,s,PointCloudView.Side)},tt=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},ot=(n,s)=>{Z(n,s,PointCloudView.Back)},it=(n,s)=>{O(n)},nt=(n,s)=>{const P=y(n.id),c=topViewPoint2PointCloud(n,s,E,P),u=H(c);M(PointCloudView.Top,n,c,void 0,u,L)},st=(n,s)=>{if(k){const c=n[0].newPolygon;c.pointList=c.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,s)),D(n[0].newPolygon);return}const P=n.map(({newPolygon:c})=>{const u=A(c.id),{boxParams:C}=topViewPolygon2PointCloud(c,s,o.pointCloudInstance,u);return C});if(P.length===1){const{newPolygon:c}=n[0],u=S(P);R(PointCloudView.Top,c,P[0],void 0,u)}else{const c=S(P);c&&t.syncAllViewPointCloudColor(c)}},M=(n,s,P,c,u,C)=>__async(void 0,null,function*(){const g=T==null?void 0:T.url,v={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,g,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,e)}};Object.keys(v).forEach(m=>{m!==n&&v[m]()}),c&&(e==null||e.updateCameraZoom(c)),X(P)}),R=(n,s,P,c,u)=>__async(void 0,null,function*(){const C=T==null?void 0:T.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,e)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),c&&(e==null||e.updateCameraZoom(c)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),e==null||e.generateBoxes(n)},initPointCloud3d:n=>{if(!e)return;const s={left:-n.width/2,right:n.width/2,top:n.height/2,bottom:-n.height/2,near:100,far:-100};e.initOrthographicCamera(s),e.initRenderer(),e.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=T){var P,c,u,C,g,v;if(!(s==null?void 0:s.url)||!e)return;actionCreators.SetPointCloudLoading(F,!0),yield e.loadPCDFile(s.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),h.forEach(b=>{e==null||e.removeObjectByName(b.id)}),f.forEach(b=>{e==null||e.removeObjectByName(b.id)});let m=[],w=[],B=[],I=[];s.result?(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),B=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),w=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),I=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),m.forEach(b=>{e==null||e.generateBox(b)}),I.forEach(b=>{e==null||e.generateSphere(b)}),t.syncAllViewPointCloudColor(m),t.setPointCloudResult(m),t.setPolygonList(B),t.setLineList(w),t.setPointCloudSphereList(I)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),U({pointCloudBoxList:m,polygonList:B,pointCloudSphereList:I}),e.updateTopCamera();const q=(u=(c=index.jsonParser(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(q),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.clearAllData(),o.updateData(s.url,s.result,{radius:(v=L==null?void 0:L.radius)!=null?v:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(F,!1)})}};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=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o)),__async=(t,o,i)=>new Promise((l,e)=>{var a=d=>{try{r(i.next(d))}catch(h){e(h)}},p=d=>{try{r(i.throw(d))}catch(h){e(h)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((i=i.apply(t,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(t,o,i,l,e)=>{const{x:a,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(t,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:a,y:p,z:r},id:t.id},h=l?__spreadValues(__spreadValues({},l),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return e&&Object.assign(h,e),h},topViewPolygon2PointCloud=(t,o,i,l,e,a)=>{let p=t.pointList.map(y=>lbUtils.PointCloudUtils.transferCanvas2World(y,o)),r=0,d=1,h={};if(i){const y=i.getSensesPointZAxisInPolygon(p,void 0,a);a&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),r=(y.maxZ+y.minZ)/2,d=y.maxZ-y.minZ,h={count:y.zCount}}const[f,x,_]=p,U=lbAnnotation.MathUtils.getLineCenterPoint([f,_]),D=lbAnnotation.MathUtils.getLineLength(f,x),O=lbAnnotation.MathUtils.getLineLength(x,_),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(t.pointList);l&&(r=l.center.z,d=l.depth);const V={center:{x:U.x,y:U.y,z:r},width:O,height:D,depth:d,rotation:k,id:t.id},w=__spreadValues(l?__spreadValues(__spreadValues({},l),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);e&&Object.assign(w,e);const A=p.map(y=>lbUtils.PointCloudUtils.transferWorld2Canvas(y,o));return{boxParams:w,newPointList:A}},sideViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(t,o,i,l)=>{const[e,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,p),w=lbAnnotation.MathUtils.getLineLength(d,h),A=V-w,{newBoxParams:y}=l.getNewBoxBySideUpdate(U,A,k,i);return y},backViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(t,o,i,l)=>{const[e,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,p),w=lbAnnotation.MathUtils.getLineLength(d,h),A=V-w;let{newBoxParams:y}=l.getNewBoxByBackUpdate(U,A,k,i);return y},syncSideViewByPoint=(t,o,i,l,e)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,t,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncBackViewByPoint=(t,o,i,l,e)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,t,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncTopViewByPoint=(t,o,i,l)=>{if(!i||!l)return;l.generateSphere(t),l.updateCameraBySphere(t,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:e,pointCloudInstance:a}=i,{point2d:p}=a.getSphereTopPoint2DCoordinate(t),r=[...e.pointList].map(d=>d.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):d);e.setResult(r),e.setSelectedID(o.id)},synchronizeTopView=(t,o,i,l)=>{var e;if(!i||!l)return;l.generateBox(t,o.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),d=[...a.polygonList],h=d.find(f=>f.id===o.id);h?h.pointList=r:d.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(e=t.valid)!=null?e:!0}),a.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const t=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:e,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:h,pointCloudSphereList:f,hideAttributes:x}=t,{addHistory:_,initHistory:U,pushHistoryUnderUpdatePolygon:D,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:k}=usePolygon.usePolygon(),{updateSelectedBox:V,updateSelectedBoxes:w,getPointCloudByID:A}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:y,updatePointCloudSphere:H,selectedSphere:z}=useSphere.useSphere(),{currentData:T,config:L}=ctx.useSelector(n=>{const{stepList:s,step:P,imgList:c,imgIndex:u}=n.annotation;return{currentData:c[u],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,s).config)}}),F=ctx.useDispatch(),{selectedBox:j}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),N=j==null?void 0:j.info;if(!o||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{e==null||e.generateBox(n),e==null||e.controls.update(),e==null||e.render()},X=n=>{e==null||e.generateSphere(n),e==null||e.controls.update(),e==null||e.render()},Y=({newPoint:n,size:s,zoom:P,trackConfigurable:c})=>{var u;const C={attribute:(u=o.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const g=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const v=p(g);M(PointCloudView.Top,n,g,P,v,L),_({newSphereParams:g})},J=({polygon:n,size:s,imgList:P,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=o.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:f})});const m=o==null?void 0:o.toolInstance,b=__spreadValues({},n),{boxParams:B,newPointList:I}=topViewPolygon2PointCloud(b,s,E,void 0,v,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),m.deletePolygon(B.id);return}C&&(I==null?void 0:I.length)&&(b.pointList=I);const q=x.includes(b.attribute),S=a(B);o==null||o.updatePolygonList(S!=null?S:[]),q?r([]):(r(B.id),m.selection.setSelectedIDs(b.id),R(PointCloudView.Top,b,B,u,S),C&&synchronizeTopView(B,b,o,e)),_({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:c})=>{var u;const C=o==null?void 0:o.toolInstance;if(!(d.length===0||!C)){if(n||(j==null?void 0:j.info)){const g=n!=null?n:j==null?void 0:j.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const v=C.selectedPolygon;if(d.length===1&&g){R(PointCloudView.Top,v,g,void 0,s);return}}if((P||z)&&d.length===1){const g=P!=null?P:z;C.setSelectedID(d[0]);const v=C.selectedPoint;g&&M(PointCloudView.Top,v,g,void 0,c,L)}}},Z=(n,s,P)=>{if(N){let c,u;switch(P){case PointCloudView.Back:c=backViewPolygon2PointCloud;break;case PointCloudView.Side:c=sideViewPolygon2PointCloud;break;default:c=sideViewPolygon2PointCloud;break}if(u=c(n,s,N,i.pointCloudInstance),e){const{count:g}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=__spreadProps(__spreadValues({},u),{count:g})}const C=V(u);return R(P,n,u,void 0,C),C}},W=(n,s,P)=>{if(z){let c,u;switch(P){case PointCloudView.Back:c=backViewPoint2PointCloud;break;case PointCloudView.Side:c=sideViewPoint2PointCloud;break;default:c=sideViewPoint2PointCloud;break}u=c(n,s,z);const C=H(u);return M(P,n,u,void 0,C,L),C}},$=(n,s)=>{W(n,s,PointCloudView.Side)},tt=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},ot=(n,s)=>{Z(n,s,PointCloudView.Back)},it=(n,s)=>{O(n)},nt=(n,s)=>{const P=y(n.id),c=topViewPoint2PointCloud(n,s,E,P),u=H(c);M(PointCloudView.Top,n,c,void 0,u,L)},st=(n,s)=>{if(k){const c=n[0].newPolygon;c.pointList=c.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,s)),D(n[0].newPolygon);return}const P=n.map(({newPolygon:c})=>{const u=A(c.id),{boxParams:C}=topViewPolygon2PointCloud(c,s,o.pointCloudInstance,u);return C});if(P.length===1){const{newPolygon:c}=n[0],u=w(P);R(PointCloudView.Top,c,P[0],void 0,u)}else{const c=w(P);c&&t.syncAllViewPointCloudColor(c)}},M=(n,s,P,c,u,C)=>__async(void 0,null,function*(){const g=T==null?void 0:T.url,v={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,g,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,e)}};Object.keys(v).forEach(m=>{m!==n&&v[m]()}),c&&(e==null||e.updateCameraZoom(c)),X(P)}),R=(n,s,P,c,u)=>__async(void 0,null,function*(){const C=T==null?void 0:T.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,e)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),c&&(e==null||e.updateCameraZoom(c)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),e==null||e.generateBoxes(n)},initPointCloud3d:n=>{if(!e)return;const s={left:-n.width/2,right:n.width/2,top:n.height/2,bottom:-n.height/2,near:100,far:-100};e.initOrthographicCamera(s),e.initRenderer(),e.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=T){var P,c,u,C,g,v;if(!(s==null?void 0:s.url)||!e)return;actionCreators.SetPointCloudLoading(F,!0),yield e.loadPCDFile(s.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),h.forEach(S=>{e==null||e.removeObjectByName(S.id)}),f.forEach(S=>{e==null||e.removeObjectByName(S.id)});let m=[],b=[],B=[],I=[];s.result?(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),B=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),I=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),m.forEach(S=>{e==null||e.generateBox(S)}),I.forEach(S=>{e==null||e.generateSphere(S)}),t.syncAllViewPointCloudColor(m),t.setPointCloudResult(m),t.setPolygonList(B),t.setLineList(b),t.setPointCloudSphereList(I)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),U({pointCloudBoxList:m,polygonList:B,pointCloudSphereList:I}),e.updateTopCamera();const q=(u=(c=index.jsonParser(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(q),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.clearAllData(),o.updateData(s.url,s.result,{radius:(v=L==null?void 0:L.radius)!=null?v:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(F,!1)})}};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
- "use strict";var React=require("react"),icons=require("@ant-design/icons"),ToolIcons=require("../ToolIcons.js"),lbAnnotation=require("@labelbee/lb-annotation"),PointCloudContext=require("../../../../components/pointCloudView/PointCloudContext.js"),antd=require("antd"),StepUtils=require("../../../../utils/StepUtils.js"),reactRedux=require("react-redux"),index=require("../../../../utils/index.js"),useStatus=require("../../../../components/pointCloudView/hooks/useStatus.js"),useSingleBox=require("../../../../components/pointCloudView/hooks/useSingleBox.js"),reactI18next=require("react-i18next"),ctx=require("../../../../store/ctx.js"),index$1=require("./components/batchUpdateModal/index.js"),lbUtils=require("@labelbee/lb-utils"),index$2=require("../../../../components/attributeList/index.js"),useAttribute=require("../../../../components/pointCloudView/hooks/useAttribute.js"),actionCreators=require("../../../../store/annotation/actionCreators.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__spreadValues=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const AnnotatedBox=({imgList:e,imgIndex:t})=>{const o=React.useContext(PointCloudContext.PointCloudContext),[u,p]=React.useState([]),{t:f}=reactI18next.useTranslation();React.useEffect(()=>{const a=e;let n=new Map;p(lbUtils.PointCloudUtils.getAllPointCloudResult({imgList:a,extraBoxList:v,ignoreIndexList:[t]}).filter(i=>!i.trackID||n.get(i.trackID)?!1:(n.set(i.trackID,!0),!0)).sort((i,r)=>{var d,c;const m=(d=i==null?void 0:i.trackID)!=null?d:0,_=(c=r==null?void 0:r.trackID)!=null?c:0;return m-_}).map(i=>{var r;return(r=i==null?void 0:i.trackID)!=null?r:0}))},[o.pointCloudBoxList,e]);const{pointCloudBoxList:v}=o;return React__default.default.createElement("div",{style:{padding:24,borderBottom:"1px solid #eee"}},React__default.default.createElement("div",{style:{marginBottom:16}},f("AllTrackIDs")),React__default.default.createElement("div",null,u.map(a=>React__default.default.createElement(antd.Tag,{color:"#F3F4FF",key:a,style:{color:"#666",marginBottom:8}},a))))},BoxTrackIDInput=()=>{const[e,t]=React.useState(!1),{pointCloudBoxList:o}=React.useContext(PointCloudContext.PointCloudContext),{selectedBox:u,updateSelectedBox:p}=useSingleBox.useSingleBox(),[f,v]=React.useState(""),{t:a}=reactI18next.useTranslation(),n=u==null?void 0:u.info.trackID,i=d=>!!o.find(m=>m.trackID===d&&m.id!==(u==null?void 0:u.info.id)),r=(d=!1)=>{const c=parseInt(f,10);if(d&&t(!1),isNaN(c)){antd.message.error(a("PositiveIntegerCheck"));return}if(f.indexOf(".")>-1){antd.message.error(a("NotAllowDecimalPointsInTrackID"));return}if(i(c)){antd.message.error(a("DuplicateTrackIDsExist"));return}if(!(c>0)){antd.message.error(a("PositiveIntegerCheck"));return}p({trackID:c})};return React.useEffect(()=>{t(!1)},[n]),React__default.default.createElement("div",{style:{padding:24}},React__default.default.createElement("div",{style:{marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center"}},React__default.default.createElement("span",null,a("CurrentBoxTrackIDs")),n&&React__default.default.createElement(index$1,{id:n})),React__default.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e&&n?React__default.default.createElement(antd.Input,{defaultValue:n,onChange:d=>{v(d.target.value)},disabled:!n,size:"small",onBlur:()=>{r()},onPressEnter:()=>{r(!0)}}):React__default.default.createElement("span",null,n),React__default.default.createElement(icons.EditFilled,{style:{color:"#999",marginLeft:16,cursor:typeof n!="undefined"?"pointer":"not-allowed"},onClick:()=>{n&&t(!e)}})))},AttributeUpdater=({attributeList:e,subAttributeList:t,toolInstance:o,config:u,stepList:p,stepInfo:f,enableColorPicker:v})=>{const{selectedBox:a}=useSingleBox.useSingleBox(),n=React.useContext(PointCloudContext.PointCloudContext),{t:i}=reactI18next.useTranslation(),{defaultAttribute:r}=useAttribute.useAttribute(),d=ctx.useDispatch(),c={fontWeight:500,fontSize:14,margin:"12px 0 8px 20px"},m={margin:"12px 20px 8px",fontSize:14,fontWeight:500,wordWrap:"break-word"},_=(l,x)=>{var C,b,I,y,s;const E=(C=u==null?void 0:u.attributeList)==null?void 0:C.map(g=>g.value===l?__spreadProps(__spreadValues({},g),{color:x}):g),k=__spreadProps(__spreadValues({},u),{attributeList:E}),w=JSON.stringify(k),L=p==null?void 0:p.map(g=>(g==null?void 0:g.step)===(f==null?void 0:f.step)?__spreadProps(__spreadValues({},g),{config:w}):g);(b=n==null?void 0:n.topViewInstance)==null||b.updateAttributeList(E),(I=n==null?void 0:n.sideViewInstance)==null||I.updateAttributeList(E),(y=n==null?void 0:n.backViewInstance)==null||y.updateAttributeList(E),(s=n==null?void 0:n.mainViewInstance)==null||s.setConfig(k),d(actionCreators.SetTaskStepList({stepList:L}))},P=l=>{o.setDefaultAttribute(l)},S=(l,x)=>{o.setSubAttribute(l,x)},D=e.map(l=>({label:l.key,value:l.value,color:l==null?void 0:l.color}));return React__default.default.createElement("div",null,React__default.default.createElement("div",{style:c},i("Attribute")),React__default.default.createElement(index$2.default,{list:D,forbidDefault:!0,selectedAttribute:r!=null?r:"",attributeChanged:l=>P(l),updateColorConfig:_,enableColorPicker:v}),React__default.default.createElement(antd.Divider,{style:{margin:0}}),a&&React__default.default.createElement(React__default.default.Fragment,null,t.map(l=>{var x,C,b,I,y;return(l==null?void 0:l.subSelected)&&React__default.default.createElement("div",{style:{marginTop:12},key:l.value},React__default.default.createElement("div",{style:m},i("SubAttribute"),"-",l.key),((x=l.subSelected)==null?void 0:x.length)<5?React__default.default.createElement(index$2.default,{list:l.subSelected.map(s=>({label:s.key,value:s.value})),selectedAttribute:(b=(C=n.selectedPointCloudBox)==null?void 0:C.subAttribute)==null?void 0:b[l.value],num:"-",forbidColor:!0,forbidDefault:!0,attributeChanged:s=>S(l.value,s),style:{marginBottom:12}}):React__default.default.createElement(antd.Select,{style:{margin:"0px 21px 17px 16px",width:"87%"},value:(y=(I=n.selectedPointCloudBox)==null?void 0:I.subAttribute)==null?void 0:y[l.value],placeholder:i("PleaseSelect"),onChange:s=>S(l.value,s),allowClear:!0},l.subSelected.map(s=>React__default.default.createElement(antd.Select.Option,{key:s.value,value:s.value},s.key))),React__default.default.createElement(antd.Divider,{style:{margin:0}}))})))},PointCloudToolSidebar=({stepInfo:e,toolInstance:t,imgList:o,imgIndex:u,stepList:p,enableColorPicker:f})=>{var v,a;const{updatePointCloudPattern:n,pointCloudPattern:i}=useStatus.useStatus(),r=index.jsonParser(e.config),d=(v=r==null?void 0:r.attributeList)!=null?v:[],c=(r==null?void 0:r.secondaryAttributeConfigurable)===!0?(a=r==null?void 0:r.inputList)!=null?a:[]:[];return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(ToolIcons.ToolIcons,{toolName:lbAnnotation.cTool.EPointCloudName.PointCloud,selectedToolName:i,onChange:m=>n==null?void 0:n(m)}),React__default.default.createElement(AttributeUpdater,{toolInstance:t,attributeList:d,subAttributeList:c,config:r,stepList:p,stepInfo:e,enableColorPicker:f}),(r==null?void 0:r.trackConfigurable)===!0&&React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(BoxTrackIDInput,null),React__default.default.createElement(antd.Divider,{style:{margin:0}}),React__default.default.createElement(AnnotatedBox,{imgList:o,imgIndex:u})))},mapStateToProps=e=>{var t,o,u,p;const f=StepUtils.getCurrentStepInfo((t=e.annotation)==null?void 0:t.step,(o=e.annotation)==null?void 0:o.stepList),v=(u=e.annotation)==null?void 0:u.toolInstance,a=(p=e.annotation)==null?void 0:p.stepList;return{stepInfo:f,toolInstance:v,imgList:e.annotation.imgList,imgIndex:e.annotation.imgIndex,stepList:a}};var PointCloudToolSidebar$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudToolSidebar);module.exports=PointCloudToolSidebar$1;
1
+ "use strict";var React=require("react"),icons=require("@ant-design/icons"),ToolIcons=require("../ToolIcons.js"),lbAnnotation=require("@labelbee/lb-annotation"),PointCloudContext=require("../../../../components/pointCloudView/PointCloudContext.js"),antd=require("antd"),StepUtils=require("../../../../utils/StepUtils.js"),reactRedux=require("react-redux"),index=require("../../../../utils/index.js"),useStatus=require("../../../../components/pointCloudView/hooks/useStatus.js"),useSingleBox=require("../../../../components/pointCloudView/hooks/useSingleBox.js"),reactI18next=require("react-i18next"),ctx=require("../../../../store/ctx.js"),index$1=require("./components/batchUpdateModal/index.js"),lbUtils=require("@labelbee/lb-utils"),index$2=require("../../../../components/attributeList/index.js"),useAttribute=require("../../../../components/pointCloudView/hooks/useAttribute.js"),actionCreators=require("../../../../store/annotation/actionCreators.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const AnnotatedBox=({imgList:e,imgIndex:t})=>{const n=React.useContext(PointCloudContext.PointCloudContext),[d,i]=React.useState([]),{t:v}=reactI18next.useTranslation();React.useEffect(()=>{const u=e;let r=new Map;i(lbUtils.PointCloudUtils.getAllPointCloudResult({imgList:u,extraBoxList:p,ignoreIndexList:[t]}).filter(l=>!l.trackID||r.get(l.trackID)?!1:(r.set(l.trackID,!0),!0)).sort((l,a)=>{var m,c;const g=(m=l==null?void 0:l.trackID)!=null?m:0,f=(c=a==null?void 0:a.trackID)!=null?c:0;return g-f}).map(l=>{var a;return(a=l==null?void 0:l.trackID)!=null?a:0}))},[n.pointCloudBoxList,e]);const{pointCloudBoxList:p}=n;return React__default.default.createElement("div",{style:{padding:24,borderBottom:"1px solid #eee"}},React__default.default.createElement("div",{style:{marginBottom:16}},v("AllTrackIDs")),React__default.default.createElement("div",null,d.map(u=>React__default.default.createElement(antd.Tag,{color:"#F3F4FF",key:u,style:{color:"#666",marginBottom:8}},u))))},BoxTrackIDInput=()=>{const[e,t]=React.useState(!1),n=React.useContext(PointCloudContext.PointCloudContext),{pointCloudBoxList:d}=n,{selectedBox:i,updateSelectedBox:v}=useSingleBox.useSingleBox(),[p,u]=React.useState(""),{t:r}=reactI18next.useTranslation(),l=i==null?void 0:i.info.trackID,a=c=>!!d.find(f=>f.trackID===c&&f.id!==(i==null?void 0:i.info.id)),m=(c=!1)=>{var g;const f=parseInt(p,10);if(c&&t(!1),isNaN(f)){antd.message.error(r("PositiveIntegerCheck"));return}if(p.indexOf(".")>-1){antd.message.error(r("NotAllowDecimalPointsInTrackID"));return}if(a(f)){antd.message.error(r("DuplicateTrackIDsExist"));return}if(!(f>0)){antd.message.error(r("PositiveIntegerCheck"));return}const E=v({trackID:f});(g=n==null?void 0:n.topViewInstance)==null||g.updatePolygonList(E!=null?E:[])};return React.useEffect(()=>{t(!1)},[l]),React__default.default.createElement("div",{style:{padding:24}},React__default.default.createElement("div",{style:{marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center"}},React__default.default.createElement("span",null,r("CurrentBoxTrackIDs")),l&&React__default.default.createElement(index$1,{id:l})),React__default.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e&&l?React__default.default.createElement(antd.Input,{defaultValue:l,onChange:c=>{u(c.target.value)},disabled:!l,size:"small",onBlur:()=>{m()},onPressEnter:()=>{m(!0)}}):React__default.default.createElement("span",null,l),React__default.default.createElement(icons.EditFilled,{style:{color:"#999",marginLeft:16,cursor:typeof l!="undefined"?"pointer":"not-allowed"},onClick:()=>{l&&t(!e)}})))},AttributeUpdater=({attributeList:e,subAttributeList:t,toolInstance:n,config:d,stepList:i,stepInfo:v,enableColorPicker:p})=>{const{selectedBox:u}=useSingleBox.useSingleBox(),r=React.useContext(PointCloudContext.PointCloudContext),{t:l}=reactI18next.useTranslation(),{defaultAttribute:a}=useAttribute.useAttribute(),m=ctx.useDispatch(),c={fontWeight:500,fontSize:14,margin:"12px 0 8px 20px"},g={margin:"12px 20px 8px",fontSize:14,fontWeight:500,wordWrap:"break-word"},f=(o,C)=>{var b,I,y,_,s;const S=(b=d==null?void 0:d.attributeList)==null?void 0:b.map(x=>x.value===o?__spreadProps(__spreadValues({},x),{color:C}):x),k=__spreadProps(__spreadValues({},d),{attributeList:S}),w=JSON.stringify(k),L=i==null?void 0:i.map(x=>(x==null?void 0:x.step)===(v==null?void 0:v.step)?__spreadProps(__spreadValues({},x),{config:w}):x);(I=r==null?void 0:r.topViewInstance)==null||I.updateAttributeList(S),(y=r==null?void 0:r.sideViewInstance)==null||y.updateAttributeList(S),(_=r==null?void 0:r.backViewInstance)==null||_.updateAttributeList(S),(s=r==null?void 0:r.mainViewInstance)==null||s.setConfig(k),m(actionCreators.SetTaskStepList({stepList:L}))},E=o=>{n.setDefaultAttribute(o)},P=(o,C)=>{n.setSubAttribute(o,C)},D=e.map(o=>({label:o.key,value:o.value,color:o==null?void 0:o.color}));return React__default.default.createElement("div",null,React__default.default.createElement("div",{style:c},l("Attribute")),React__default.default.createElement(index$2.default,{list:D,forbidDefault:!0,selectedAttribute:a!=null?a:"",attributeChanged:o=>E(o),updateColorConfig:f,enableColorPicker:p}),React__default.default.createElement(antd.Divider,{style:{margin:0}}),u&&React__default.default.createElement(React__default.default.Fragment,null,t.map(o=>{var C,b,I,y,_;return(o==null?void 0:o.subSelected)&&React__default.default.createElement("div",{style:{marginTop:12},key:o.value},React__default.default.createElement("div",{style:g},l("SubAttribute"),"-",o.key),((C=o.subSelected)==null?void 0:C.length)<5?React__default.default.createElement(index$2.default,{list:o.subSelected.map(s=>({label:s.key,value:s.value})),selectedAttribute:(I=(b=r.selectedPointCloudBox)==null?void 0:b.subAttribute)==null?void 0:I[o.value],num:"-",forbidColor:!0,forbidDefault:!0,attributeChanged:s=>P(o.value,s),style:{marginBottom:12}}):React__default.default.createElement(antd.Select,{style:{margin:"0px 21px 17px 16px",width:"87%"},value:(_=(y=r.selectedPointCloudBox)==null?void 0:y.subAttribute)==null?void 0:_[o.value],placeholder:l("PleaseSelect"),onChange:s=>P(o.value,s),allowClear:!0},o.subSelected.map(s=>React__default.default.createElement(antd.Select.Option,{key:s.value,value:s.value},s.key))),React__default.default.createElement(antd.Divider,{style:{margin:0}}))})))},PointCloudToolSidebar=({stepInfo:e,toolInstance:t,imgList:n,imgIndex:d,stepList:i,enableColorPicker:v})=>{var p,u;const{updatePointCloudPattern:r,pointCloudPattern:l}=useStatus.useStatus(),a=index.jsonParser(e.config),m=(p=a==null?void 0:a.attributeList)!=null?p:[],c=(a==null?void 0:a.secondaryAttributeConfigurable)===!0?(u=a==null?void 0:a.inputList)!=null?u:[]:[];return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(ToolIcons.ToolIcons,{toolName:lbAnnotation.cTool.EPointCloudName.PointCloud,selectedToolName:l,onChange:g=>r==null?void 0:r(g)}),React__default.default.createElement(AttributeUpdater,{toolInstance:t,attributeList:m,subAttributeList:c,config:a,stepList:i,stepInfo:e,enableColorPicker:v}),(a==null?void 0:a.trackConfigurable)===!0&&React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(BoxTrackIDInput,null),React__default.default.createElement(antd.Divider,{style:{margin:0}}),React__default.default.createElement(AnnotatedBox,{imgList:n,imgIndex:d})))},mapStateToProps=e=>{var t,n,d,i;const v=StepUtils.getCurrentStepInfo((t=e.annotation)==null?void 0:t.step,(n=e.annotation)==null?void 0:n.stepList),p=(d=e.annotation)==null?void 0:d.toolInstance,u=(i=e.annotation)==null?void 0:i.stepList;return{stepInfo:v,toolInstance:p,imgList:e.annotation.imgList,imgIndex:e.annotation.imgIndex,stepList:u}};var PointCloudToolSidebar$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudToolSidebar);module.exports=PointCloudToolSidebar$1;
@@ -1 +1 @@
1
- import{MathUtils as x,getCuboidFromPointCloudBox as Ot}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as I,DEFAULT_SPHERE_PARAMS as Vt}from"@labelbee/lb-utils";import{useContext as Ut}from"react";import{PointCloudContext as kt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as At}from"./useSphere.js";import{useSelector as jt,useDispatch as Tt}from"../../../store/ctx.js";import zt from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as dt}from"../../../store/annotation/actionCreators.js";import{message as Rt}from"antd";import{useTranslation as Et}from"react-i18next";import{useHistory as Ht}from"./useHistory.js";import{usePolygon as Ft}from"./usePolygon.js";var Nt=Object.defineProperty,Zt=Object.defineProperties,Wt=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,at=(t,e,n)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,m=(t,e)=>{for(var n in e||(e={}))Mt.call(e,n)&&at(t,n,e[n]);if(lt)for(var n of lt(e))Gt.call(e,n)&&at(t,n,e[n]);return t},A=(t,e)=>Zt(t,Wt(e)),q=(t,e,n)=>new Promise((d,o)=>{var a=l=>{try{r(n.next(l))}catch(P){o(P)}},p=l=>{try{r(n.throw(l))}catch(P){o(P)}},r=l=>l.done?d(l.value):Promise.resolve(l.value).then(a,p);r((n=n.apply(t,e)).next())});const G=5,Q=90,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(t,e,n,d,o)=>{const{x:a,y:p}=I.transferCanvas2World(t,e),{defaultZ:r}=Vt,l={center:{x:a,y:p,z:r},id:t.id},P=d?m(m({},d),l):A(m({},l),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},K=(t,e,n,d,o,a)=>{let p=t.pointList.map(y=>I.transferCanvas2World(y,e)),r=0,l=1,P={};if(n){const y=n.getSensesPointZAxisInPolygon(p,void 0,a);a&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),r=(y.maxZ+y.minZ)/2,l=y.maxZ-y.minZ,P={count:y.zCount}}const[h,B,j]=p,V=x.getLineCenterPoint([h,j]),T=x.getLineLength(h,B),z=x.getLineLength(B,j),R=x.getRadiusFromQuadrangle(t.pointList);d&&(r=d.center.z,l=d.depth);const U={center:{x:V.x,y:V.y,z:r},width:z,height:T,depth:l,rotation:R,id:t.id},D=m(d?m(m({},d),U):A(m({},U),{attribute:"",valid:!0}),P);o&&Object.assign(D,o);const E=p.map(y=>I.transferWorld2Canvas(y,e));return{boxParams:D,newPointList:E}},ct=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(m({},n),{center:{x:n.center.x-d.x,y:n.center.y,z:n.center.z-d.y}})},ut=(t,e,n,d)=>{const[o,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),D=x.getLineLength(l,P),E=U-D,{newBoxParams:y}=d.getNewBoxBySideUpdate(V,E,R,n);return y},Qt=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(m({},n),{center:{x:n.center.x,y:n.center.y-d.x,z:n.center.z-d.y}})},Xt=(t,e,n,d)=>{const[o,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),D=x.getLineLength(l,P),E=U-D;let{newBoxParams:y}=d.getNewBoxByBackUpdate(V,E,R,n);return y},pt=(t,e,n,d,o)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Left);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(m(m({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},ft=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,t,{width:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},Ct=(t,e,n,d,o)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Back);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(m(m({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},Pt=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,t,{height:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},gt=(t,e,n,d)=>{if(!n||!d)return;d.generateSphere(t),d.updateCameraBySphere(t,N.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=n,{point2d:p}=a.getSphereTopPoint2DCoordinate(t),r=[...o.pointList].map(l=>l.id===e.id?A(m(m({},e),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):l);o.setResult(r),o.setSelectedID(e.id)},$=(t,e,n,d)=>{var o;if(!n||!d)return;d.generateBox(t,e.id),d.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),l=[...a.polygonList],P=l.find(h=>h.id===e.id);P?P.pointList=r:l.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(o=t.valid)!=null?o:!0}),a.setResultAndSelectedID(l,e.id)},Yt=()=>{const t=Ut(kt),{topViewInstance:e,sideViewInstance:n,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:l,pointCloudBoxList:P,pointCloudSphereList:h,hideAttributes:B}=t,{addHistory:j,initHistory:V,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:z}=Ht(),{selectedPolygon:R}=Ft(),{updateSelectedBox:U,updateSelectedBoxes:D,getPointCloudByID:E}=st(),{getPointCloudSphereByID:y,updatePointCloudSphere:tt,selectedSphere:Z}=At(),{currentData:F,config:S}=jt(i=>{const{stepList:s,step:f,imgList:c,imgIndex:u}=i.annotation;return{currentData:c[u],config:rt(zt.getCurrentStepInfo(f,s).config)}}),ot=Tt(),{selectedBox:H}=st(),{t:ht}=Et(),et=H==null?void 0:H.info;if(!e||!n||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,Lt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},mt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},yt=({newPoint:i,size:s,zoom:f,trackConfigurable:c})=>{var u;const C={attribute:(u=e.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const g=J(i,s,X,void 0,C);r(i.id);const v=p(g);W(L.Top,i,g,f,v,S),j({newSphereParams:g})},vt=({polygon:i,size:s,imgList:f,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=e.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:I.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:h})});const w=e==null?void 0:e.toolInstance,_=m({},i),{boxParams:b,newPointList:k}=K(_,s,X,void 0,v,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Rt.info(ht("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),w.deletePolygon(b.id);return}C&&(k==null?void 0:k.length)&&(_.pointList=k);const Y=B.includes(_.attribute),O=a(b);Y?r([]):(r(b.id),w.selection.setSelectedIDs(_.id),M(L.Top,_,b,u,O),C&&$(b,_,e,o)),j({newBoxParams:b})},xt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:c})=>{var u;const C=e==null?void 0:e.toolInstance;if(!(l.length===0||!C)){if(i||(H==null?void 0:H.info)){const g=i!=null?i:H==null?void 0:H.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(l[0]);const v=C.selectedPolygon;if(l.length===1&&g){M(L.Top,v,g,void 0,s);return}}if((f||Z)&&l.length===1){const g=f!=null?f:Z;C.setSelectedID(l[0]);const v=C.selectedPoint;g&&W(L.Top,v,g,void 0,c,S)}}},nt=(i,s,f)=>{if(et){let c,u;switch(f){case L.Back:c=Xt;break;case L.Side:c=ut;break;default:c=ut;break}if(u=c(i,s,et,n.pointCloudInstance),o){const{count:g}=o.getSensesPointZAxisInPolygon(Ot(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=A(m({},u),{count:g})}const C=U(u);return M(f,i,u,void 0,C),C}},it=(i,s,f)=>{if(Z){let c,u;switch(f){case L.Back:c=Qt;break;case L.Side:c=ct;break;default:c=ct;break}u=c(i,s,Z);const C=tt(u);return W(f,i,u,void 0,C,S),C}},Bt=(i,s)=>{it(i,s,L.Side)},St=(i,s)=>{it(i,s,L.Back)},bt=(i,s)=>{nt(i,s,L.Side)},wt=(i,s)=>{nt(i,s,L.Back)},It=(i,s)=>{z(i)},Dt=(i,s)=>{const f=y(i.id),c=J(i,s,X,f),u=tt(c);W(L.Top,i,c,void 0,u,S)},_t=(i,s)=>{if(R){const c=i[0].newPolygon;c.pointList=c.pointList.map(u=>I.transferCanvas2World(u,s)),T(i[0].newPolygon);return}const f=i.map(({newPolygon:c})=>{const u=E(c.id),{boxParams:C}=K(c,s,e.pointCloudInstance,u);return C});if(f.length===1){const{newPolygon:c}=i[0],u=D(f);M(L.Top,c,f[0],void 0,u)}else{const c=D(f);c&&t.syncAllViewPointCloudColor(c)}},W=(i,s,f,c,u,C)=>q(void 0,null,function*(){const g=F==null?void 0:F.url,v={[L.Side]:()=>{pt(f,s,n,g,C)},[L.Back]:()=>{d&&Ct(f,s,d,g,C)},[L.Top]:()=>{gt(f,s,e,o)}};Object.keys(v).forEach(w=>{w!==i&&v[w]()}),c&&(o==null||o.updateCameraZoom(c)),mt(f)}),M=(i,s,f,c,u)=>q(void 0,null,function*(){const C=F==null?void 0:F.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[L.Side]:()=>{ft(f,s,n,C)},[L.Back]:()=>{d&&Pt(f,s,d,C)},[L.Top]:()=>{$(f,s,e,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),c&&(o==null||o.updateCameraZoom(c)),Lt(f)});return{topViewAddSphere:yt,topViewAddBox:vt,topViewSelectedChanged:xt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:_t,topViewUpdateLine:It,sideViewUpdateBox:bt,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const s={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(s=F){var f,c,u,C,g,v;if(!(s==null?void 0:s.url)||!o)return;dt(ot,!0),yield o.loadPCDFile(s.url,(f=S==null?void 0:S.radius)!=null?f:Q),P.forEach(O=>{o==null||o.removeObjectByName(O.id)}),h.forEach(O=>{o==null||o.removeObjectByName(O.id)});let w=[],_=[],b=[],k=[];s.result?(w=I.getBoxParamsFromResultList(s.result),b=I.getPolygonListFromResultList(s.result),_=I.getLineListFromResultList(s.result),k=I.getSphereParamsFromResultList(s.result),w.forEach(O=>{o==null||o.generateBox(O)}),k.forEach(O=>{o==null||o.generateSphere(O)}),t.syncAllViewPointCloudColor(w),t.setPointCloudResult(w),t.setPolygonList(b),t.setLineList(_),t.setPointCloudSphereList(k)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),V({pointCloudBoxList:w,polygonList:b,pointCloudSphereList:k}),o.updateTopCamera();const Y=(u=(c=rt(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(Y),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.clearAllData(),e.updateData(s.url,s.result,{radius:(v=S==null?void 0:S.radius)!=null?v:Q}),dt(ot,!1)})}};export{Ct as syncBackViewByPoint,pt as syncSideViewByPoint,gt as syncTopViewByPoint,Pt as synchronizeBackView,ft as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Yt as usePointCloudViews};
1
+ import{MathUtils as x,getCuboidFromPointCloudBox as Ot}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as D,DEFAULT_SPHERE_PARAMS as Vt}from"@labelbee/lb-utils";import{useContext as Ut}from"react";import{PointCloudContext as kt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as At}from"./useSphere.js";import{useSelector as jt,useDispatch as Tt}from"../../../store/ctx.js";import zt from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as dt}from"../../../store/annotation/actionCreators.js";import{message as Rt}from"antd";import{useTranslation as Et}from"react-i18next";import{useHistory as Ht}from"./useHistory.js";import{usePolygon as Ft}from"./usePolygon.js";var Nt=Object.defineProperty,Zt=Object.defineProperties,Wt=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,at=(t,e,n)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e)=>{for(var n in e||(e={}))Mt.call(e,n)&&at(t,n,e[n]);if(lt)for(var n of lt(e))Gt.call(e,n)&&at(t,n,e[n]);return t},A=(t,e)=>Zt(t,Wt(e)),q=(t,e,n)=>new Promise((d,o)=>{var a=l=>{try{r(n.next(l))}catch(P){o(P)}},p=l=>{try{r(n.throw(l))}catch(P){o(P)}},r=l=>l.done?d(l.value):Promise.resolve(l.value).then(a,p);r((n=n.apply(t,e)).next())});const G=5,Q=90,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(t,e,n,d,o)=>{const{x:a,y:p}=D.transferCanvas2World(t,e),{defaultZ:r}=Vt,l={center:{x:a,y:p,z:r},id:t.id},P=d?y(y({},d),l):A(y({},l),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},K=(t,e,n,d,o,a)=>{let p=t.pointList.map(m=>D.transferCanvas2World(m,e)),r=0,l=1,P={};if(n){const m=n.getSensesPointZAxisInPolygon(p,void 0,a);a&&m.fittedCoordinates.length>0&&(p=m.fittedCoordinates),r=(m.maxZ+m.minZ)/2,l=m.maxZ-m.minZ,P={count:m.zCount}}const[h,B,j]=p,V=x.getLineCenterPoint([h,j]),T=x.getLineLength(h,B),z=x.getLineLength(B,j),R=x.getRadiusFromQuadrangle(t.pointList);d&&(r=d.center.z,l=d.depth);const U={center:{x:V.x,y:V.y,z:r},width:z,height:T,depth:l,rotation:R,id:t.id},_=y(d?y(y({},d),U):A(y({},U),{attribute:"",valid:!0}),P);o&&Object.assign(_,o);const E=p.map(m=>D.transferWorld2Canvas(m,e));return{boxParams:_,newPointList:E}},ct=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(y({},n),{center:{x:n.center.x-d.x,y:n.center.y,z:n.center.z-d.y}})},ut=(t,e,n,d)=>{const[o,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),_=x.getLineLength(l,P),E=U-_,{newBoxParams:m}=d.getNewBoxBySideUpdate(V,E,R,n);return m},Qt=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(y({},n),{center:{x:n.center.x,y:n.center.y-d.x,z:n.center.z-d.y}})},Xt=(t,e,n,d)=>{const[o,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),_=x.getLineLength(l,P),E=U-_;let{newBoxParams:m}=d.getNewBoxByBackUpdate(V,E,R,n);return m},pt=(t,e,n,d,o)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Left);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(y(y({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},ft=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,t,{width:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},Ct=(t,e,n,d,o)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Back);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),p.setResult([A(y(y({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},Pt=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,t,{height:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},gt=(t,e,n,d)=>{if(!n||!d)return;d.generateSphere(t),d.updateCameraBySphere(t,N.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=n,{point2d:p}=a.getSphereTopPoint2DCoordinate(t),r=[...o.pointList].map(l=>l.id===e.id?A(y(y({},e),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):l);o.setResult(r),o.setSelectedID(e.id)},$=(t,e,n,d)=>{var o;if(!n||!d)return;d.generateBox(t,e.id),d.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),l=[...a.polygonList],P=l.find(h=>h.id===e.id);P?P.pointList=r:l.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(o=t.valid)!=null?o:!0}),a.setResultAndSelectedID(l,e.id)},Yt=()=>{const t=Ut(kt),{topViewInstance:e,sideViewInstance:n,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:l,pointCloudBoxList:P,pointCloudSphereList:h,hideAttributes:B}=t,{addHistory:j,initHistory:V,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:z}=Ht(),{selectedPolygon:R}=Ft(),{updateSelectedBox:U,updateSelectedBoxes:_,getPointCloudByID:E}=st(),{getPointCloudSphereByID:m,updatePointCloudSphere:tt,selectedSphere:Z}=At(),{currentData:F,config:S}=jt(i=>{const{stepList:s,step:f,imgList:c,imgIndex:u}=i.annotation;return{currentData:c[u],config:rt(zt.getCurrentStepInfo(f,s).config)}}),ot=Tt(),{selectedBox:H}=st(),{t:ht}=Et(),et=H==null?void 0:H.info;if(!e||!n||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,Lt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},yt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},mt=({newPoint:i,size:s,zoom:f,trackConfigurable:c})=>{var u;const C={attribute:(u=e.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:D.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const g=J(i,s,X,void 0,C);r(i.id);const v=p(g);W(L.Top,i,g,f,v,S),j({newSphereParams:g})},vt=({polygon:i,size:s,imgList:f,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=e.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:D.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:h})});const w=e==null?void 0:e.toolInstance,O=y({},i),{boxParams:b,newPointList:k}=K(O,s,X,void 0,v,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Rt.info(ht("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),w.deletePolygon(b.id);return}C&&(k==null?void 0:k.length)&&(O.pointList=k);const Y=B.includes(O.attribute),I=a(b);e==null||e.updatePolygonList(I!=null?I:[]),Y?r([]):(r(b.id),w.selection.setSelectedIDs(O.id),M(L.Top,O,b,u,I),C&&$(b,O,e,o)),j({newBoxParams:b})},xt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:c})=>{var u;const C=e==null?void 0:e.toolInstance;if(!(l.length===0||!C)){if(i||(H==null?void 0:H.info)){const g=i!=null?i:H==null?void 0:H.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(l[0]);const v=C.selectedPolygon;if(l.length===1&&g){M(L.Top,v,g,void 0,s);return}}if((f||Z)&&l.length===1){const g=f!=null?f:Z;C.setSelectedID(l[0]);const v=C.selectedPoint;g&&W(L.Top,v,g,void 0,c,S)}}},nt=(i,s,f)=>{if(et){let c,u;switch(f){case L.Back:c=Xt;break;case L.Side:c=ut;break;default:c=ut;break}if(u=c(i,s,et,n.pointCloudInstance),o){const{count:g}=o.getSensesPointZAxisInPolygon(Ot(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=A(y({},u),{count:g})}const C=U(u);return M(f,i,u,void 0,C),C}},it=(i,s,f)=>{if(Z){let c,u;switch(f){case L.Back:c=Qt;break;case L.Side:c=ct;break;default:c=ct;break}u=c(i,s,Z);const C=tt(u);return W(f,i,u,void 0,C,S),C}},Bt=(i,s)=>{it(i,s,L.Side)},St=(i,s)=>{it(i,s,L.Back)},bt=(i,s)=>{nt(i,s,L.Side)},wt=(i,s)=>{nt(i,s,L.Back)},It=(i,s)=>{z(i)},Dt=(i,s)=>{const f=m(i.id),c=J(i,s,X,f),u=tt(c);W(L.Top,i,c,void 0,u,S)},_t=(i,s)=>{if(R){const c=i[0].newPolygon;c.pointList=c.pointList.map(u=>D.transferCanvas2World(u,s)),T(i[0].newPolygon);return}const f=i.map(({newPolygon:c})=>{const u=E(c.id),{boxParams:C}=K(c,s,e.pointCloudInstance,u);return C});if(f.length===1){const{newPolygon:c}=i[0],u=_(f);M(L.Top,c,f[0],void 0,u)}else{const c=_(f);c&&t.syncAllViewPointCloudColor(c)}},W=(i,s,f,c,u,C)=>q(void 0,null,function*(){const g=F==null?void 0:F.url,v={[L.Side]:()=>{pt(f,s,n,g,C)},[L.Back]:()=>{d&&Ct(f,s,d,g,C)},[L.Top]:()=>{gt(f,s,e,o)}};Object.keys(v).forEach(w=>{w!==i&&v[w]()}),c&&(o==null||o.updateCameraZoom(c)),yt(f)}),M=(i,s,f,c,u)=>q(void 0,null,function*(){const C=F==null?void 0:F.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[L.Side]:()=>{ft(f,s,n,C)},[L.Back]:()=>{d&&Pt(f,s,d,C)},[L.Top]:()=>{$(f,s,e,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),c&&(o==null||o.updateCameraZoom(c)),Lt(f)});return{topViewAddSphere:mt,topViewAddBox:vt,topViewSelectedChanged:xt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:_t,topViewUpdateLine:It,sideViewUpdateBox:bt,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const s={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(s=F){var f,c,u,C,g,v;if(!(s==null?void 0:s.url)||!o)return;dt(ot,!0),yield o.loadPCDFile(s.url,(f=S==null?void 0:S.radius)!=null?f:Q),P.forEach(I=>{o==null||o.removeObjectByName(I.id)}),h.forEach(I=>{o==null||o.removeObjectByName(I.id)});let w=[],O=[],b=[],k=[];s.result?(w=D.getBoxParamsFromResultList(s.result),b=D.getPolygonListFromResultList(s.result),O=D.getLineListFromResultList(s.result),k=D.getSphereParamsFromResultList(s.result),w.forEach(I=>{o==null||o.generateBox(I)}),k.forEach(I=>{o==null||o.generateSphere(I)}),t.syncAllViewPointCloudColor(w),t.setPointCloudResult(w),t.setPolygonList(b),t.setLineList(O),t.setPointCloudSphereList(k)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),V({pointCloudBoxList:w,polygonList:b,pointCloudSphereList:k}),o.updateTopCamera();const Y=(u=(c=rt(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(Y),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.clearAllData(),e.updateData(s.url,s.result,{radius:(v=S==null?void 0:S.radius)!=null?v:Q}),dt(ot,!1)})}};export{Ct as syncBackViewByPoint,pt as syncSideViewByPoint,gt as syncTopViewByPoint,Pt as synchronizeBackView,ft as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Yt as usePointCloudViews};
@@ -1 +1 @@
1
- import t,{useContext as P,useState as D,useEffect as A}from"react";import{EditFilled as $}from"@ant-design/icons";import{ToolIcons as q}from"../ToolIcons.js";import{cTool as G}from"@labelbee/lb-annotation";import{PointCloudContext as w}from"../../../../components/pointCloudView/PointCloudContext.js";import{Divider as L,Tag as H,Input as K,Select as V,message as k}from"antd";import Q from"../../../../utils/StepUtils.js";import{connect as X}from"react-redux";import{jsonParser as Y}from"../../../../utils/index.js";import{useStatus as Z}from"../../../../components/pointCloudView/hooks/useStatus.js";import{useSingleBox as F}from"../../../../components/pointCloudView/hooks/useSingleBox.js";import{useTranslation as B}from"react-i18next";import{LabelBeeContext as tt,useDispatch as et}from"../../../../store/ctx.js";import ot from"./components/batchUpdateModal/index.js";import{PointCloudUtils as nt}from"@labelbee/lb-utils";import N from"../../../../components/attributeList/index.js";import{useAttribute as lt}from"../../../../components/pointCloudView/hooks/useAttribute.js";import{SetTaskStepList as rt}from"../../../../store/annotation/actionCreators.js";var it=Object.defineProperty,at=Object.defineProperties,st=Object.getOwnPropertyDescriptors,U=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable,M=(e,o,r)=>o in e?it(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,h=(e,o)=>{for(var r in o||(o={}))ut.call(o,r)&&M(e,r,o[r]);if(U)for(var r of U(o))ct.call(o,r)&&M(e,r,o[r]);return e},T=(e,o)=>at(e,st(o));const dt=({imgList:e,imgIndex:o})=>{const r=P(w),[u,m]=D([]),{t:f}=B();A(()=>{const a=e;let n=new Map;m(nt.getAllPointCloudResult({imgList:a,extraBoxList:v,ignoreIndexList:[o]}).filter(s=>!s.trackID||n.get(s.trackID)?!1:(n.set(s.trackID,!0),!0)).sort((s,i)=>{var d,p;const g=(d=s==null?void 0:s.trackID)!=null?d:0,S=(p=i==null?void 0:i.trackID)!=null?p:0;return g-S}).map(s=>{var i;return(i=s==null?void 0:s.trackID)!=null?i:0}))},[r.pointCloudBoxList,e]);const{pointCloudBoxList:v}=r;return t.createElement("div",{style:{padding:24,borderBottom:"1px solid #eee"}},t.createElement("div",{style:{marginBottom:16}},f("AllTrackIDs")),t.createElement("div",null,u.map(a=>t.createElement(H,{color:"#F3F4FF",key:a,style:{color:"#666",marginBottom:8}},a))))},pt=()=>{const[e,o]=D(!1),{pointCloudBoxList:r}=P(w),{selectedBox:u,updateSelectedBox:m}=F(),[f,v]=D(""),{t:a}=B(),n=u==null?void 0:u.info.trackID,s=d=>!!r.find(g=>g.trackID===d&&g.id!==(u==null?void 0:u.info.id)),i=(d=!1)=>{const p=parseInt(f,10);if(d&&o(!1),isNaN(p)){k.error(a("PositiveIntegerCheck"));return}if(f.indexOf(".")>-1){k.error(a("NotAllowDecimalPointsInTrackID"));return}if(s(p)){k.error(a("DuplicateTrackIDsExist"));return}if(!(p>0)){k.error(a("PositiveIntegerCheck"));return}m({trackID:p})};return A(()=>{o(!1)},[n]),t.createElement("div",{style:{padding:24}},t.createElement("div",{style:{marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center"}},t.createElement("span",null,a("CurrentBoxTrackIDs")),n&&t.createElement(ot,{id:n})),t.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e&&n?t.createElement(K,{defaultValue:n,onChange:d=>{v(d.target.value)},disabled:!n,size:"small",onBlur:()=>{i()},onPressEnter:()=>{i(!0)}}):t.createElement("span",null,n),t.createElement($,{style:{color:"#999",marginLeft:16,cursor:typeof n!="undefined"?"pointer":"not-allowed"},onClick:()=>{n&&o(!e)}})))},mt=({attributeList:e,subAttributeList:o,toolInstance:r,config:u,stepList:m,stepInfo:f,enableColorPicker:v})=>{const{selectedBox:a}=F(),n=P(w),{t:s}=B(),{defaultAttribute:i}=lt(),d=et(),p={fontWeight:500,fontSize:14,margin:"12px 0 8px 20px"},g={margin:"12px 20px 8px",fontSize:14,fontWeight:500,wordWrap:"break-word"},S=(l,b)=>{var C,I,y,E,c;const _=(C=u==null?void 0:u.attributeList)==null?void 0:C.map(x=>x.value===l?T(h({},x),{color:b}):x),O=T(h({},u),{attributeList:_}),R=JSON.stringify(O),J=m==null?void 0:m.map(x=>(x==null?void 0:x.step)===(f==null?void 0:f.step)?T(h({},x),{config:R}):x);(I=n==null?void 0:n.topViewInstance)==null||I.updateAttributeList(_),(y=n==null?void 0:n.sideViewInstance)==null||y.updateAttributeList(_),(E=n==null?void 0:n.backViewInstance)==null||E.updateAttributeList(_),(c=n==null?void 0:n.mainViewInstance)==null||c.setConfig(O),d(rt({stepList:J}))},z=l=>{r.setDefaultAttribute(l)},j=(l,b)=>{r.setSubAttribute(l,b)},W=e.map(l=>({label:l.key,value:l.value,color:l==null?void 0:l.color}));return t.createElement("div",null,t.createElement("div",{style:p},s("Attribute")),t.createElement(N,{list:W,forbidDefault:!0,selectedAttribute:i!=null?i:"",attributeChanged:l=>z(l),updateColorConfig:S,enableColorPicker:v}),t.createElement(L,{style:{margin:0}}),a&&t.createElement(t.Fragment,null,o.map(l=>{var b,C,I,y,E;return(l==null?void 0:l.subSelected)&&t.createElement("div",{style:{marginTop:12},key:l.value},t.createElement("div",{style:g},s("SubAttribute"),"-",l.key),((b=l.subSelected)==null?void 0:b.length)<5?t.createElement(N,{list:l.subSelected.map(c=>({label:c.key,value:c.value})),selectedAttribute:(I=(C=n.selectedPointCloudBox)==null?void 0:C.subAttribute)==null?void 0:I[l.value],num:"-",forbidColor:!0,forbidDefault:!0,attributeChanged:c=>j(l.value,c),style:{marginBottom:12}}):t.createElement(V,{style:{margin:"0px 21px 17px 16px",width:"87%"},value:(E=(y=n.selectedPointCloudBox)==null?void 0:y.subAttribute)==null?void 0:E[l.value],placeholder:s("PleaseSelect"),onChange:c=>j(l.value,c),allowClear:!0},l.subSelected.map(c=>t.createElement(V.Option,{key:c.value,value:c.value},c.key))),t.createElement(L,{style:{margin:0}}))})))},ft=({stepInfo:e,toolInstance:o,imgList:r,imgIndex:u,stepList:m,enableColorPicker:f})=>{var v,a;const{updatePointCloudPattern:n,pointCloudPattern:s}=Z(),i=Y(e.config),d=(v=i==null?void 0:i.attributeList)!=null?v:[],p=(i==null?void 0:i.secondaryAttributeConfigurable)===!0?(a=i==null?void 0:i.inputList)!=null?a:[]:[];return t.createElement(t.Fragment,null,t.createElement(q,{toolName:G.EPointCloudName.PointCloud,selectedToolName:s,onChange:g=>n==null?void 0:n(g)}),t.createElement(mt,{toolInstance:o,attributeList:d,subAttributeList:p,config:i,stepList:m,stepInfo:e,enableColorPicker:f}),(i==null?void 0:i.trackConfigurable)===!0&&t.createElement(t.Fragment,null,t.createElement(pt,null),t.createElement(L,{style:{margin:0}}),t.createElement(dt,{imgList:r,imgIndex:u})))},vt=e=>{var o,r,u,m;const f=Q.getCurrentStepInfo((o=e.annotation)==null?void 0:o.step,(r=e.annotation)==null?void 0:r.stepList),v=(u=e.annotation)==null?void 0:u.toolInstance,a=(m=e.annotation)==null?void 0:m.stepList;return{stepInfo:f,toolInstance:v,imgList:e.annotation.imgList,imgIndex:e.annotation.imgIndex,stepList:a}};var gt=X(vt,null,null,{context:tt})(ft);export{gt as default};
1
+ import t,{useContext as w,useState as D,useEffect as V}from"react";import{EditFilled as $}from"@ant-design/icons";import{ToolIcons as q}from"../ToolIcons.js";import{cTool as G}from"@labelbee/lb-annotation";import{PointCloudContext as L}from"../../../../components/pointCloudView/PointCloudContext.js";import{Divider as B,Tag as H,Input as K,Select as F,message as S}from"antd";import Q from"../../../../utils/StepUtils.js";import{connect as X}from"react-redux";import{jsonParser as Y}from"../../../../utils/index.js";import{useStatus as Z}from"../../../../components/pointCloudView/hooks/useStatus.js";import{useSingleBox as N}from"../../../../components/pointCloudView/hooks/useSingleBox.js";import{useTranslation as h}from"react-i18next";import{LabelBeeContext as tt,useDispatch as et}from"../../../../store/ctx.js";import ot from"./components/batchUpdateModal/index.js";import{PointCloudUtils as nt}from"@labelbee/lb-utils";import U from"../../../../components/attributeList/index.js";import{useAttribute as lt}from"../../../../components/pointCloudView/hooks/useAttribute.js";import{SetTaskStepList as rt}from"../../../../store/annotation/actionCreators.js";var it=Object.defineProperty,at=Object.defineProperties,st=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable,z=(e,o,n)=>o in e?it(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,T=(e,o)=>{for(var n in o||(o={}))ut.call(o,n)&&z(e,n,o[n]);if(M)for(var n of M(o))ct.call(o,n)&&z(e,n,o[n]);return e},j=(e,o)=>at(e,st(o));const dt=({imgList:e,imgIndex:o})=>{const n=w(L),[d,s]=D([]),{t:v}=h();V(()=>{const u=e;let i=new Map;s(nt.getAllPointCloudResult({imgList:u,extraBoxList:m,ignoreIndexList:[o]}).filter(l=>!l.trackID||i.get(l.trackID)?!1:(i.set(l.trackID,!0),!0)).sort((l,a)=>{var g,p;const x=(g=l==null?void 0:l.trackID)!=null?g:0,f=(p=a==null?void 0:a.trackID)!=null?p:0;return x-f}).map(l=>{var a;return(a=l==null?void 0:l.trackID)!=null?a:0}))},[n.pointCloudBoxList,e]);const{pointCloudBoxList:m}=n;return t.createElement("div",{style:{padding:24,borderBottom:"1px solid #eee"}},t.createElement("div",{style:{marginBottom:16}},v("AllTrackIDs")),t.createElement("div",null,d.map(u=>t.createElement(H,{color:"#F3F4FF",key:u,style:{color:"#666",marginBottom:8}},u))))},pt=()=>{const[e,o]=D(!1),n=w(L),{pointCloudBoxList:d}=n,{selectedBox:s,updateSelectedBox:v}=N(),[m,u]=D(""),{t:i}=h(),l=s==null?void 0:s.info.trackID,a=p=>!!d.find(f=>f.trackID===p&&f.id!==(s==null?void 0:s.info.id)),g=(p=!1)=>{var x;const f=parseInt(m,10);if(p&&o(!1),isNaN(f)){S.error(i("PositiveIntegerCheck"));return}if(m.indexOf(".")>-1){S.error(i("NotAllowDecimalPointsInTrackID"));return}if(a(f)){S.error(i("DuplicateTrackIDsExist"));return}if(!(f>0)){S.error(i("PositiveIntegerCheck"));return}const k=v({trackID:f});(x=n==null?void 0:n.topViewInstance)==null||x.updatePolygonList(k!=null?k:[])};return V(()=>{o(!1)},[l]),t.createElement("div",{style:{padding:24}},t.createElement("div",{style:{marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center"}},t.createElement("span",null,i("CurrentBoxTrackIDs")),l&&t.createElement(ot,{id:l})),t.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e&&l?t.createElement(K,{defaultValue:l,onChange:p=>{u(p.target.value)},disabled:!l,size:"small",onBlur:()=>{g()},onPressEnter:()=>{g(!0)}}):t.createElement("span",null,l),t.createElement($,{style:{color:"#999",marginLeft:16,cursor:typeof l!="undefined"?"pointer":"not-allowed"},onClick:()=>{l&&o(!e)}})))},mt=({attributeList:e,subAttributeList:o,toolInstance:n,config:d,stepList:s,stepInfo:v,enableColorPicker:m})=>{const{selectedBox:u}=N(),i=w(L),{t:l}=h(),{defaultAttribute:a}=lt(),g=et(),p={fontWeight:500,fontSize:14,margin:"12px 0 8px 20px"},x={margin:"12px 20px 8px",fontSize:14,fontWeight:500,wordWrap:"break-word"},f=(r,C)=>{var I,y,E,_,c;const P=(I=d==null?void 0:d.attributeList)==null?void 0:I.map(b=>b.value===r?j(T({},b),{color:C}):b),A=j(T({},d),{attributeList:P}),R=JSON.stringify(A),J=s==null?void 0:s.map(b=>(b==null?void 0:b.step)===(v==null?void 0:v.step)?j(T({},b),{config:R}):b);(y=i==null?void 0:i.topViewInstance)==null||y.updateAttributeList(P),(E=i==null?void 0:i.sideViewInstance)==null||E.updateAttributeList(P),(_=i==null?void 0:i.backViewInstance)==null||_.updateAttributeList(P),(c=i==null?void 0:i.mainViewInstance)==null||c.setConfig(A),g(rt({stepList:J}))},k=r=>{n.setDefaultAttribute(r)},O=(r,C)=>{n.setSubAttribute(r,C)},W=e.map(r=>({label:r.key,value:r.value,color:r==null?void 0:r.color}));return t.createElement("div",null,t.createElement("div",{style:p},l("Attribute")),t.createElement(U,{list:W,forbidDefault:!0,selectedAttribute:a!=null?a:"",attributeChanged:r=>k(r),updateColorConfig:f,enableColorPicker:m}),t.createElement(B,{style:{margin:0}}),u&&t.createElement(t.Fragment,null,o.map(r=>{var C,I,y,E,_;return(r==null?void 0:r.subSelected)&&t.createElement("div",{style:{marginTop:12},key:r.value},t.createElement("div",{style:x},l("SubAttribute"),"-",r.key),((C=r.subSelected)==null?void 0:C.length)<5?t.createElement(U,{list:r.subSelected.map(c=>({label:c.key,value:c.value})),selectedAttribute:(y=(I=i.selectedPointCloudBox)==null?void 0:I.subAttribute)==null?void 0:y[r.value],num:"-",forbidColor:!0,forbidDefault:!0,attributeChanged:c=>O(r.value,c),style:{marginBottom:12}}):t.createElement(F,{style:{margin:"0px 21px 17px 16px",width:"87%"},value:(_=(E=i.selectedPointCloudBox)==null?void 0:E.subAttribute)==null?void 0:_[r.value],placeholder:l("PleaseSelect"),onChange:c=>O(r.value,c),allowClear:!0},r.subSelected.map(c=>t.createElement(F.Option,{key:c.value,value:c.value},c.key))),t.createElement(B,{style:{margin:0}}))})))},ft=({stepInfo:e,toolInstance:o,imgList:n,imgIndex:d,stepList:s,enableColorPicker:v})=>{var m,u;const{updatePointCloudPattern:i,pointCloudPattern:l}=Z(),a=Y(e.config),g=(m=a==null?void 0:a.attributeList)!=null?m:[],p=(a==null?void 0:a.secondaryAttributeConfigurable)===!0?(u=a==null?void 0:a.inputList)!=null?u:[]:[];return t.createElement(t.Fragment,null,t.createElement(q,{toolName:G.EPointCloudName.PointCloud,selectedToolName:l,onChange:x=>i==null?void 0:i(x)}),t.createElement(mt,{toolInstance:o,attributeList:g,subAttributeList:p,config:a,stepList:s,stepInfo:e,enableColorPicker:v}),(a==null?void 0:a.trackConfigurable)===!0&&t.createElement(t.Fragment,null,t.createElement(pt,null),t.createElement(B,{style:{margin:0}}),t.createElement(dt,{imgList:n,imgIndex:d})))},vt=e=>{var o,n,d,s;const v=Q.getCurrentStepInfo((o=e.annotation)==null?void 0:o.step,(n=e.annotation)==null?void 0:n.stepList),m=(d=e.annotation)==null?void 0:d.toolInstance,u=(s=e.annotation)==null?void 0:s.stepList;return{stepInfo:v,toolInstance:m,imgList:e.annotation.imgList,imgIndex:e.annotation.imgIndex,stepList:u}};var gt=X(vt,null,null,{context:tt})(ft);export{gt as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.10.0",
3
+ "version": "1.11.0-alpha.2",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.14.0",
47
- "@labelbee/lb-utils": "1.7.0",
46
+ "@labelbee/lb-annotation": "1.15.0-alpha.2",
47
+ "@labelbee/lb-utils": "1.7.1-alpha.1",
48
48
  "ahooks": "^3.4.0",
49
49
  "classnames": "^2.3.0",
50
50
  "lodash": "^4.17.21",