@labelbee/lb-components 1.14.0-alpha.5 → 1.14.0-alpha.6
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/components/HighlightVisible/index.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/index.css +3 -0
- package/es/components/pointCloudView/components/HighlightVisible/index.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/index.css +3 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var React=require("react"),icons=require("@ant-design/icons");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e};const HighlightVisible=({visible:e,style:r,onClick:t,loading:a})=>{const
|
|
1
|
+
"use strict";var React=require("react"),icons=require("@ant-design/icons"),dom=require("../../../../utils/dom.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e};const HighlightVisible=({visible:e,style:r,onClick:t,loading:a})=>{const i={background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,fontSize:16,zIndex:101};let o=e?icons.EyeFilled:icons.EyeInvisibleFilled;return a&&(o=icons.LoadingOutlined,Object.assign(i,{borderRadius:100})),React__default.default.createElement(o,{className:dom.getClassName("point-cloud-highlight-view"),style:__spreadValues(__spreadValues({},i),r),onClick:a?()=>{}:t})};module.exports=HighlightVisible;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,i)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,__spreadValues=(o,e)=>{for(var i in e||(e={}))__hasOwnProp.call(e,i)&&__defNormalProp(o,i,e[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(e))__propIsEnum.call(e,i)&&__defNormalProp(o,i,e[i]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e)),__async=(o,e,i)=>new Promise((l,t)=>{var a=c=>{try{d(i.next(c))}catch(g){t(g)}},P=c=>{try{d(i.throw(c))}catch(g){t(g)}},d=c=>c.done?l(c.value):Promise.resolve(c.value).then(a,P);d((i=i.apply(o,e)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,e,i,l,t)=>{const{x:a,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,e),{defaultZ:d}=lbUtils.DEFAULT_SPHERE_PARAMS,c={center:{x:a,y:P,z:d},id:o.id},g=l?__spreadValues(__spreadValues({},l),c):__spreadProps(__spreadValues({},c),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},topViewPolygon2PointCloud=(o,e,i,l,t,a)=>{let P=o.pointList.map(f=>lbUtils.PointCloudUtils.transferCanvas2World(f,e)),d=0,c=1,g={};if(i){const f=i.getSensesPointZAxisInPolygon(P,void 0,a);a&&f.fittedCoordinates.length>0&&(P=f.fittedCoordinates),d=(f.maxZ+f.minZ)/2,c=f.maxZ-f.minZ,g={count:f.zCount}}const[h,m,T]=P,b=lbAnnotation.MathUtils.getLineCenterPoint([h,T]),D=lbAnnotation.MathUtils.getLineLength(h,m),I=lbAnnotation.MathUtils.getLineLength(m,T),O=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);l&&(d=l.center.z,c=l.depth);const _={center:{x:b.x,y:b.y,z:d},width:a?I+INTELLIGENT_FIT_MARGIN:I,height:a?D+INTELLIGENT_FIT_MARGIN:D,depth:c,rotation:O,id:o.id},k=__spreadValues(l?__spreadValues(__spreadValues({},l),_):__spreadProps(__spreadValues({},_),{attribute:"",valid:!0}),g);t&&Object.assign(k,t);const S=P.map(f=>lbUtils.PointCloudUtils.transferWorld2Canvas(f,e));return{boxParams:k,newPointList:S}},sideViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k,{newBoxParams:f}=l.getNewBoxBySideUpdate(b,S,O,i);return f},backViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k;let{newBoxParams:f}=l.getNewBoxByBackUpdate(b,S,O,i);return f},syncSideViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereSidePoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeSideView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxSidePolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncBackViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereBackPoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeBackView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxBackPolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncTopViewByPoint=(o,e,i,l)=>{if(!i||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=i,{point2d:P}=a.getSphereTopPoint2DCoordinate(o),d=[...t.pointList].map(c=>c.id===e.id?__spreadProps(__spreadValues(__spreadValues({},e),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):c);t.setResult(d),t.setSelectedID(e.id)},synchronizeTopView=(o,e,i,l)=>{var t,a;if(!i||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:P,pointCloudInstance:d}=i,{polygon2d:c}=d.getBoxTopPolygon2DCoordinate(o),g=[...P.polygonList],h=g.find(m=>m.id===e.id);h?(h.pointList=c,h.valid=(t=o.valid)!=null?t:!0):g.push({id:e.id,pointList:c,textAttribute:"",isRect:!0,valid:(a=o.valid)!=null?a:!0}),P.setResultAndSelectedID(g,e.id)},usePointCloudViews=()=>{const o=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:e,sideViewInstance:i,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:P,setSelectedIDs:d,selectedIDs:c,pointCloudBoxList:g,pointCloudSphereList:h,hideAttributes:m,setHighlight2DDataList:T}=o,{addHistory:b,initHistory:D,pushHistoryUnderUpdatePolygon:I,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{updateSelectedBox:k,updateSelectedBoxes:S,getPointCloudByID:f}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:G,updatePointCloudSphere:H,selectedSphere:M}=useSphere.useSphere(),{currentData:z,config:L}=ctx.useSelector(n=>{const{stepList:s,step:p,imgList:u,imgIndex:r}=n.annotation;return{currentData:u[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),A=ctx.useDispatch(),{selectedBox:w}=useSingleBox.useSingleBox(),{t:Q}=reactI18next.useTranslation(),F=w==null?void 0:w.info;if(!e||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:N}=e,X=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},Y=n=>{t==null||t.generateSphere(n),t==null||t.controls.update(),t==null||t.render()},J=({newPoint:n,size:s,zoom:p,trackConfigurable:u})=>{var r;const C={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};u===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const x=topViewPoint2PointCloud(n,s,N,void 0,C);d(n.id);const y=P(x);E(PointCloudView.Top,n,x,p,y,L),b({newSphereParams:x})},K=({polygon:n,size:s,imgList:p,trackConfigurable:u,zoom:r,intelligentFit:C})=>{var x,y;const v={attribute:(x=e.toolInstance.defaultAttribute)!=null?x:""};u===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:h})});const U=e==null?void 0:e.toolInstance,V=__spreadValues({},n);let{boxParams:B,newPointList:R}=topViewPolygon2PointCloud(V,s,N,void 0,v,C);if(B=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:L,action:"viewUpdateBox"}))[0],(L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(Q("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),U.deletePolygon(B.id);return}C&&(R==null?void 0:R.length)&&(V.pointList=R);const at=m.includes(V.attribute),q=a(B),dt=(y=o==null?void 0:o.polygonList)!=null?y:[];e==null||e.updatePolygonList(q!=null?q:[],dt),at?d([]):(d(B.id),U.selection.setSelectedIDs(V.id),j({omitView:PointCloudView.Top,polygon:V,boxParams:B,zoom:r,newPointCloudBoxList:q}),C&&synchronizeTopView(B,V,e,t)),b({newBoxParams:B})},$=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:u})=>{var r;const C=e==null?void 0:e.toolInstance;if(!(c.length===0||!C)){if(n||(w==null?void 0:w.info)){const x=n!=null?n:w==null?void 0:w.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(c[0]);const y=C.selectedPolygon;if(c.length===1&&x){j({omitView:PointCloudView.Top,polygon:y,boxParams:x,newPointCloudBoxList:s});return}}if((p||M)&&c.length===1){const x=p!=null?p:M;C.setSelectedID(c[0]);const y=C.selectedPoint;x&&E(PointCloudView.Top,y,x,void 0,u,L)}}},Z=(n,s,p)=>{if(F){let u,r;switch(p){case PointCloudView.Back:u=backViewPolygon2PointCloud;break;case PointCloudView.Side:u=sideViewPolygon2PointCloud;break;default:u=sideViewPolygon2PointCloud;break}r=u(n,s,F,i.pointCloudInstance);const x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:L,action:"viewUpdateBox"}))[0],y=r.valid!==x.valid;if(r=x,t){const{count:U}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:U})}const v=k(r);return r=v.find(U=>U.id===r.id),j({omitView:y?void 0:p,polygon:n,boxParams:r,newPointCloudBoxList:[r]}),v}},W=(n,s,p)=>{if(M){let u,r;switch(p){case PointCloudView.Back:u=backViewPoint2PointCloud;break;case PointCloudView.Side:u=sideViewPoint2PointCloud;break;default:u=sideViewPoint2PointCloud;break}r=u(n,s,M);const C=H(r);return E(p,n,r,void 0,C,L),C}},tt=(n,s)=>{W(n,s,PointCloudView.Side)},ot=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},it=(n,s)=>{Z(n,s,PointCloudView.Back)},nt=(n,s)=>{O(n)},st=(n,s)=>{const p=G(n.id),u=topViewPoint2PointCloud(n,s,N,p),r=H(u);E(PointCloudView.Top,n,u,void 0,r,L)},rt=(n,s)=>{if(_){const u=n[0].newPolygon;u.pointList=u.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,s)),I(n[0].newPolygon);return}let p=n.map(({newPolygon:u})=>{const r=f(u.id),{boxParams:C}=topViewPolygon2PointCloud(u,s,e.pointCloudInstance,r);return C});if(p=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:L,action:"viewUpdateBox"})),p.length===1){const{newPolygon:u}=n[0],r=S(p);j({omitView:PointCloudView.Top,polygon:u,boxParams:p[0],newPointCloudBoxList:r})}else{const u=S(p);u&&o.syncAllViewPointCloudColor(u)}},lt=n=>{var s;if(w){const p=w==null?void 0:w.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(y=>(y==null?void 0:y.trackID)===p),C=__spreadProps(__spreadValues({},w.info),{width:Number(n.widthDefault),depth:Number(n.depthDefault),height:Number(n.heightDefault)}),x=S([C]);j({omitView:PointCloudView["3D"],polygon:r,boxParams:C,newPointCloudBoxList:x})}},E=(n,s,p,u,r,C)=>__async(void 0,null,function*(){const x=z==null?void 0:z.url,y={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,i,x,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(p,s,l,x,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,e,t)}};Object.keys(y).forEach(v=>{v!==n&&y[v]()}),u&&(t==null||t.updateCameraZoom(u)),Y(p)}),j=n=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:u,zoom:r,newPointCloudBoxList:C}=n,x=z==null?void 0:z.url;C&&(yield o.syncAllViewPointCloudColor(C));const y={[PointCloudView.Side]:()=>{synchronizeSideView(u,p,i,x)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(u,p,l,x)},[PointCloudView.Top]:()=>{synchronizeTopView(u,p,e,t)}};Object.keys(y).forEach(v=>{v!==s&&y[v]()}),r&&(t==null||t.updateCameraZoom(r)),X(u)});return{topViewAddSphere:J,topViewAddBox:K,topViewSelectedChanged:$,topViewUpdatePoint:st,sideViewUpdatePoint:tt,backViewUpdatePoint:ot,topViewUpdateBox:rt,topViewUpdateLine:nt,sideViewUpdateBox:et,backViewUpdateBox:it,pointCloudBoxListUpdated:n=>{e.updatePolygonList(n),t==null||t.generateBoxes(n)},initPointCloud3d:n=>{if(!t)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=z){var p,u,r,C,x,y;if(!(s==null?void 0:s.url)||!t)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield t.loadPCDFile(s.url,(p=L==null?void 0:L.radius)!=null?p:DEFAULT_RADIUS),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],U=[],V=[],B=[];t.updateTopCamera();const R=(r=(u=index.jsonParser(s.result))==null?void 0:u.valid)!=null?r:!0;o.setPointCloudValid(R),(C=o.sideViewInstance)==null||C.clearAllData(),(x=o.backViewInstance)==null||x.clearAllData(),e.updateData(s.url,s.result,{radius:(y=L==null?void 0:L.radius)!=null?y:DEFAULT_RADIUS}),s.result&&(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),V=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),U=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(B),yield o.syncAllViewPointCloudColor(v,[])),D({pointCloudBoxList:v,polygonList:V,lineList:U,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:lt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,i)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,__spreadValues=(o,e)=>{for(var i in e||(e={}))__hasOwnProp.call(e,i)&&__defNormalProp(o,i,e[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(e))__propIsEnum.call(e,i)&&__defNormalProp(o,i,e[i]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e)),__async=(o,e,i)=>new Promise((l,t)=>{var a=c=>{try{d(i.next(c))}catch(g){t(g)}},P=c=>{try{d(i.throw(c))}catch(g){t(g)}},d=c=>c.done?l(c.value):Promise.resolve(c.value).then(a,P);d((i=i.apply(o,e)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,e,i,l,t)=>{const{x:a,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,e),{defaultZ:d}=lbUtils.DEFAULT_SPHERE_PARAMS,c={center:{x:a,y:P,z:d},id:o.id},g=l?__spreadValues(__spreadValues({},l),c):__spreadProps(__spreadValues({},c),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},topViewPolygon2PointCloud=(o,e,i,l,t,a)=>{let P=o.pointList.map(f=>lbUtils.PointCloudUtils.transferCanvas2World(f,e)),d=0,c=1,g={};if(i){const f=i.getSensesPointZAxisInPolygon(P,void 0,a);a&&f.fittedCoordinates.length>0&&(P=f.fittedCoordinates),d=(f.maxZ+f.minZ)/2,c=f.maxZ-f.minZ,g={count:f.zCount}}const[h,m,T]=P,b=lbAnnotation.MathUtils.getLineCenterPoint([h,T]),D=lbAnnotation.MathUtils.getLineLength(h,m),I=lbAnnotation.MathUtils.getLineLength(m,T),O=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);l&&(d=l.center.z,c=l.depth);const _={center:{x:b.x,y:b.y,z:d},width:a?I+INTELLIGENT_FIT_MARGIN:I,height:a?D+INTELLIGENT_FIT_MARGIN:D,depth:c,rotation:O,id:o.id},k=__spreadValues(l?__spreadValues(__spreadValues({},l),_):__spreadProps(__spreadValues({},_),{attribute:"",valid:!0}),g);t&&Object.assign(k,t);const S=P.map(f=>lbUtils.PointCloudUtils.transferWorld2Canvas(f,e));return{boxParams:k,newPointList:S}},sideViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k,{newBoxParams:f}=l.getNewBoxBySideUpdate(b,S,O,i);return f},backViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k;let{newBoxParams:f}=l.getNewBoxByBackUpdate(b,S,O,i);return f},syncSideViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereSidePoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeSideView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxSidePolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncBackViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereBackPoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeBackView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxBackPolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncTopViewByPoint=(o,e,i,l)=>{if(!i||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=i,{point2d:P}=a.getSphereTopPoint2DCoordinate(o),d=[...t.pointList].map(c=>c.id===e.id?__spreadProps(__spreadValues(__spreadValues({},e),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):c);t.setResult(d),t.setSelectedID(e.id)},synchronizeTopView=(o,e,i,l)=>{var t,a;if(!i||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:P,pointCloudInstance:d}=i,{polygon2d:c}=d.getBoxTopPolygon2DCoordinate(o),g=[...P.polygonList],h=g.find(m=>m.id===e.id);h?(h.pointList=c,h.valid=(t=o.valid)!=null?t:!0):g.push({id:e.id,pointList:c,textAttribute:"",isRect:!0,valid:(a=o.valid)!=null?a:!0}),P.setResultAndSelectedID(g,e.id)},usePointCloudViews=()=>{const o=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:e,sideViewInstance:i,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:P,setSelectedIDs:d,selectedIDs:c,pointCloudBoxList:g,pointCloudSphereList:h,hideAttributes:m,setHighlight2DDataList:T}=o,{addHistory:b,initHistory:D,pushHistoryUnderUpdatePolygon:I,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{updateSelectedBox:k,updateSelectedBoxes:S,getPointCloudByID:f}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:G,updatePointCloudSphere:H,selectedSphere:M}=useSphere.useSphere(),{currentData:z,config:L}=ctx.useSelector(n=>{const{stepList:s,step:p,imgList:u,imgIndex:r}=n.annotation;return{currentData:u[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),A=ctx.useDispatch(),{selectedBox:w}=useSingleBox.useSingleBox(),{t:Q}=reactI18next.useTranslation(),F=w==null?void 0:w.info;if(!e||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:N}=e,X=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},Y=n=>{t==null||t.generateSphere(n),t==null||t.controls.update(),t==null||t.render()},J=({newPoint:n,size:s,zoom:p,trackConfigurable:u})=>{var r;const C={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};u===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const x=topViewPoint2PointCloud(n,s,N,void 0,C);d(n.id);const y=P(x);E(PointCloudView.Top,n,x,p,y,L),b({newSphereParams:x})},K=({polygon:n,size:s,imgList:p,trackConfigurable:u,zoom:r,intelligentFit:C})=>{var x,y;const v={attribute:(x=e.toolInstance.defaultAttribute)!=null?x:""};u===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:h})});const U=e==null?void 0:e.toolInstance,V=__spreadValues({},n);let{boxParams:B,newPointList:R}=topViewPolygon2PointCloud(V,s,N,void 0,v,C);if(B=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:L,action:"viewUpdateBox"}))[0],(L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(Q("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),U.deletePolygon(B.id);return}C&&(R==null?void 0:R.length)&&(V.pointList=R);const at=m.includes(V.attribute),q=a(B),dt=(y=o==null?void 0:o.polygonList)!=null?y:[];e==null||e.updatePolygonList(q!=null?q:[],dt),at?d([]):(d(B.id),U.selection.setSelectedIDs(V.id),j({omitView:PointCloudView.Top,polygon:V,boxParams:B,zoom:r,newPointCloudBoxList:q}),C&&synchronizeTopView(B,V,e,t)),b({newBoxParams:B})},$=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:u})=>{var r;const C=e==null?void 0:e.toolInstance;if(!(c.length===0||!C)){if(n||(w==null?void 0:w.info)){const x=n!=null?n:w==null?void 0:w.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(c[0]);const y=C.selectedPolygon;if(c.length===1&&x){j({omitView:PointCloudView.Top,polygon:y,boxParams:x,newPointCloudBoxList:s});return}}if((p||M)&&c.length===1){const x=p!=null?p:M;C.setSelectedID(c[0]);const y=C.selectedPoint;x&&E(PointCloudView.Top,y,x,void 0,u,L)}}},Z=(n,s,p)=>{if(F){let u,r;switch(p){case PointCloudView.Back:u=backViewPolygon2PointCloud;break;case PointCloudView.Side:u=sideViewPolygon2PointCloud;break;default:u=sideViewPolygon2PointCloud;break}r=u(n,s,F,i.pointCloudInstance);const x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:L,action:"viewUpdateBox"}))[0],y=r.valid!==x.valid;if(r=x,t){const{count:U}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:U})}const v=k(r);return r=v.find(U=>U.id===r.id),j({omitView:y?void 0:p,polygon:n,boxParams:r,newPointCloudBoxList:v}),v}},W=(n,s,p)=>{if(M){let u,r;switch(p){case PointCloudView.Back:u=backViewPoint2PointCloud;break;case PointCloudView.Side:u=sideViewPoint2PointCloud;break;default:u=sideViewPoint2PointCloud;break}r=u(n,s,M);const C=H(r);return E(p,n,r,void 0,C,L),C}},tt=(n,s)=>{W(n,s,PointCloudView.Side)},ot=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},it=(n,s)=>{Z(n,s,PointCloudView.Back)},nt=(n,s)=>{O(n)},st=(n,s)=>{const p=G(n.id),u=topViewPoint2PointCloud(n,s,N,p),r=H(u);E(PointCloudView.Top,n,u,void 0,r,L)},rt=(n,s)=>{if(_){const u=n[0].newPolygon;u.pointList=u.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,s)),I(n[0].newPolygon);return}let p=n.map(({newPolygon:u})=>{const r=f(u.id),{boxParams:C}=topViewPolygon2PointCloud(u,s,e.pointCloudInstance,r);return C});if(p=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:L,action:"viewUpdateBox"})),p.length===1){const{newPolygon:u}=n[0],r=S(p);j({omitView:PointCloudView.Top,polygon:u,boxParams:p[0],newPointCloudBoxList:r})}else{const u=S(p);u&&o.syncAllViewPointCloudColor(u)}},lt=n=>{var s;if(w){const p=w==null?void 0:w.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(y=>(y==null?void 0:y.trackID)===p),C=__spreadProps(__spreadValues({},w.info),{width:Number(n.widthDefault),depth:Number(n.depthDefault),height:Number(n.heightDefault)}),x=S([C]);j({omitView:PointCloudView["3D"],polygon:r,boxParams:C,newPointCloudBoxList:x})}},E=(n,s,p,u,r,C)=>__async(void 0,null,function*(){const x=z==null?void 0:z.url,y={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,i,x,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(p,s,l,x,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,e,t)}};Object.keys(y).forEach(v=>{v!==n&&y[v]()}),u&&(t==null||t.updateCameraZoom(u)),Y(p)}),j=n=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:u,zoom:r,newPointCloudBoxList:C}=n,x=z==null?void 0:z.url;C&&(yield o.syncAllViewPointCloudColor(C));const y={[PointCloudView.Side]:()=>{synchronizeSideView(u,p,i,x)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(u,p,l,x)},[PointCloudView.Top]:()=>{synchronizeTopView(u,p,e,t)}};Object.keys(y).forEach(v=>{v!==s&&y[v]()}),r&&(t==null||t.updateCameraZoom(r)),X(u)});return{topViewAddSphere:J,topViewAddBox:K,topViewSelectedChanged:$,topViewUpdatePoint:st,sideViewUpdatePoint:tt,backViewUpdatePoint:ot,topViewUpdateBox:rt,topViewUpdateLine:nt,sideViewUpdateBox:et,backViewUpdateBox:it,pointCloudBoxListUpdated:n=>{e.updatePolygonList(n),t==null||t.generateBoxes(n)},initPointCloud3d:n=>{if(!t)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=z){var p,u,r,C,x,y;if(!(s==null?void 0:s.url)||!t)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield t.loadPCDFile(s.url,(p=L==null?void 0:L.radius)!=null?p:DEFAULT_RADIUS),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],U=[],V=[],B=[];t.updateTopCamera();const R=(r=(u=index.jsonParser(s.result))==null?void 0:u.valid)!=null?r:!0;o.setPointCloudValid(R),(C=o.sideViewInstance)==null||C.clearAllData(),(x=o.backViewInstance)==null||x.clearAllData(),e.updateData(s.url,s.result,{radius:(y=L==null?void 0:L.radius)!=null?y:DEFAULT_RADIUS}),s.result&&(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),V=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),U=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(B),yield o.syncAllViewPointCloudColor(v,[])),D({pointCloudBoxList:v,polygonList:V,lineList:U,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:lt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
package/dist/index.css
CHANGED
|
@@ -1366,6 +1366,9 @@
|
|
|
1366
1366
|
border-bottom: 1px solid;
|
|
1367
1367
|
font-size: 14px;
|
|
1368
1368
|
}
|
|
1369
|
+
.bee-point-cloud-wrapper .bee-point-cloud-container__zoom .bee-point-cloud-highlight-view {
|
|
1370
|
+
display: none;
|
|
1371
|
+
}
|
|
1369
1372
|
.bee-point-cloud-wrapper .bee-point-cloud-container__left {
|
|
1370
1373
|
width: 455px;
|
|
1371
1374
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"react";import{EyeFilled as d,EyeInvisibleFilled as p,LoadingOutlined as f}from"@ant-design/icons";var
|
|
1
|
+
import c from"react";import{EyeFilled as d,EyeInvisibleFilled as p,LoadingOutlined as f}from"@ant-design/icons";import{getClassName as u}from"../../../../utils/dom.js";var m=Object.defineProperty,l=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,n=(t,e,r)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,s=(t,e)=>{for(var r in e||(e={}))g.call(e,r)&&n(t,r,e[r]);if(l)for(var r of l(e))_.call(e,r)&&n(t,r,e[r]);return t};const y=({visible:t,style:e,onClick:r,loading:o})=>{const i={background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,fontSize:16,zIndex:101};let a=t?d:p;return o&&(a=f,Object.assign(i,{borderRadius:100})),c.createElement(a,{className:u("point-cloud-highlight-view"),style:s(s({},i),e),onClick:o?()=>{}:r})};export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as J,MathUtils as B,getCuboidFromPointCloudBox as Rt}from"@labelbee/lb-annotation";import{EPerspectiveView as W,PointCloudUtils as I,DEFAULT_SPHERE_PARAMS as Nt}from"@labelbee/lb-utils";import{useContext as Et}from"react";import{PointCloudContext as Ht}from"../PointCloudContext.js";import{useSingleBox as lt}from"./useSingleBox.js";import{useSphere as Ft}from"./useSphere.js";import{useSelector as Zt,useDispatch as Wt}from"../../../store/ctx.js";import Mt from"../../../utils/StepUtils.js";import{jsonParser as dt}from"../../../utils/index.js";import{PreDataProcess as K,SetPointCloudLoading as at,SetLoadPCDFileLoading as ct}from"../../../store/annotation/actionCreators.js";import{message as Gt}from"antd";import{useTranslation as Qt}from"react-i18next";import{useHistory as Xt}from"./useHistory.js";import{usePolygon as Yt}from"./usePolygon.js";var qt=Object.defineProperty,Jt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,ut=Object.getOwnPropertySymbols,$t=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable,pt=(o,e,n)=>e in o?qt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,y=(o,e)=>{for(var n in e||(e={}))$t.call(e,n)&&pt(o,n,e[n]);if(ut)for(var n of ut(e))to.call(e,n)&&pt(o,n,e[n]);return o},k=(o,e)=>Jt(o,Kt(e)),$=(o,e,n)=>new Promise((l,t)=>{var d=u=>{try{a(n.next(u))}catch(P){t(P)}},f=u=>{try{a(n.throw(u))}catch(P){t(P)}},a=u=>u.done?l(u.value):Promise.resolve(u.value).then(d,f);a((n=n.apply(o,e)).next())});const Q=5,X=90,ft=.01,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},tt=(o,e,n,l,t)=>{const{x:d,y:f}=I.transferCanvas2World(o,e),{defaultZ:a}=Nt,u={center:{x:d,y:f,z:a},id:o.id},P=l?y(y({},l),u):k(y({},u),{attribute:"",valid:!0});return t&&Object.assign(P,t),P},ot=(o,e,n,l,t,d)=>{let f=o.pointList.map(h=>I.transferCanvas2World(h,e)),a=0,u=1,P={};if(n){const h=n.getSensesPointZAxisInPolygon(f,void 0,d);d&&h.fittedCoordinates.length>0&&(f=h.fittedCoordinates),a=(h.maxZ+h.minZ)/2,u=h.maxZ-h.minZ,P={count:h.zCount}}const[m,b,E]=f,V=B.getLineCenterPoint([m,E]),A=B.getLineLength(m,b),T=B.getLineLength(b,E),R=B.getRadiusFromQuadrangle(o.pointList);l&&(a=l.center.z,u=l.depth);const z={center:{x:V.x,y:V.y,z:a},width:d?T+ft:T,height:d?A+ft:A,depth:u,rotation:R,id:o.id},j=y(l?y(y({},l),z):k(y({},z),{attribute:"",valid:!0}),P);t&&Object.assign(j,t);const _=f.map(h=>I.transferWorld2Canvas(h,e));return{boxParams:j,newPointList:_}},Ct=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x-l.x,y:n.center.y,z:n.center.z-l.y}})},Pt=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,P]=e.pointList,m=B.getLineCenterPoint([t,f]),b=B.getLineCenterPoint([a,P]),V={x:{x:m.x-b.x,y:m.y-b.y}.x,y:0,z:m.y-b.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,P),_=z-j,{newBoxParams:h}=l.getNewBoxBySideUpdate(V,_,R,n);return h},oo=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x,y:n.center.y-l.x,z:n.center.z-l.y}})},eo=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,P]=e.pointList,m=B.getLineCenterPoint([t,f]),b=B.getLineCenterPoint([a,P]),V={x:{x:m.x-b.x,y:m.y-b.y}.x,y:0,z:m.y-b.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,P),_=z-j;let{newBoxParams:h}=l.getNewBoxByBackUpdate(V,_,R,n);return h},gt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Left);a.setInitCameraPosition(u);const{point2d:P,zoom:m}=a.getSphereSidePoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),P),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},mt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{width:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Left);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxSidePolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},xt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Back);a.setInitCameraPosition(u);const{point2d:P,zoom:m}=a.getSphereBackPoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),P),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},Lt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{height:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Back);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxBackPolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},yt=(o,e,n,l)=>{if(!n||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,W.Top),l.render();const{toolInstance:t,pointCloudInstance:d}=n,{point2d:f}=d.getSphereTopPoint2DCoordinate(o),a=[...t.pointList].map(u=>u.id===e.id?k(y(y({},e),f),{valid:o.valid,textAttribute:"",attribute:o.attribute}):u);t.setResult(a),t.setSelectedID(e.id)},et=(o,e,n,l)=>{var t,d;if(!n||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:f,pointCloudInstance:a}=n,{polygon2d:u}=a.getBoxTopPolygon2DCoordinate(o),P=[...f.polygonList],m=P.find(b=>b.id===e.id);m?(m.pointList=u,m.valid=(t=o.valid)!=null?t:!0):P.push({id:e.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=o.valid)!=null?d:!0}),f.setResultAndSelectedID(P,e.id)},no=()=>{const o=Et(Ht),{topViewInstance:e,sideViewInstance:n,backViewInstance:l,mainViewInstance:t,addPointCloudBox:d,addPointCloudSphere:f,setSelectedIDs:a,selectedIDs:u,pointCloudBoxList:P,pointCloudSphereList:m,hideAttributes:b,setHighlight2DDataList:E}=o,{addHistory:V,initHistory:A,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:R}=Xt(),{selectedPolygon:z}=Yt(),{updateSelectedBox:j,updateSelectedBoxes:_,getPointCloudByID:h}=lt(),{getPointCloudSphereByID:ht,updatePointCloudSphere:nt,selectedSphere:M}=Ft(),{currentData:H,config:w}=Zt(i=>{const{stepList:s,step:p,imgList:c,imgIndex:r}=i.annotation;return{currentData:c[r],config:dt(Mt.getCurrentStepInfo(p,s).config)}}),N=Wt(),{selectedBox:D}=lt(),{t:vt}=Qt(),it=D==null?void 0:D.info;if(!e||!n||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:Y}=e,Bt=i=>{t==null||t.generateBox(i),t==null||t.controls.update(),t==null||t.render()},wt=i=>{t==null||t.generateSphere(i),t==null||t.controls.update(),t==null||t.render()},bt=({newPoint:i,size:s,zoom:p,trackConfigurable:c})=>{var r;const C={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};c===!0&&Object.assign(C,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const g=tt(i,s,Y,void 0,C);a(i.id);const x=f(g);G(L.Top,i,g,p,x,w),V({newSphereParams:g})},St=({polygon:i,size:s,imgList:p,trackConfigurable:c,zoom:r,intelligentFit:C})=>{var g,x;const v={attribute:(g=e.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:I.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:m})});const O=e==null?void 0:e.toolInstance,U=y({},i);let{boxParams:S,newPointList:Z}=ot(U,s,Y,void 0,v,C);if(S=N(K({tool:J.PointCloud,dataList:[S],stepConfig:w,action:"viewUpdateBox"}))[0],(w==null?void 0:w.lowerLimitPointsNumInBox)&&typeof S.count=="number"&&S.count<w.lowerLimitPointsNumInBox){Gt.info(vt("LowerLimitPointsNumInBox",{num:w.lowerLimitPointsNumInBox})),O.deletePolygon(S.id);return}C&&(Z==null?void 0:Z.length)&&(U.pointList=Z);const zt=b.includes(U.attribute),q=d(S),jt=(x=o==null?void 0:o.polygonList)!=null?x:[];e==null||e.updatePolygonList(q!=null?q:[],jt),zt?a([]):(a(S.id),O.selection.setSelectedIDs(U.id),F({omitView:L.Top,polygon:U,boxParams:S,zoom:r,newPointCloudBoxList:q}),C&&et(S,U,e,t)),V({newBoxParams:S})},It=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:p,newSphereList:c})=>{var r;const C=e==null?void 0:e.toolInstance;if(!(u.length===0||!C)){if(i||(D==null?void 0:D.info)){const g=i!=null?i:D==null?void 0:D.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(u[0]);const x=C.selectedPolygon;if(u.length===1&&g){F({omitView:L.Top,polygon:x,boxParams:g,newPointCloudBoxList:s});return}}if((p||M)&&u.length===1){const g=p!=null?p:M;C.setSelectedID(u[0]);const x=C.selectedPoint;g&&G(L.Top,x,g,void 0,c,w)}}},st=(i,s,p)=>{if(it){let c,r;switch(p){case L.Back:c=eo;break;case L.Side:c=Pt;break;default:c=Pt;break}r=c(i,s,it,n.pointCloudInstance);const g=N(K({tool:J.PointCloud,dataList:[r],stepConfig:w,action:"viewUpdateBox"}))[0],x=r.valid!==g.valid;if(r=g,t){const{count:O}=t.getSensesPointZAxisInPolygon(Rt(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=k(y({},r),{count:O})}const v=j(r);return r=v.find(O=>O.id===r.id),F({omitView:x?void 0:p,polygon:i,boxParams:r,newPointCloudBoxList:[r]}),v}},rt=(i,s,p)=>{if(M){let c,r;switch(p){case L.Back:c=oo;break;case L.Side:c=Ct;break;default:c=Ct;break}r=c(i,s,M);const C=nt(r);return G(p,i,r,void 0,C,w),C}},Dt=(i,s)=>{rt(i,s,L.Side)},Vt=(i,s)=>{rt(i,s,L.Back)},_t=(i,s)=>{st(i,s,L.Side)},Ot=(i,s)=>{st(i,s,L.Back)},Ut=(i,s)=>{R(i)},kt=(i,s)=>{const p=ht(i.id),c=tt(i,s,Y,p),r=nt(c);G(L.Top,i,c,void 0,r,w)},At=(i,s)=>{if(z){const c=i[0].newPolygon;c.pointList=c.pointList.map(r=>I.transferCanvas2World(r,s)),T(i[0].newPolygon);return}let p=i.map(({newPolygon:c})=>{const r=h(c.id),{boxParams:C}=ot(c,s,e.pointCloudInstance,r);return C});if(p=N(K({tool:J.PointCloud,dataList:p,stepConfig:w,action:"viewUpdateBox"})),p.length===1){const{newPolygon:c}=i[0],r=_(p);F({omitView:L.Top,polygon:c,boxParams:p[0],newPointCloudBoxList:r})}else{const c=_(p);c&&o.syncAllViewPointCloudColor(c)}},Tt=i=>{var s;if(D){const p=D==null?void 0:D.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(x=>(x==null?void 0:x.trackID)===p),C=k(y({},D.info),{width:Number(i.widthDefault),depth:Number(i.depthDefault),height:Number(i.heightDefault)}),g=_([C]);F({omitView:L["3D"],polygon:r,boxParams:C,newPointCloudBoxList:g})}},G=(i,s,p,c,r,C)=>$(void 0,null,function*(){const g=H==null?void 0:H.url,x={[L.Side]:()=>{gt(p,s,n,g,C)},[L.Back]:()=>{l&&xt(p,s,l,g,C)},[L.Top]:()=>{yt(p,s,e,t)}};Object.keys(x).forEach(v=>{v!==i&&x[v]()}),c&&(t==null||t.updateCameraZoom(c)),wt(p)}),F=i=>$(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:c,zoom:r,newPointCloudBoxList:C}=i,g=H==null?void 0:H.url;C&&(yield o.syncAllViewPointCloudColor(C));const x={[L.Side]:()=>{mt(c,p,n,g)},[L.Back]:()=>{l&&Lt(c,p,l,g)},[L.Top]:()=>{et(c,p,e,t)}};Object.keys(x).forEach(v=>{v!==s&&x[v]()}),r&&(t==null||t.updateCameraZoom(r)),Bt(c)});return{topViewAddSphere:bt,topViewAddBox:St,topViewSelectedChanged:It,topViewUpdatePoint:kt,sideViewUpdatePoint:Dt,backViewUpdatePoint:Vt,topViewUpdateBox:At,topViewUpdateLine:Ut,sideViewUpdateBox:_t,backViewUpdateBox:Ot,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),t==null||t.generateBoxes(i)},initPointCloud3d:i=>{if(!t)return;const s=I.getDefaultOrthographicParams(i);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...i)=>$(void 0,[...i],function*(s=H){var p,c,r,C,g,x;if(!(s==null?void 0:s.url)||!t)return;E([]),at(N,!0),ct(N,!0),yield t.loadPCDFile(s.url,(p=w==null?void 0:w.radius)!=null?p:X),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],O=[],U=[],S=[];t.updateTopCamera();const Z=(r=(c=dt(s.result))==null?void 0:c.valid)!=null?r:!0;o.setPointCloudValid(Z),(C=o.sideViewInstance)==null||C.clearAllData(),(g=o.backViewInstance)==null||g.clearAllData(),e.updateData(s.url,s.result,{radius:(x=w==null?void 0:w.radius)!=null?x:X}),s.result&&(v=I.getBoxParamsFromResultList(s.result),U=I.getPolygonListFromResultList(s.result),O=I.getLineListFromResultList(s.result),S=I.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(S),yield o.syncAllViewPointCloudColor(v,[])),A({pointCloudBoxList:v,polygonList:U,lineList:O,pointCloudSphereList:S}),at(N,!1),ct(N,!1)}),updateViewsByDefaultSize:Tt}};export{xt as syncBackViewByPoint,gt as syncSideViewByPoint,yt as syncTopViewByPoint,Lt as synchronizeBackView,mt as synchronizeSideView,et as synchronizeTopView,tt as topViewPoint2PointCloud,ot as topViewPolygon2PointCloud,no as usePointCloudViews};
|
|
1
|
+
import{EPointCloudName as J,MathUtils as B,getCuboidFromPointCloudBox as Rt}from"@labelbee/lb-annotation";import{EPerspectiveView as W,PointCloudUtils as I,DEFAULT_SPHERE_PARAMS as Nt}from"@labelbee/lb-utils";import{useContext as Et}from"react";import{PointCloudContext as Ht}from"../PointCloudContext.js";import{useSingleBox as lt}from"./useSingleBox.js";import{useSphere as Ft}from"./useSphere.js";import{useSelector as Zt,useDispatch as Wt}from"../../../store/ctx.js";import Mt from"../../../utils/StepUtils.js";import{jsonParser as dt}from"../../../utils/index.js";import{PreDataProcess as K,SetPointCloudLoading as at,SetLoadPCDFileLoading as ct}from"../../../store/annotation/actionCreators.js";import{message as Gt}from"antd";import{useTranslation as Qt}from"react-i18next";import{useHistory as Xt}from"./useHistory.js";import{usePolygon as Yt}from"./usePolygon.js";var qt=Object.defineProperty,Jt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,ut=Object.getOwnPropertySymbols,$t=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable,pt=(o,e,n)=>e in o?qt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,y=(o,e)=>{for(var n in e||(e={}))$t.call(e,n)&&pt(o,n,e[n]);if(ut)for(var n of ut(e))to.call(e,n)&&pt(o,n,e[n]);return o},k=(o,e)=>Jt(o,Kt(e)),$=(o,e,n)=>new Promise((l,t)=>{var d=u=>{try{a(n.next(u))}catch(C){t(C)}},f=u=>{try{a(n.throw(u))}catch(C){t(C)}},a=u=>u.done?l(u.value):Promise.resolve(u.value).then(d,f);a((n=n.apply(o,e)).next())});const Q=5,X=90,ft=.01,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},tt=(o,e,n,l,t)=>{const{x:d,y:f}=I.transferCanvas2World(o,e),{defaultZ:a}=Nt,u={center:{x:d,y:f,z:a},id:o.id},C=l?y(y({},l),u):k(y({},u),{attribute:"",valid:!0});return t&&Object.assign(C,t),C},ot=(o,e,n,l,t,d)=>{let f=o.pointList.map(h=>I.transferCanvas2World(h,e)),a=0,u=1,C={};if(n){const h=n.getSensesPointZAxisInPolygon(f,void 0,d);d&&h.fittedCoordinates.length>0&&(f=h.fittedCoordinates),a=(h.maxZ+h.minZ)/2,u=h.maxZ-h.minZ,C={count:h.zCount}}const[m,b,E]=f,V=B.getLineCenterPoint([m,E]),A=B.getLineLength(m,b),T=B.getLineLength(b,E),R=B.getRadiusFromQuadrangle(o.pointList);l&&(a=l.center.z,u=l.depth);const z={center:{x:V.x,y:V.y,z:a},width:d?T+ft:T,height:d?A+ft:A,depth:u,rotation:R,id:o.id},j=y(l?y(y({},l),z):k(y({},z),{attribute:"",valid:!0}),C);t&&Object.assign(j,t);const _=f.map(h=>I.transferWorld2Canvas(h,e));return{boxParams:j,newPointList:_}},gt=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x-l.x,y:n.center.y,z:n.center.z-l.y}})},Ct=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,C]=e.pointList,m=B.getLineCenterPoint([t,f]),b=B.getLineCenterPoint([a,C]),V={x:{x:m.x-b.x,y:m.y-b.y}.x,y:0,z:m.y-b.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,C),_=z-j,{newBoxParams:h}=l.getNewBoxBySideUpdate(V,_,R,n);return h},oo=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x,y:n.center.y-l.x,z:n.center.z-l.y}})},eo=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,C]=e.pointList,m=B.getLineCenterPoint([t,f]),b=B.getLineCenterPoint([a,C]),V={x:{x:m.x-b.x,y:m.y-b.y}.x,y:0,z:m.y-b.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,C),_=z-j;let{newBoxParams:h}=l.getNewBoxByBackUpdate(V,_,R,n);return h},Pt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Left);a.setInitCameraPosition(u);const{point2d:C,zoom:m}=a.getSphereSidePoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),C),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},mt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{width:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Left);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxSidePolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},xt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Back);a.setInitCameraPosition(u);const{point2d:C,zoom:m}=a.getSphereBackPoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),C),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},Lt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{height:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Back);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxBackPolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},yt=(o,e,n,l)=>{if(!n||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,W.Top),l.render();const{toolInstance:t,pointCloudInstance:d}=n,{point2d:f}=d.getSphereTopPoint2DCoordinate(o),a=[...t.pointList].map(u=>u.id===e.id?k(y(y({},e),f),{valid:o.valid,textAttribute:"",attribute:o.attribute}):u);t.setResult(a),t.setSelectedID(e.id)},et=(o,e,n,l)=>{var t,d;if(!n||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:f,pointCloudInstance:a}=n,{polygon2d:u}=a.getBoxTopPolygon2DCoordinate(o),C=[...f.polygonList],m=C.find(b=>b.id===e.id);m?(m.pointList=u,m.valid=(t=o.valid)!=null?t:!0):C.push({id:e.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=o.valid)!=null?d:!0}),f.setResultAndSelectedID(C,e.id)},no=()=>{const o=Et(Ht),{topViewInstance:e,sideViewInstance:n,backViewInstance:l,mainViewInstance:t,addPointCloudBox:d,addPointCloudSphere:f,setSelectedIDs:a,selectedIDs:u,pointCloudBoxList:C,pointCloudSphereList:m,hideAttributes:b,setHighlight2DDataList:E}=o,{addHistory:V,initHistory:A,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:R}=Xt(),{selectedPolygon:z}=Yt(),{updateSelectedBox:j,updateSelectedBoxes:_,getPointCloudByID:h}=lt(),{getPointCloudSphereByID:ht,updatePointCloudSphere:nt,selectedSphere:M}=Ft(),{currentData:H,config:w}=Zt(i=>{const{stepList:s,step:p,imgList:c,imgIndex:r}=i.annotation;return{currentData:c[r],config:dt(Mt.getCurrentStepInfo(p,s).config)}}),N=Wt(),{selectedBox:D}=lt(),{t:vt}=Qt(),it=D==null?void 0:D.info;if(!e||!n||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:Y}=e,Bt=i=>{t==null||t.generateBox(i),t==null||t.controls.update(),t==null||t.render()},wt=i=>{t==null||t.generateSphere(i),t==null||t.controls.update(),t==null||t.render()},bt=({newPoint:i,size:s,zoom:p,trackConfigurable:c})=>{var r;const g={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};c===!0&&Object.assign(g,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const P=tt(i,s,Y,void 0,g);a(i.id);const x=f(P);G(L.Top,i,P,p,x,w),V({newSphereParams:P})},St=({polygon:i,size:s,imgList:p,trackConfigurable:c,zoom:r,intelligentFit:g})=>{var P,x;const v={attribute:(P=e.toolInstance.defaultAttribute)!=null?P:""};c===!0&&Object.assign(v,{trackID:I.getNextTrackID({imgList:[],extraBoxList:C,extraSphereList:m})});const O=e==null?void 0:e.toolInstance,U=y({},i);let{boxParams:S,newPointList:Z}=ot(U,s,Y,void 0,v,g);if(S=N(K({tool:J.PointCloud,dataList:[S],stepConfig:w,action:"viewUpdateBox"}))[0],(w==null?void 0:w.lowerLimitPointsNumInBox)&&typeof S.count=="number"&&S.count<w.lowerLimitPointsNumInBox){Gt.info(vt("LowerLimitPointsNumInBox",{num:w.lowerLimitPointsNumInBox})),O.deletePolygon(S.id);return}g&&(Z==null?void 0:Z.length)&&(U.pointList=Z);const zt=b.includes(U.attribute),q=d(S),jt=(x=o==null?void 0:o.polygonList)!=null?x:[];e==null||e.updatePolygonList(q!=null?q:[],jt),zt?a([]):(a(S.id),O.selection.setSelectedIDs(U.id),F({omitView:L.Top,polygon:U,boxParams:S,zoom:r,newPointCloudBoxList:q}),g&&et(S,U,e,t)),V({newBoxParams:S})},It=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:p,newSphereList:c})=>{var r;const g=e==null?void 0:e.toolInstance;if(!(u.length===0||!g)){if(i||(D==null?void 0:D.info)){const P=i!=null?i:D==null?void 0:D.info;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(u[0]);const x=g.selectedPolygon;if(u.length===1&&P){F({omitView:L.Top,polygon:x,boxParams:P,newPointCloudBoxList:s});return}}if((p||M)&&u.length===1){const P=p!=null?p:M;g.setSelectedID(u[0]);const x=g.selectedPoint;P&&G(L.Top,x,P,void 0,c,w)}}},st=(i,s,p)=>{if(it){let c,r;switch(p){case L.Back:c=eo;break;case L.Side:c=Ct;break;default:c=Ct;break}r=c(i,s,it,n.pointCloudInstance);const P=N(K({tool:J.PointCloud,dataList:[r],stepConfig:w,action:"viewUpdateBox"}))[0],x=r.valid!==P.valid;if(r=P,t){const{count:O}=t.getSensesPointZAxisInPolygon(Rt(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=k(y({},r),{count:O})}const v=j(r);return r=v.find(O=>O.id===r.id),F({omitView:x?void 0:p,polygon:i,boxParams:r,newPointCloudBoxList:v}),v}},rt=(i,s,p)=>{if(M){let c,r;switch(p){case L.Back:c=oo;break;case L.Side:c=gt;break;default:c=gt;break}r=c(i,s,M);const g=nt(r);return G(p,i,r,void 0,g,w),g}},Dt=(i,s)=>{rt(i,s,L.Side)},Vt=(i,s)=>{rt(i,s,L.Back)},_t=(i,s)=>{st(i,s,L.Side)},Ot=(i,s)=>{st(i,s,L.Back)},Ut=(i,s)=>{R(i)},kt=(i,s)=>{const p=ht(i.id),c=tt(i,s,Y,p),r=nt(c);G(L.Top,i,c,void 0,r,w)},At=(i,s)=>{if(z){const c=i[0].newPolygon;c.pointList=c.pointList.map(r=>I.transferCanvas2World(r,s)),T(i[0].newPolygon);return}let p=i.map(({newPolygon:c})=>{const r=h(c.id),{boxParams:g}=ot(c,s,e.pointCloudInstance,r);return g});if(p=N(K({tool:J.PointCloud,dataList:p,stepConfig:w,action:"viewUpdateBox"})),p.length===1){const{newPolygon:c}=i[0],r=_(p);F({omitView:L.Top,polygon:c,boxParams:p[0],newPointCloudBoxList:r})}else{const c=_(p);c&&o.syncAllViewPointCloudColor(c)}},Tt=i=>{var s;if(D){const p=D==null?void 0:D.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(x=>(x==null?void 0:x.trackID)===p),g=k(y({},D.info),{width:Number(i.widthDefault),depth:Number(i.depthDefault),height:Number(i.heightDefault)}),P=_([g]);F({omitView:L["3D"],polygon:r,boxParams:g,newPointCloudBoxList:P})}},G=(i,s,p,c,r,g)=>$(void 0,null,function*(){const P=H==null?void 0:H.url,x={[L.Side]:()=>{Pt(p,s,n,P,g)},[L.Back]:()=>{l&&xt(p,s,l,P,g)},[L.Top]:()=>{yt(p,s,e,t)}};Object.keys(x).forEach(v=>{v!==i&&x[v]()}),c&&(t==null||t.updateCameraZoom(c)),wt(p)}),F=i=>$(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:c,zoom:r,newPointCloudBoxList:g}=i,P=H==null?void 0:H.url;g&&(yield o.syncAllViewPointCloudColor(g));const x={[L.Side]:()=>{mt(c,p,n,P)},[L.Back]:()=>{l&&Lt(c,p,l,P)},[L.Top]:()=>{et(c,p,e,t)}};Object.keys(x).forEach(v=>{v!==s&&x[v]()}),r&&(t==null||t.updateCameraZoom(r)),Bt(c)});return{topViewAddSphere:bt,topViewAddBox:St,topViewSelectedChanged:It,topViewUpdatePoint:kt,sideViewUpdatePoint:Dt,backViewUpdatePoint:Vt,topViewUpdateBox:At,topViewUpdateLine:Ut,sideViewUpdateBox:_t,backViewUpdateBox:Ot,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),t==null||t.generateBoxes(i)},initPointCloud3d:i=>{if(!t)return;const s=I.getDefaultOrthographicParams(i);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...i)=>$(void 0,[...i],function*(s=H){var p,c,r,g,P,x;if(!(s==null?void 0:s.url)||!t)return;E([]),at(N,!0),ct(N,!0),yield t.loadPCDFile(s.url,(p=w==null?void 0:w.radius)!=null?p:X),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],O=[],U=[],S=[];t.updateTopCamera();const Z=(r=(c=dt(s.result))==null?void 0:c.valid)!=null?r:!0;o.setPointCloudValid(Z),(g=o.sideViewInstance)==null||g.clearAllData(),(P=o.backViewInstance)==null||P.clearAllData(),e.updateData(s.url,s.result,{radius:(x=w==null?void 0:w.radius)!=null?x:X}),s.result&&(v=I.getBoxParamsFromResultList(s.result),U=I.getPolygonListFromResultList(s.result),O=I.getLineListFromResultList(s.result),S=I.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(S),yield o.syncAllViewPointCloudColor(v,[])),A({pointCloudBoxList:v,polygonList:U,lineList:O,pointCloudSphereList:S}),at(N,!1),ct(N,!1)}),updateViewsByDefaultSize:Tt}};export{xt as syncBackViewByPoint,Pt as syncSideViewByPoint,yt as syncTopViewByPoint,Lt as synchronizeBackView,mt as synchronizeSideView,et as synchronizeTopView,tt as topViewPoint2PointCloud,ot as topViewPolygon2PointCloud,no as usePointCloudViews};
|
package/es/index.css
CHANGED
|
@@ -1366,6 +1366,9 @@
|
|
|
1366
1366
|
border-bottom: 1px solid;
|
|
1367
1367
|
font-size: 14px;
|
|
1368
1368
|
}
|
|
1369
|
+
.bee-point-cloud-wrapper .bee-point-cloud-container__zoom .bee-point-cloud-highlight-view {
|
|
1370
|
+
display: none;
|
|
1371
|
+
}
|
|
1369
1372
|
.bee-point-cloud-wrapper .bee-point-cloud-container__left {
|
|
1370
1373
|
width: 455px;
|
|
1371
1374
|
display: flex;
|