@labelbee/lb-components 1.11.0-alpha.1 → 1.11.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/types/views/MainView/sidebar/PointCloudToolSidebar/components/batchUpdateModal/index.d.ts +2 -1
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/batchUpdateModal/index.js +1 -1
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/batchUpdateModal/index.js +1 -1
- package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/package.json +3 -3
|
@@ -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},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);q?r([]):(r(B.id),m.selection.setSelectedIDs(b.id),R(PointCloudView.Top,b,B,u,S),C&&synchronizeTopView(B,b,o,e)),o==null||o.updatePolygonList(S!=null?S:[]),_({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
|
+
"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;
|
|
@@ -15,6 +15,7 @@ interface IProps {
|
|
|
15
15
|
imgList: AnnotationFileList;
|
|
16
16
|
imgIndex: number;
|
|
17
17
|
stepList: IStepInfo[];
|
|
18
|
+
updateCurrentPolygonList: (value: number) => void;
|
|
18
19
|
}
|
|
19
|
-
declare const _default: import("react-redux").ConnectedComponent<({ id, stepList, imgList, imgIndex, toolInstance }: IProps) => React.JSX.Element, import("react-redux").Omit<IProps, "stepList" | "imgIndex" | "imgList" | "toolInstance">>;
|
|
20
|
+
declare const _default: import("react-redux").ConnectedComponent<({ id, stepList, imgList, imgIndex, toolInstance, updateCurrentPolygonList, }: IProps) => React.JSX.Element, import("react-redux").Omit<IProps, "stepList" | "imgIndex" | "imgList" | "toolInstance">>;
|
|
20
21
|
export default _default;
|
package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/batchUpdateModal/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var actionCreators=require("../../../../../../store/annotation/actionCreators.js"),reducer=require("../../../../../../store/annotation/reducer.js"),ctx=require("../../../../../../store/ctx.js"),antd=require("antd"),React=require("react"),reactI18next=require("react-i18next"),reactRedux=require("react-redux");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const layout={labelCol:{span:8},wrapperCol:{span:16}},inputStyle={width:"80px"},BatchUpdateModal=({id:e,stepList:t,imgList:r,imgIndex:c,toolInstance:
|
|
1
|
+
"use strict";var actionCreators=require("../../../../../../store/annotation/actionCreators.js"),reducer=require("../../../../../../store/annotation/reducer.js"),ctx=require("../../../../../../store/ctx.js"),antd=require("antd"),React=require("react"),reactI18next=require("react-i18next"),reactRedux=require("react-redux"),lbUtils=require("@labelbee/lb-utils");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const layout={labelCol:{span:8},wrapperCol:{span:16}},inputStyle={width:"80px"},BatchUpdateModal=({id:e,stepList:t,imgList:r,imgIndex:c,toolInstance:u,updateCurrentPolygonList:m})=>{const p=ctx.useDispatch(),[d,l]=React.useState(!1),[s]=antd.Form.useForm(),{t:a}=reactI18next.useTranslation(),f=n=>{const i=reducer.composeResultByToolInstance({toolInstance:u,imgList:r,imgIndex:c,stepList:t});if(i.some(g=>{const x=parseInt(n.newID,10);return lbUtils.PointCloudUtils.batchUpdateTrackIDCheck({newID:x,result:g.result})})){antd.message.error(a("DuplicateTrackIDsExist"));return}p(actionCreators.BatchUpdateTrackID({id:e,newID:n.newID,rangeIndex:[n.prevPage-1,n.nextPage-1],imgList:i}));const y=parseInt(n.newID,10);l(!1),m(y)},I=()=>l(!1),b=()=>s.submit(),o=[{required:!0,message:a("PositiveIntegerCheck")}];return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("a",{style:{color:"#666FFF"},onClick:()=>l(!0)},a("BatchUpdateText")),React__default.default.createElement(antd.Modal,{title:a("BatchUpdateTrackID"),visible:d,onCancel:I,onOk:b,wrapClassName:"labelbee-custom-modal"},React__default.default.createElement(antd.Form,__spreadProps(__spreadValues({},layout),{form:s,onFinish:f}),React__default.default.createElement(antd.Form.Item,{name:"id",label:a("CurrentBoxTrackIDs")},e),React__default.default.createElement(antd.Form.Item,{name:"newID",label:a("TrackIDUnifyAs"),rules:o},React__default.default.createElement(antd.InputNumber,{precision:0,min:1,style:inputStyle})),React__default.default.createElement(antd.Form.Item,{label:a("UnifyTrackIDRange"),required:!0},React__default.default.createElement(antd.Form.Item,{style:{display:"inline-block"},rules:o,name:"prevPage",noStyle:!0},React__default.default.createElement(antd.InputNumber,{precision:0,min:1,style:inputStyle})),React__default.default.createElement("span",{style:{display:"inline-block",width:"24px",textAlign:"center"}},"-"),React__default.default.createElement(antd.Form.Item,{style:{display:"inline-block"},rules:o,name:"nextPage",noStyle:!0},React__default.default.createElement(antd.InputNumber,{precision:0,min:1,style:inputStyle})),React__default.default.createElement("span",{style:{display:"inline-block",width:"40x",marginLeft:"10px",textAlign:"center"}},a("Page"))))))},mapStateToProps=e=>({toolInstance:e.annotation.toolInstance,imgList:e.annotation.imgList,imgIndex:e.annotation.imgIndex,stepList:e.annotation.stepList});var BatchUpdateModal$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(BatchUpdateModal);module.exports=BatchUpdateModal$1;
|
|
@@ -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,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),[
|
|
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),[c,u]=React.useState([]),{t:v}=reactI18next.useTranslation();React.useEffect(()=>{const s=e;let r=new Map;u(lbUtils.PointCloudUtils.getAllPointCloudResult({imgList:s,extraBoxList:f,ignoreIndexList:[t]}).filter(l=>!l.trackID||r.get(l.trackID)?!1:(r.set(l.trackID,!0),!0)).sort((l,a)=>{var m,g;const i=(m=l==null?void 0:l.trackID)!=null?m:0,p=(g=a==null?void 0:a.trackID)!=null?g:0;return i-p}).map(l=>{var a;return(a=l==null?void 0:l.trackID)!=null?a:0}))},[n.pointCloudBoxList,e]);const{pointCloudBoxList:f}=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,c.map(s=>React__default.default.createElement(antd.Tag,{color:"#F3F4FF",key:s,style:{color:"#666",marginBottom:8}},s))))},BoxTrackIDInput=()=>{const[e,t]=React.useState(!1),n=React.useContext(PointCloudContext.PointCloudContext),{pointCloudBoxList:c}=n,{selectedBox:u,updateSelectedBox:v}=useSingleBox.useSingleBox(),[f,s]=React.useState(""),{t:r}=reactI18next.useTranslation(),l=u==null?void 0:u.info.trackID,a=i=>!!c.find(C=>C.trackID===i&&C.id!==(u==null?void 0:u.info.id)),m=(i=!1)=>{const p=parseInt(f,10);if(i&&t(!1),isNaN(p)){antd.message.error(r("PositiveIntegerCheck"));return}if(f.indexOf(".")>-1){antd.message.error(r("NotAllowDecimalPointsInTrackID"));return}if(a(p)){antd.message.error(r("DuplicateTrackIDsExist"));return}if(!(p>0)){antd.message.error(r("PositiveIntegerCheck"));return}g(p)};React.useEffect(()=>{t(!1)},[l]);const g=i=>{var p;const C=v({trackID:i});(p=n==null?void 0:n.topViewInstance)==null||p.updatePolygonList(C!=null?C:[])};return 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,updateCurrentPolygonList:i=>g(i)})),React__default.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e&&l?React__default.default.createElement(antd.Input,{defaultValue:l,onChange:i=>{s(i.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:c,stepList:u,stepInfo:v,enableColorPicker:f})=>{const{selectedBox:s}=useSingleBox.useSingleBox(),r=React.useContext(PointCloudContext.PointCloudContext),{t:l}=reactI18next.useTranslation(),{defaultAttribute:a}=useAttribute.useAttribute(),m=ctx.useDispatch(),g={fontWeight:500,fontSize:14,margin:"12px 0 8px 20px"},i={margin:"12px 20px 8px",fontSize:14,fontWeight:500,wordWrap:"break-word"},p=(o,b)=>{var I,y,_,E,d;const P=(I=c==null?void 0:c.attributeList)==null?void 0:I.map(x=>x.value===o?__spreadProps(__spreadValues({},x),{color:b}):x),k=__spreadProps(__spreadValues({},c),{attributeList:P}),L=JSON.stringify(k),w=u==null?void 0:u.map(x=>(x==null?void 0:x.step)===(v==null?void 0:v.step)?__spreadProps(__spreadValues({},x),{config:L}):x);(y=r==null?void 0:r.topViewInstance)==null||y.updateAttributeList(P),(_=r==null?void 0:r.sideViewInstance)==null||_.updateAttributeList(P),(E=r==null?void 0:r.backViewInstance)==null||E.updateAttributeList(P),(d=r==null?void 0:r.mainViewInstance)==null||d.setConfig(k),m(actionCreators.SetTaskStepList({stepList:w}))},C=o=>{n.setDefaultAttribute(o)},S=(o,b)=>{n.setSubAttribute(o,b)},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:g},l("Attribute")),React__default.default.createElement(index$2.default,{list:D,forbidDefault:!0,selectedAttribute:a!=null?a:"",attributeChanged:o=>C(o),updateColorConfig:p,enableColorPicker:f}),React__default.default.createElement(antd.Divider,{style:{margin:0}}),s&&React__default.default.createElement(React__default.default.Fragment,null,t.map(o=>{var b,I,y,_,E;return(o==null?void 0:o.subSelected)&&React__default.default.createElement("div",{style:{marginTop:12},key:o.value},React__default.default.createElement("div",{style:i},l("SubAttribute"),"-",o.key),((b=o.subSelected)==null?void 0:b.length)<5?React__default.default.createElement(index$2.default,{list:o.subSelected.map(d=>({label:d.key,value:d.value})),selectedAttribute:(y=(I=r.selectedPointCloudBox)==null?void 0:I.subAttribute)==null?void 0:y[o.value],num:"-",forbidColor:!0,forbidDefault:!0,attributeChanged:d=>S(o.value,d),style:{marginBottom:12}}):React__default.default.createElement(antd.Select,{style:{margin:"0px 21px 17px 16px",width:"87%"},value:(E=(_=r.selectedPointCloudBox)==null?void 0:_.subAttribute)==null?void 0:E[o.value],placeholder:l("PleaseSelect"),onChange:d=>S(o.value,d),allowClear:!0},o.subSelected.map(d=>React__default.default.createElement(antd.Select.Option,{key:d.value,value:d.value},d.key))),React__default.default.createElement(antd.Divider,{style:{margin:0}}))})))},PointCloudToolSidebar=({stepInfo:e,toolInstance:t,imgList:n,imgIndex:c,stepList:u,enableColorPicker:v})=>{var f,s;const{updatePointCloudPattern:r,pointCloudPattern:l}=useStatus.useStatus(),a=index.jsonParser(e.config),m=(f=a==null?void 0:a.attributeList)!=null?f:[],g=(a==null?void 0:a.secondaryAttributeConfigurable)===!0?(s=a==null?void 0:a.inputList)!=null?s:[]:[];return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(ToolIcons.ToolIcons,{toolName:lbAnnotation.cTool.EPointCloudName.PointCloud,selectedToolName:l,onChange:i=>r==null?void 0:r(i)}),React__default.default.createElement(AttributeUpdater,{toolInstance:t,attributeList:m,subAttributeList:g,config:a,stepList:u,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:c})))},mapStateToProps=e=>{var t,n,c,u;const v=StepUtils.getCurrentStepInfo((t=e.annotation)==null?void 0:t.step,(n=e.annotation)==null?void 0:n.stepList),f=(c=e.annotation)==null?void 0:c.toolInstance,s=(u=e.annotation)==null?void 0:u.stepList;return{stepInfo:v,toolInstance:f,imgList:e.annotation.imgList,imgIndex:e.annotation.imgIndex,stepList:s}};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 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);Y?r([]):(r(b.id),w.selection.setSelectedIDs(O.id),M(L.Top,O,b,u,I),C&&$(b,O,e,o)),e==null||e.updatePolygonList(I!=null?I:[]),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
|
+
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};
|
package/es/views/MainView/sidebar/PointCloudToolSidebar/components/batchUpdateModal/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BatchUpdateTrackID as
|
|
1
|
+
import{BatchUpdateTrackID as k}from"../../../../../../store/annotation/actionCreators.js";import{composeResultByToolInstance as O}from"../../../../../../store/annotation/reducer.js";import{LabelBeeContext as T,useDispatch as v}from"../../../../../../store/ctx.js";import{Form as o,Modal as C,InputNumber as c,message as U}from"antd";import r,{useState as B}from"react";import{useTranslation as L}from"react-i18next";import{connect as j}from"react-redux";import{PointCloudUtils as F}from"@labelbee/lb-utils";var S=Object.defineProperty,N=Object.defineProperties,R=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable,I=(e,t,n)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t)=>{for(var n in t||(t={}))A.call(t,n)&&I(e,n,t[n]);if(d)for(var n of d(t))M.call(t,n)&&I(e,n,t[n]);return e},V=(e,t)=>N(e,R(t));const $={labelCol:{span:8},wrapperCol:{span:16}},m={width:"80px"},z=({id:e,stepList:t,imgList:n,imgIndex:f,toolInstance:y,updateCurrentPolygonList:g})=>{const b=v(),[x,l]=B(!1),[p]=o.useForm(),{t:a}=L(),w=s=>{const u=O({toolInstance:y,imgList:n,imgIndex:f,stepList:t});if(u.some(_=>{const h=parseInt(s.newID,10);return F.batchUpdateTrackIDCheck({newID:h,result:_.result})})){U.error(a("DuplicateTrackIDsExist"));return}b(k({id:e,newID:s.newID,rangeIndex:[s.prevPage-1,s.nextPage-1],imgList:u}));const E=parseInt(s.newID,10);l(!1),g(E)},P=()=>l(!1),D=()=>p.submit(),i=[{required:!0,message:a("PositiveIntegerCheck")}];return r.createElement(r.Fragment,null,r.createElement("a",{style:{color:"#666FFF"},onClick:()=>l(!0)},a("BatchUpdateText")),r.createElement(C,{title:a("BatchUpdateTrackID"),visible:x,onCancel:P,onOk:D,wrapClassName:"labelbee-custom-modal"},r.createElement(o,V(q({},$),{form:p,onFinish:w}),r.createElement(o.Item,{name:"id",label:a("CurrentBoxTrackIDs")},e),r.createElement(o.Item,{name:"newID",label:a("TrackIDUnifyAs"),rules:i},r.createElement(c,{precision:0,min:1,style:m})),r.createElement(o.Item,{label:a("UnifyTrackIDRange"),required:!0},r.createElement(o.Item,{style:{display:"inline-block"},rules:i,name:"prevPage",noStyle:!0},r.createElement(c,{precision:0,min:1,style:m})),r.createElement("span",{style:{display:"inline-block",width:"24px",textAlign:"center"}},"-"),r.createElement(o.Item,{style:{display:"inline-block"},rules:i,name:"nextPage",noStyle:!0},r.createElement(c,{precision:0,min:1,style:m})),r.createElement("span",{style:{display:"inline-block",width:"40x",marginLeft:"10px",textAlign:"center"}},a("Page"))))))},G=e=>({toolInstance:e.annotation.toolInstance,imgList:e.annotation.imgList,imgIndex:e.annotation.imgIndex,stepList:e.annotation.stepList});var H=j(G,null,null,{context:T})(z);export{H as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t,{useContext as
|
|
1
|
+
import t,{useContext as L,useState as w,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 D}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=L(D),[p,u]=w([]),{t:v}=h();V(()=>{const c=e;let i=new Map;u(nt.getAllPointCloudResult({imgList:c,extraBoxList:f,ignoreIndexList:[o]}).filter(l=>!l.trackID||i.get(l.trackID)?!1:(i.set(l.trackID,!0),!0)).sort((l,a)=>{var g,x;const s=(g=l==null?void 0:l.trackID)!=null?g:0,m=(x=a==null?void 0:a.trackID)!=null?x:0;return s-m}).map(l=>{var a;return(a=l==null?void 0:l.trackID)!=null?a:0}))},[n.pointCloudBoxList,e]);const{pointCloudBoxList:f}=n;return t.createElement("div",{style:{padding:24,borderBottom:"1px solid #eee"}},t.createElement("div",{style:{marginBottom:16}},v("AllTrackIDs")),t.createElement("div",null,p.map(c=>t.createElement(H,{color:"#F3F4FF",key:c,style:{color:"#666",marginBottom:8}},c))))},pt=()=>{const[e,o]=w(!1),n=L(D),{pointCloudBoxList:p}=n,{selectedBox:u,updateSelectedBox:v}=N(),[f,c]=w(""),{t:i}=h(),l=u==null?void 0:u.info.trackID,a=s=>!!p.find(C=>C.trackID===s&&C.id!==(u==null?void 0:u.info.id)),g=(s=!1)=>{const m=parseInt(f,10);if(s&&o(!1),isNaN(m)){S.error(i("PositiveIntegerCheck"));return}if(f.indexOf(".")>-1){S.error(i("NotAllowDecimalPointsInTrackID"));return}if(a(m)){S.error(i("DuplicateTrackIDsExist"));return}if(!(m>0)){S.error(i("PositiveIntegerCheck"));return}x(m)};V(()=>{o(!1)},[l]);const x=s=>{var m;const C=v({trackID:s});(m=n==null?void 0:n.topViewInstance)==null||m.updatePolygonList(C!=null?C:[])};return 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,updateCurrentPolygonList:s=>x(s)})),t.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e&&l?t.createElement(K,{defaultValue:l,onChange:s=>{c(s.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:p,stepList:u,stepInfo:v,enableColorPicker:f})=>{const{selectedBox:c}=N(),i=L(D),{t:l}=h(),{defaultAttribute:a}=lt(),g=et(),x={fontWeight:500,fontSize:14,margin:"12px 0 8px 20px"},s={margin:"12px 20px 8px",fontSize:14,fontWeight:500,wordWrap:"break-word"},m=(r,I)=>{var y,E,_,P,d;const k=(y=p==null?void 0:p.attributeList)==null?void 0:y.map(b=>b.value===r?j(T({},b),{color:I}):b),A=j(T({},p),{attributeList:k}),R=JSON.stringify(A),J=u==null?void 0:u.map(b=>(b==null?void 0:b.step)===(v==null?void 0:v.step)?j(T({},b),{config:R}):b);(E=i==null?void 0:i.topViewInstance)==null||E.updateAttributeList(k),(_=i==null?void 0:i.sideViewInstance)==null||_.updateAttributeList(k),(P=i==null?void 0:i.backViewInstance)==null||P.updateAttributeList(k),(d=i==null?void 0:i.mainViewInstance)==null||d.setConfig(A),g(rt({stepList:J}))},C=r=>{n.setDefaultAttribute(r)},O=(r,I)=>{n.setSubAttribute(r,I)},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:x},l("Attribute")),t.createElement(U,{list:W,forbidDefault:!0,selectedAttribute:a!=null?a:"",attributeChanged:r=>C(r),updateColorConfig:m,enableColorPicker:f}),t.createElement(B,{style:{margin:0}}),c&&t.createElement(t.Fragment,null,o.map(r=>{var I,y,E,_,P;return(r==null?void 0:r.subSelected)&&t.createElement("div",{style:{marginTop:12},key:r.value},t.createElement("div",{style:s},l("SubAttribute"),"-",r.key),((I=r.subSelected)==null?void 0:I.length)<5?t.createElement(U,{list:r.subSelected.map(d=>({label:d.key,value:d.value})),selectedAttribute:(E=(y=i.selectedPointCloudBox)==null?void 0:y.subAttribute)==null?void 0:E[r.value],num:"-",forbidColor:!0,forbidDefault:!0,attributeChanged:d=>O(r.value,d),style:{marginBottom:12}}):t.createElement(F,{style:{margin:"0px 21px 17px 16px",width:"87%"},value:(P=(_=i.selectedPointCloudBox)==null?void 0:_.subAttribute)==null?void 0:P[r.value],placeholder:l("PleaseSelect"),onChange:d=>O(r.value,d),allowClear:!0},r.subSelected.map(d=>t.createElement(F.Option,{key:d.value,value:d.value},d.key))),t.createElement(B,{style:{margin:0}}))})))},ft=({stepInfo:e,toolInstance:o,imgList:n,imgIndex:p,stepList:u,enableColorPicker:v})=>{var f,c;const{updatePointCloudPattern:i,pointCloudPattern:l}=Z(),a=Y(e.config),g=(f=a==null?void 0:a.attributeList)!=null?f:[],x=(a==null?void 0:a.secondaryAttributeConfigurable)===!0?(c=a==null?void 0:a.inputList)!=null?c:[]:[];return t.createElement(t.Fragment,null,t.createElement(q,{toolName:G.EPointCloudName.PointCloud,selectedToolName:l,onChange:s=>i==null?void 0:i(s)}),t.createElement(mt,{toolInstance:o,attributeList:g,subAttributeList:x,config:a,stepList:u,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:p})))},vt=e=>{var o,n,p,u;const v=Q.getCurrentStepInfo((o=e.annotation)==null?void 0:o.step,(n=e.annotation)==null?void 0:n.stepList),f=(p=e.annotation)==null?void 0:p.toolInstance,c=(u=e.annotation)==null?void 0:u.stepList;return{stepInfo:v,toolInstance:f,imgList:e.annotation.imgList,imgIndex:e.annotation.imgIndex,stepList:c}};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.11.0-alpha.
|
|
3
|
+
"version": "1.11.0-alpha.3",
|
|
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.15.0-alpha.
|
|
47
|
-
"@labelbee/lb-utils": "1.7.1-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.15.0-alpha.3",
|
|
47
|
+
"@labelbee/lb-utils": "1.7.1-alpha.2",
|
|
48
48
|
"ahooks": "^3.4.0",
|
|
49
49
|
"classnames": "^2.3.0",
|
|
50
50
|
"lodash": "^4.17.21",
|