@labelbee/lb-components 1.24.0-alpha.62 → 1.24.0-alpha.63
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/_virtual/2DViewWorker.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +2 -0
- package/dist/types/hooks/annotation.d.ts +3 -1
- package/dist/types/views/MainView/sidebar/GeneralOperation/ActionsConfirm.d.ts +3 -0
- package/dist/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
- package/dist/views/MainView/sidebar/GeneralOperation/index.js +1 -1
- package/es/_virtual/2DViewWorker.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
- package/es/views/MainView/sidebar/GeneralOperation/index.js +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
1
|
+
import{PointCloudContext as se}from"./PointCloudContext.js";import{useRotate as ne}from"./hooks/useRotate.js";import{useRotateEdge as ie}from"./hooks/useRotateEdge.js";import{useBoxes as ae}from"./hooks/useBoxes.js";import{useSingleBox as le}from"./hooks/useSingleBox.js";import{useSphere as ue}from"./hooks/useSphere.js";import{useContext as de,useEffect as d}from"react";import{CommonToolUtils as ce,EToolName as b,cTool as pe}from"@labelbee/lb-annotation";import{Modal as me,message as w}from"antd";import{connect as ve}from"react-redux";import{a2MapStateToProps as Pe}from"../../store/annotation/map.js";import{useStatus as we}from"./hooks/useStatus.js";import{usePointCloudViews as ye}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as fe}from"../../store/ctx.js";import{useHistory as he}from"./hooks/useHistory.js";import{useAttribute as be}from"./hooks/useAttribute.js";import{useConfig as Ce}from"./hooks/useConfig.js";import{usePolygon as Se}from"./hooks/usePolygon.js";import{useLine as ge}from"./hooks/useLine.js";import{useUpdatePointCloudColor as ke}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as Ve}from"react-i18next";import{useLatest as A}from"ahooks";var xe=Object.defineProperty,_e=Object.defineProperties,Ie=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable,E=(i,r,n)=>r in i?xe(i,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[r]=n,C=(i,r)=>{for(var n in r||(r={}))Le.call(r,n)&&E(i,n,r[n]);if(T)for(var n of T(r))Be.call(r,n)&&E(i,n,r[n]);return i},S=(i,r)=>_e(i,Ie(r)),Oe=(i,r,n)=>new Promise((g,p)=>{var a=e=>{try{m(n.next(e))}catch(v){p(v)}},y=e=>{try{m(n.throw(e))}catch(v){p(v)}},m=e=>e.done?g(e.value):Promise.resolve(e.value).then(a,y);m((n=n.apply(i,r)).next())});const{EPolygonPattern:je}=pe,Ae=({currentData:i,config:r,checkMode:n,configString:g,imgIndex:p,toolInstanceRef:a,setResourceLoading:y,isBatchSetValid:m})=>{const e=de(se),{changeSelectedBoxValid:v,selectNextBox:D,selectPrevBox:H,updateSelectedBox:K,deleteSelectedPointCloudBoxAndPolygon:N}=le(),{selectedSphere:k,updatePointCloudSphere:R}=ue(),{clearAllResult:V,updatePointCloudPattern:U}=we(),{copySelectedBoxes:z,pasteSelectedBoxes:F,copiedBoxes:Ee}=ae({config:r,currentData:i}),{updateRotate:x}=ne({currentData:i}),{updateRotateEdge:M}=ie({currentData:i}),{updatePointCloudData:f,restorePreResult:_,topViewSelectedChanged:q}=ye({setResourceLoading:y}),{redo:I,undo:L,pushHistoryWithList:G,pushHistoryUnderUpdatePolygon:W,pushHistoryUnderUpdateLine:Y}=he(),{syncThreeViewsAttribute:B}=be(),{syncAllViewsConfig:$,reRenderTopViewRange:J,reRenderTopViewTipScopeList:Q}=Ce(),{selectedPolygon:O}=Se(),{selectedLine:j}=ge(),{t:P}=Ve(),{updatePointCloudColor:X}=ke(y,r),Z=A(i),h=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},ee=(t,o)=>{const{topViewInstance:s,mainViewInstance:l}=e;if(!s)return;const{pointCloud2dOperation:u}=s;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":M(-90);break;case"u":{const c=u.pattern===je.Normal?b.Rect:b.Polygon;U(c);const re={[b.Polygon]:P("PolygonPattern"),[b.Rect]:P("RectPattern")};w.success(P("ChangePatternMsg",{pattern:re[c]})),u.clearActiveStatus(),u.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":m?(me.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){H();break}D(),o.preventDefault();break;case"f":v();break;case"arrowup":h({y:-1});break;case"arrowdown":h({y:1});break;case"arrowleft":h({x:-1});break;case"arrowright":h({x:1});break;case"delete":N(Z.current);break}},te=(t,o)=>{switch(t){case"c":z();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?I():L();break}}},oe=A(t=>{if(!ce.hotkeyFilter(t)||n===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){te(o,t);return}ee(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(u=>oe.current(u))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[g]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{(r==null?void 0:r.tipScopeList)&&Q(r==null?void 0:r.tipScopeList)},[r==null?void 0:r.tipScopeList]),d(()=>{f==null||f()},[p,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[p]),d(()=>{a.current.setAttrChangeTrigger=t=>{var o;(o=e.topViewInstance)==null||o.toolInstance.setAttrChangeTrigger(t)},a.current.setDefaultAttribute=t=>{var o;if(B(t),X(t),O&&W(S(C({},O),{attribute:t})),j&&Y(S(C({},j),{attribute:t})),k){const s=R(S(C({},k),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),q({newSelectedSphere:k,newSphereList:s}))}},a.current.setSubAttribute=(t,o)=>{var s;const l=e.selectedPointCloudBox;if(l){const u=(s=l==null?void 0:l.subAttribute)!=null?s:{};l.subAttribute=S(C({},u),{[t]:o}),K(l),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(l.id),e.mainViewInstance.render())}},a.current.clearResult=t=>Oe(void 0,null,function*(){if(t==null?void 0:t.keepPreResult){try{(yield _==null?void 0:_())||w.error(P("ClearKeepPreAnnotationFailed"))}catch(o){w.error(P("ClearKeepPreAnnotationFailed"))}return}V==null||V()}),a.current.redo=()=>{I()},a.current.undo=()=>{L()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},a.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},a.current.asyncData=t=>{setTimeout(()=>{f==null||f(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),d(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),d(()=>{a.current.history={pushHistory:t=>{G({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||n)return;const s=c=>{B(c)},l=c=>{w.error(c)},u=c=>{w.info(c)};return o.on("syncAttribute",s),o.on("messageError",l),o.on("messageInfo",u),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",l),o.unbind("messageInfo",u)}},[e.topViewInstance]),null};var Te=ve(Pe,null,null,{context:fe})(Ae);export{Te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as J,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as Pt,useCallback as mt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as F}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as xt,generatePointCloudBoxRects as po,resolveFileItemValid as go}from"../../../utils/index.js";import{PreDataProcess as rt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as fo}from"./useHistory.js";import{usePolygon as Co}from"./usePolygon.js";import{useLatest as K}from"ahooks";var Po=Object.defineProperty,mo=Object.defineProperties,ho=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,Lo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Po(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,L=(e,n)=>{for(var t in n||(n={}))xo.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))Lo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>mo(e,ho(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(e,n,t,d,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?L(L({},d),a):A(L({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},dt=(e,n,t,d,p,o)=>{let f=e.pointList.map(S=>O.transferCanvas2World(S,n)),u=0,a=1,h={};if(t){const S=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&S.fittedCoordinates.length>0&&(f=S.fittedCoordinates),u=(S.maxZ+S.minZ)/2,a=S.maxZ-S.minZ,h={count:S.zCount}}const[P,v,T]=f,V=w.getLineCenterPoint([P,T]),D=w.getLineLength(P,v),U=w.getLineLength(v,T),N=w.getRadiusFromQuadrangle(e.pointList);d&&(u=d.center.z,a=d.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+It:U,height:o?D+It:D,depth:a,rotation:N,id:e.id},j=L(d?L(L({},d),z):A(L({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const E=f.map(S=>O.transferWorld2Canvas(S,n));return{boxParams:j,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},St=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,h]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j,{newBoxParams:S}=d.getNewBoxBySideUpdate(V,E,N,t);return S},vo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},yo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,h]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j;let{newBoxParams:S}=d.getNewBoxByBackUpdate(V,E,N,t);return S},Dt=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,J.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,J.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,J.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,J.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,J.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(L(L({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},at=(e,n,t,d)=>{var p,o;if(!t||!d)return;d.generateBox(e),d.setHighlightColor(e.id),d.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),h=[...f.polygonList],P=h.find(v=>v.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},Bo=e=>{const n=Pt(ht),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:P,pointCloudSphereList:v,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:D,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:E,pushHistoryUnderUpdatePolygon:S}=fo(),{selectedPolygon:Ot}=Co(),{getPointCloudSphereByID:At,updatePointCloudSphere:ct,selectedSphere:Q}=ro(),{currentData:H,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:xt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(D),Ut=K(z),zt=mt((s,i)=>{const c=Ut.current,l=i.id;return s.filter(r=>{if(!r)return!1;const m=c.get(r.imageName);return m===void 0?!0:Boolean(m.get(l))})},[]),ot=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=H;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),ut=k==null?void 0:k.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:nt}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:c,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const m=lt(s,i,nt,void 0,r);a(s.id);const C=u(m);W(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ft=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,x;const R={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(R,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})}),t==null||t.toolInstance;const _=L({},s);let{boxParams:B,newPointList:I}=dt(_,i,nt,void 0,R,r);B=M(rt({tool:st.PointCloud,dataList:[B],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(I==null?void 0:I.length)&&(_.pointList=I);const X=T.includes(_.attribute);ot(B);const Y=f(B),it=(C=n==null?void 0:n.polygonList)!=null?C:[];B.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(x=y==null?void 0:y.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(Y!=null?Y:[],it,!1),X?a([]):(a(B.id),r&&at(B,_,t,o)),j({newBoxParams:B})},Ht=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(I=>I.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(I=>I.imageName===c))return;const R=C.rects.map(I=>I.imageName===c?A(L({},I),{width:l,height:g,x:r,y:m}):I),_=A(L({},C),{rects:R}),B=P.map(I=>I.id===i?_:I);return t==null||t.updatePolygonList(B!=null?B:[]),B},Wt=s=>{const{boxID:i,imageName:c}=s,l=P.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==c),r=A(L({},l),{rects:g}),m=P.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(h.length===0||!r)){if(s||(k==null?void 0:k.info)){const m=s!=null?s:k==null?void 0:k.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(h[0]);const C=r.selectedPolygon;if(h.length===1&&m){Z({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Q)&&h.length===1){const m=c!=null?c:Q;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&W(b.Top,C,m,void 0,l,y)}}},pt=(s,i,c,l=F.Default)=>{if(ut){let g,r;switch(c){case b.Back:g=yo;break;case b.Side:g=St;break;default:g=St;break}if(r=g(s,i,ut,d.pointCloudInstance),o){const{count:_}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(L({},r),{count:_})}const C=M(rt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],x=r.valid!==C.valid;r=C;const R=Nt(r);return r=R.find(_=>_.id===r.id),Z({omitView:x?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:R},l),R}},gt=(s,i,c)=>{if(Q){let l,g;switch(c){case b.Back:l=vo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Q);const r=ct(g);return W(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{gt(s,i,b.Side)},Jt=(s,i)=>{gt(s,i,b.Back)},Qt=(s,i)=>{pt(s,i,b.Side,F.Single)},Xt=(s,i)=>{pt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=lt(s,i,nt,c),g=ct(l);W(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=L({},s[0].newPolygon);l.pointList=l.pointList.map(g=>O.transferCanvas2World(g,i)),S(l);return}let c=s.map(({newPolygon:l})=>{const g=jt(l.id),{boxParams:r}=dt(l,i,t.pointCloudInstance,g);return r});if(c=M(rt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Z({polygon:l,boxParams:c[0],newPointCloudBoxList:g},F.Single)}else{const l=et(c);l&&n.syncAllViewPointCloudColor(F.MultiMove,l)}},Kt=s=>{var i,c,l,g,r;if(k){const m=Number(s.widthDefault),C=Number(s.depthDefault),x=Number(s.heightDefault),R=k==null?void 0:k.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===R),I={width:(l=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},G=B.pointList.map(q=>O.transferCanvas2World(q,I)),X=w.getModifiedRectangleCoordinates(G,x,m),Y=X[0],it=X[2],ft=w.getLineCenterPoint([Y,it]),$t=k.info.center.z-k.info.depth/2,Ct=A(L({},k.info),{center:{x:ft.x,y:ft.y,z:$t+C/2},width:m,height:x,depth:C,valid:!0}),to=et([Ct]);Z({omitView:b["3D"],polygon:B,boxParams:Ct,newPointCloudBoxList:to})}},W=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=H==null?void 0:H.url,C={[b.Side]:()=>{Dt(c,i,d,m,r)},[b.Back]:()=>{p&&_t(c,i,p,m,r)},[b.Top]:()=>{kt(c,i,t,o)}};Object.keys(C).forEach(x=>{x!==s&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Z=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=H==null?void 0:H.url;m&&n.syncAllViewPointCloudColor(i,m);const x={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{at(g,l,t,o)}};Object.keys(x).forEach(R=>{R!==c&&x[R]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Z,syncPointCloudPoint:W,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=H){var c,l,g,r,m,C;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(M,!0),vt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:tt,y==null?void 0:y.tipScopeList),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],R=[],_=[],B=[];o.updateTopCamera();const I=go(i.result,i.preResult);if(n.setPointCloudValid(I),(g=n.sideViewInstance)==null||g.clearAllData(),(r=n.backViewInstance)==null||r.clearAllData(),i.result){if(x=O.getBoxParamsFromResultList(i.result),(x==null?void 0:x.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(i.url,y,x);const G=xt(i.result);G[no].result=x,i.result=JSON.stringify(G),n.setPointCloudResult(x)}_=O.getPolygonListFromResultList(i.result),R=O.getLineListFromResultList(i.result),B=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(m=y==null?void 0:y.radius)!=null?m:tt}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(B),yield n.syncAllViewPointCloudColor(F.Default,x,[])}E({pointCloudBoxList:x,polygonList:_,lineList:R,pointCloudSphereList:B}),Lt(M,!1),vt(M,!1),(C=e==null?void 0:e.setResourceLoading)==null||C.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ht,remove2DViewRect:Wt}},bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=Pt(ht),d=K(e),p=K(n);return{syncToPointCloudBoxList:mt(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const v=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let D=a.get(v);D||(D=new Map,a.set(v,D)),D.set(T,V),h.add(v)}),a.size){const P=f.map(v=>{var T;const V=v.id;if(h.has(V)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),D}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,Dt as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,Bo as usePointCloudViews,bo as useSyncRectPositionDimensionToPointCloudList};
|
|
1
|
+
import{EPointCloudName as at,TagUtils as ie,MathUtils as R,getCuboidFromPointCloudBox as se}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as _,POINT_CLOUD_DEFAULT_STEP as tt,DEFAULT_SPHERE_PARAMS as le}from"@labelbee/lb-utils";import{useContext as vt,useCallback as xt}from"react";import{PointCloudContext as yt}from"../PointCloudContext.js";import{useSingleBox as re}from"./useSingleBox.js";import{useSphere as de}from"./useSphere.js";import ae,{pick as ue}from"lodash";import{useSelector as ce,useDispatch as pe}from"../../../store/ctx.js";import ge from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as H}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as Y,generatePointCloudBoxRects as fe,resolveFileItemValid as Bt}from"../../../utils/index.js";import{PreDataProcess as ut,SetAnnotationLoading as et,SetLoadPCDFileLoading as bt}from"../../../store/annotation/actionCreators.js";import{useHistory as Pe}from"./useHistory.js";import{usePolygon as Ce}from"./usePolygon.js";import{useLatest as ot}from"ahooks";var Le=Object.defineProperty,me=Object.defineProperties,he=Object.getOwnPropertyDescriptors,St=Object.getOwnPropertySymbols,ve=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,It=(o,n,e)=>n in o?Le(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,y=(o,n)=>{for(var e in n||(n={}))ve.call(n,e)&&It(o,e,n[e]);if(St)for(var e of St(n))xe.call(n,e)&&It(o,e,n[e]);return o},T=(o,n)=>me(o,he(n)),nt=(o,n,e)=>new Promise((u,g)=>{var t=a=>{try{c(e.next(a))}catch(h){g(h)}},P=a=>{try{c(e.throw(a))}catch(h){g(h)}},c=a=>a.done?u(a.value):Promise.resolve(a.value).then(t,P);c((e=e.apply(o,n)).next())});const it=5,q=90,wt=.01,w={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},ct=(o,n,e,u,g)=>{const{x:t,y:P}=_.transferCanvas2World(o,n),{defaultZ:c}=le,a={center:{x:t,y:P,z:c},id:o.id},h=u?y(y({},u),a):T(y({},a),{attribute:"",valid:!0});return g&&Object.assign(h,g),h},pt=(o,n,e,u,g,t)=>{let P=o.pointList.map(D=>_.transferCanvas2World(D,n)),c=0,a=1,h={};if(e){const D=e.getSensesPointZAxisInPolygon(P,void 0,t);t&&D.fittedCoordinates.length>0&&(P=D.fittedCoordinates),c=(D.maxZ+D.minZ)/2,a=D.maxZ-D.minZ,h={count:D.zCount}}const[L,B,U]=P,A=R.getLineCenterPoint([L,U]),V=R.getLineLength(L,B),z=R.getLineLength(B,U),E=R.getRadiusFromQuadrangle(o.pointList);u&&(c=u.center.z,a=u.depth);const N={center:{x:A.x,y:A.y,z:c},width:t?z+wt:z,height:t?V+wt:V,depth:a,rotation:E,id:o.id},F=y(u?y(y({},u),N):T(y({},N),{attribute:"",valid:!0}),h);g&&Object.assign(F,g);const W=P.map(D=>_.transferWorld2Canvas(D,n));return{boxParams:F,newPointList:W}},Rt=(o,n,e)=>{const u={x:o.x-n.x,y:o.y-n.y};return T(y({},e),{center:{x:e.center.x-u.x,y:e.center.y,z:e.center.z-u.y}})},Dt=(o,n,e,u)=>{const[g,t,P]=o.pointList,[c,a,h]=n.pointList,L=R.getLineCenterPoint([g,P]),B=R.getLineCenterPoint([c,h]),A={x:{x:L.x-B.x,y:L.y-B.y}.x,y:0,z:L.y-B.y},V=R.getLineLength(g,t),z=R.getLineLength(c,a),E=V-z,N=R.getLineLength(t,P),F=R.getLineLength(a,h),W=N-F,{newBoxParams:D}=u.getNewBoxBySideUpdate(A,W,E,e);return D},ye=(o,n,e)=>{const u={x:o.x-n.x,y:o.y-n.y};return T(y({},e),{center:{x:e.center.x,y:e.center.y-u.x,z:e.center.z-u.y}})},Be=(o,n,e,u)=>{const[g,t,P]=o.pointList,[c,a,h]=n.pointList,L=R.getLineCenterPoint([g,P]),B=R.getLineCenterPoint([c,h]),A={x:{x:L.x-B.x,y:L.y-B.y}.x,y:0,z:L.y-B.y},V=R.getLineLength(g,t),z=R.getLineLength(c,a),E=V-z,N=R.getLineLength(t,P),F=R.getLineLength(a,h),W=N-F;let{newBoxParams:D}=u.getNewBoxByBackUpdate(A,W,E,e);return D},_t=(o,n,e,u,g)=>{var t;if(!e)return;const{toolInstance:P,pointCloudInstance:c}=e;c.loadPCDFile(u,(t=g==null?void 0:g.radius)!=null?t:q);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,X.Left);c.setInitCameraPosition(a);const{point2d:h,zoom:L}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=L,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(L),P.setResult([T(y(y({},n),h),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},Vt=(o,n,e,u)=>{if(!e)return;const{pointCloud2dOperation:g,pointCloudInstance:t}=e;t.loadPCDFileByBox(u,o,{width:it,depth:it});const{cameraPositionVector:P}=t.updateOrthoCamera(o,X.Left);t.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=t.getBoxSidePolygon2DCoordinate(o);t.camera.zoom=a,t.camera.updateProjectionMatrix(),t.render(),g.initPosition(),g.zoomChangeOnCenter(a),g.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},At=(o,n,e,u,g)=>{var t;if(!e)return;const{toolInstance:P,pointCloudInstance:c}=e;c.loadPCDFile(u,(t=g==null?void 0:g.radius)!=null?t:q);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,X.Back);c.setInitCameraPosition(a);const{point2d:h,zoom:L}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=L,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(L),P.setResult([T(y(y({},n),h),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},Ot=(o,n,e,u)=>{if(!e)return;const{pointCloud2dOperation:g,pointCloudInstance:t}=e;t.loadPCDFileByBox(u,o,{height:it,depth:it});const{cameraPositionVector:P}=t.updateOrthoCamera(o,X.Back);t.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=t.getBoxBackPolygon2DCoordinate(o);t.camera.zoom=a,t.camera.updateProjectionMatrix(),t.render(),g.initPosition(),g.zoomChangeOnCenter(a),g.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},kt=(o,n,e,u)=>{if(!e||!u)return;u.generateSphere(o),u.updateCameraBySphere(o,X.Top),u.render();const{toolInstance:g,pointCloudInstance:t}=e,{point2d:P}=t.getSphereTopPoint2DCoordinate(o),c=[...g.pointList].map(a=>a.id===n.id?T(y(y({},n),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):a);g.setResult(c),g.setSelectedID(n.id)},gt=(o,n,e,u)=>{var g,t;if(!e||!u)return;u.generateBox(o),u.setHighlightColor(o.id),u.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=e,{polygon2d:a}=c.getBoxTopPolygon2DCoordinate(o),h=[...P.polygonList],L=h.find(B=>B.id===n.id);L?(L.pointList=a,L.valid=(g=o.valid)!=null?g:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(t=o.valid)!=null?t:!0}),P.setResultAndSelectedID(h,n.id)},be=o=>{const n=vt(yt),{topViewInstance:e,sideViewInstance:u,backViewInstance:g,mainViewInstance:t,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:L,pointCloudSphereList:B,hideAttributes:U,setHighlight2DDataList:A,cuboidBoxIn2DView:V,imageSizes:z,history:E,linkageImageNameRectMap:N}=n,{addHistory:F,initHistory:W,pushHistoryUnderUpdatePolygon:D,pushHistoryWithList:Tt}=Pe(),{selectedPolygon:Ut}=Ce(),{getPointCloudSphereByID:zt,updatePointCloudSphere:ft,selectedSphere:K}=de(),{currentData:O,config:v}=ce(s=>{const{stepList:i,step:d,imgList:r,imgIndex:p}=s.annotation;return{currentData:r[p],config:Y(ge.getCurrentStepInfo(d,i).config)}}),M=pe(),Nt=ot(V),jt=ot(N),Et=xt((s,i)=>{const d=jt.current,r=i.id;return s.filter(l=>{if(!l)return!1;const C=d.get(l.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),st=s=>{const{enableAutoMap2DRect:i=!1}=v;if(!Nt.current||i){const{mappingImgList:d=[]}=O;fe({pointCloudBox:s,mappingImgList:d,imageSizes:z},{prepareRectsFn:Et})}},{selectedBox:k,updateSelectedBox:Ft,updateSelectedBoxes:lt,getPointCloudByID:Mt}=re({generateRects:st}),Pt=k==null?void 0:k.info;if(!e||!u||!g)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{},restorePreResult:()=>nt(void 0,null,function*(){return!1})};const{pointCloudInstance:rt}=e,Ht=s=>{t==null||t.generateSphere(s),t==null||t.controls.update(),t==null||t.render()},Wt=({newPoint:s,size:i,zoom:d,trackConfigurable:r})=>{var p;const l={attribute:(p=e.toolInstance.defaultAttribute)!=null?p:""};r===!0&&Object.assign(l,{trackID:_.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:B})});const C=ct(s,i,rt,void 0,l);a(s.id);const f=c(C);J(w.Top,s,C,d,f,v),F({newSphereParams:C})},Zt=({polygon:s,size:i,imgList:d,trackConfigurable:r,zoom:p,intelligentFit:l})=>{var C,f,m;const I={attribute:(C=e.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(I,{trackID:_.getNextTrackID({imgList:[],extraBoxList:L,extraSphereList:B})}),e==null||e.toolInstance;const x=y({},s);let{boxParams:b,newPointList:S}=pt(x,i,rt,void 0,I,l);b=M(ut({tool:at.PointCloud,dataList:[b],stepConfig:v,action:"viewUpdateBox"}))[0],l&&(S==null?void 0:S.length)&&(x.pointList=S);const G=U.includes(x.attribute);st(b);const Z=P(b),dt=(f=n==null?void 0:n.polygonList)!=null?f:[];b.subAttribute=ie.getDefaultResultByConfig((v==null?void 0:v.secondaryAttributeConfigurable)?(m=v==null?void 0:v.inputList)!=null?m:[]:[]),e==null||e.updatePolygonList(Z!=null?Z:[],dt,!1),G?a([]):(a(b.id),l&>(b,x,e,t)),F({newBoxParams:b})},Gt=s=>{const{boxID:i,imageName:d,width:r,height:p,x:l,y:C}=s,f=L.find(S=>S.id===i);if(!(f==null?void 0:f.rects)||!f.rects.find(S=>S.imageName===d))return;const I=f.rects.map(S=>S.imageName===d?T(y({},S),{width:r,height:p,x:l,y:C}):S),x=T(y({},f),{rects:I}),b=L.map(S=>S.id===i?x:S);return e==null||e.updatePolygonList(b!=null?b:[]),b},Jt=s=>{const{boxID:i,imageName:d}=s,r=L.find(f=>f.id===i);if(!(r==null?void 0:r.rects))return;const p=r.rects.filter(f=>f.imageName!==d),l=T(y({},r),{rects:p}),C=L.map(f=>f.id===i?l:f);return e==null||e.updatePolygonList(C!=null?C:[]),C},Qt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:d,newSphereList:r})=>{var p;const l=e==null?void 0:e.toolInstance;if(!(h.length===0||!l)){if(s||(k==null?void 0:k.info)){const C=s!=null?s:k==null?void 0:k.info;(p=l==null?void 0:l.selection)==null||p.setSelectedIDs(h[0]);const f=l.selectedPolygon;if(h.length===1&&C){Q({omitView:w.Top,polygon:f,boxParams:C,newPointCloudBoxList:i});return}}if((d||K)&&h.length===1){const C=d!=null?d:K;l.setSelectedID(h[0]);const f=l.selectedPoint;C&&J(w.Top,f,C,void 0,r,v)}}},Ct=(s,i,d,r=H.Default)=>{if(Pt){let p,l;switch(d){case w.Back:p=Be;break;case w.Side:p=Dt;break;default:p=Dt;break}if(l=p(s,i,Pt,u.pointCloudInstance),t){const{count:x}=t.getSensesPointZAxisInPolygon(se(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=T(y({},l),{count:x})}const f=M(ut({tool:at.PointCloud,dataList:[l],stepConfig:v,action:"viewUpdateBox"}))[0],m=l.valid!==f.valid;l=f;const I=Ft(l);return l=I.find(x=>x.id===l.id),Q({omitView:m?void 0:d,polygon:s,boxParams:l,newPointCloudBoxList:I},r),I}},Lt=(s,i,d)=>{if(K){let r,p;switch(d){case w.Back:r=ye;break;case w.Side:r=Rt;break;default:r=Rt;break}p=r(s,i,K);const l=ft(p);return J(d,s,p,void 0,l,v),l}},Xt=(s,i)=>{Lt(s,i,w.Side)},Yt=(s,i)=>{Lt(s,i,w.Back)},qt=(s,i)=>{Ct(s,i,w.Side,H.Single)},Kt=(s,i)=>{Ct(s,i,w.Back,H.Single)},$t=(s,i)=>{const d=zt(s.id),r=ct(s,i,rt,d),p=ft(r);J(w.Top,s,r,void 0,p,v)},te=(s,i)=>{if(Ut){const r=y({},s[0].newPolygon);r.pointList=r.pointList.map(p=>_.transferCanvas2World(p,i)),D(r);return}let d=s.map(({newPolygon:r})=>{const p=Mt(r.id),{boxParams:l}=pt(r,i,e.pointCloudInstance,p);return l});if(d=M(ut({tool:at.PointCloud,dataList:d,stepConfig:v,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=s[0],p=lt(d);Q({polygon:r,boxParams:d[0],newPointCloudBoxList:p},H.Single)}else{const r=lt(d);r&&n.syncAllViewPointCloudColor(H.MultiMove,r)}},ee=s=>{var i,d,r,p,l;if(k){const C=Number(s.widthDefault),f=Number(s.depthDefault),m=Number(s.heightDefault),I=k==null?void 0:k.info.trackID,b=((i=e==null?void 0:e.toolInstance)==null?void 0:i.polygonList).find($=>($==null?void 0:$.trackID)===I),S={width:(r=(d=e==null?void 0:e.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(l=(p=e==null?void 0:e.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:l.height},j=b.pointList.map($=>_.transferCanvas2World($,S)),G=R.getModifiedRectangleCoordinates(j,m,C),Z=G[0],dt=G[2],mt=R.getLineCenterPoint([Z,dt]),oe=k.info.center.z-k.info.depth/2,ht=T(y({},k.info),{center:{x:mt.x,y:mt.y,z:oe+f/2},width:C,height:m,depth:f,valid:!0}),ne=lt([ht]);Q({omitView:w["3D"],polygon:b,boxParams:ht,newPointCloudBoxList:ne})}},J=(s,i,d,r,p,l)=>nt(void 0,null,function*(){const C=O==null?void 0:O.url,f={[w.Side]:()=>{_t(d,i,u,C,l)},[w.Back]:()=>{g&&At(d,i,g,C,l)},[w.Top]:()=>{kt(d,i,e,t)}};Object.keys(f).forEach(m=>{m!==s&&f[m]()}),r&&(t==null||t.updateCameraZoom(r)),Ht(d)}),Q=(s,i=H.Default)=>{const{omitView:d,polygon:r,boxParams:p,zoom:l,newPointCloudBoxList:C}=s,f=O==null?void 0:O.url;C&&n.syncAllViewPointCloudColor(i,C);const m={[w.Side]:()=>{Vt(p,r,u,f)},[w.Back]:()=>{g&&Ot(p,r,g,f)},[w.Top]:()=>{gt(p,r,e,t)}};Object.keys(m).forEach(I=>{I!==d&&m[I]()}),l&&(t==null||t.updateCameraZoom(l))};return{topViewAddSphere:Wt,topViewAddBox:Zt,topViewSelectedChanged:Qt,topViewUpdatePoint:$t,sideViewUpdatePoint:Xt,backViewUpdatePoint:Yt,topViewUpdateBox:te,sideViewUpdateBox:qt,backViewUpdateBox:Kt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{e.updatePolygonList(s),t==null||t.generateBoxes(s)},initPointCloud3d:s=>{if(!t)return;const i=_.getDefaultOrthographicParams(s);t.initOrthographicCamera(i),t.initRenderer(),t.render()},updatePointCloudData:(...s)=>nt(void 0,[...s],function*(i=O){var d,r,p,l,C,f;if(!(i==null?void 0:i.url)||!t)return;A([]),et(M,!0),bt(M,!0),(d=o==null?void 0:o.setResourceLoading)==null||d.call(o,!0),yield t.loadPCDFile(i.url,(r=v==null?void 0:v.radius)!=null?r:q,v==null?void 0:v.tipScopeList),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let m=[],I=[],x=[],b=[];t.updateTopCamera();const S=Bt(i.result,i.preResult);if(n.setPointCloudValid(S),(p=n.sideViewInstance)==null||p.clearAllData(),(l=n.backViewInstance)==null||l.clearAllData(),i.result){if(m=_.getBoxParamsFromResultList(i.result),(m==null?void 0:m.length)>0&&i.isPreResult&&(v==null?void 0:v.lowerLimitPointsNumInBox)>0){m=yield t==null?void 0:t.filterPreResult(i.url,v,m);const j=Y(i.result);j[tt].result=m,i.result=JSON.stringify(j),n.setPointCloudResult(m)}x=_.getPolygonListFromResultList(i.result),I=_.getLineListFromResultList(i.result),b=_.getSphereParamsFromResultList(i.result),e.updateData(i.url,i.result,{radius:(C=v==null?void 0:v.radius)!=null?C:q}),t==null||t.generateBoxes(m),t==null||t.generateSpheres(b),yield n.syncAllViewPointCloudColor(H.Default,m,[])}W({pointCloudBoxList:m,polygonList:x,lineList:I,pointCloudSphereList:b}),et(M,!1),bt(M,!1),(f=o==null?void 0:o.setResourceLoading)==null||f.call(o,!1)}),restorePreResult:()=>nt(void 0,null,function*(){var s,i,d,r,p,l;if(!(O==null?void 0:O.url)||!t)return!1;const C=(s=Y(O.preResult))==null?void 0:s[tt];if(!C)return!1;const f=Y(O.result||"{}");f[tt]=ae.cloneDeep(C);let m=JSON.stringify(f);const I=O.url;et(M,!0),(i=o==null?void 0:o.setResourceLoading)==null||i.call(o,!0);try{A([]),a(void 0),t.clearAllBox(),t.clearAllSphere();let x=[],b=[],S=[],j=[];if(n.setPointCloudValid(Bt(m,O.preResult)),(d=n.sideViewInstance)==null||d.clearAllData(),(r=n.backViewInstance)==null||r.clearAllData(),x=_.getBoxParamsFromResultList(m),(x==null?void 0:x.length)>0&&(v==null?void 0:v.lowerLimitPointsNumInBox)>0){x=yield t==null?void 0:t.filterPreResult(I,v,x);const Z=Y(m);Z[tt].result=x,m=JSON.stringify(Z),n.setPointCloudResult(x)}S=_.getPolygonListFromResultList(m),b=_.getLineListFromResultList(m),j=_.getSphereParamsFromResultList(m);const{rectList:G}=_.parsePointCloudCurrentResult(m);return n.setPointCloudResult(x),n.setPolygonList(S),n.setLineList(b),n.setPointCloudSphereList(j),n.setRectList(G),e.updateData(I,m,{radius:(p=v==null?void 0:v.radius)!=null?p:q}),t.generateBoxes(x),t.generateSpheres(j),yield n.syncAllViewPointCloudColor(H.Default,x,[]),Tt({pointCloudBoxList:x,polygonList:S,lineList:b,pointCloudSphereList:j}),!0}finally{et(M,!1),(l=o==null?void 0:o.setResourceLoading)==null||l.call(o,!1)}}),updateViewsByDefaultSize:ee,generateRects:st,update2DViewRect:Gt,remove2DViewRect:Jt}},Se=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:e}=vt(yt),u=ot(o),g=ot(n);return{syncToPointCloudBoxList:xt(()=>{const P=u.current,c=g.current;if(c.length===0)return null;const a=new Map,h=new Set;if(c.filter(L=>L.extId!==void 0).forEach(L=>{const B=L.extId,U=L.imageName,A=ue(L,["x","y","width","height"]);let V=a.get(B);V||(V=new Map,a.set(B,V)),V.set(U,A),h.add(B)}),a.size){const L=P.map(B=>{var U;const A=B.id;if(h.has(A)){const V=y({},B);return(U=V.rects)==null||U.forEach(z=>{var E;const N=z.imageName;Object.assign(z,(E=a.get(A))==null?void 0:E.get(N))}),V}return B});return e(L),L}return null},[])}};export{At as syncBackViewByPoint,_t as syncSideViewByPoint,kt as syncTopViewByPoint,Ot as synchronizeBackView,Vt as synchronizeSideView,gt as synchronizeTopView,ct as topViewPoint2PointCloud,pt as topViewPolygon2PointCloud,be as usePointCloudViews,Se as useSyncRectPositionDimensionToPointCloudList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t,{useRef as C,useState as p}from"react";import{Col as E,Popconfirm as y}from"antd";import{useTranslation as i}from"react-i18next";import{prefix as g}from"../../../../constant/index.js";const k={color:"#CCCCCC"},h=({info:e})=>{const{t:r}=i(),l=e.key.startsWith("sure")?t.createElement("div",{key:e.key},`${r("ConfirmTo")}${e.name.slice(0)}\uFF1F`,(e==null?void 0:e.content)?e.content:""):t.createElement("span",null,e.name);return e.confirmExtra?t.createElement("div",null,l,e.confirmExtra):l},f=({icon:e})=>typeof e=="string"?t.createElement("img",{width:23,height:25,src:e}):e,u=({isHover:e,info:r})=>{const l=!!r.forbidOperation,a=r.key===e&&!l;let o={color:a?"#666fff":""};return l&&(o=k),t.createElement("div",{style:{cursor:l?"not-allowed":"default"},onClick:()=>{var c;return(r==null?void 0:r.forbidConfirm)&&!l&&((c=r==null?void 0:r.onClick)==null?void 0:c.call(r))}},t.createElement("div",{className:"icon"},t.createElement(f,{icon:a?r.hoverSvg:r.imgSvg})),t.createElement("div",{className:"toolName",style:o},r.name))},x=({allOperation:e,setBatchSetValid:r,valid:l})=>{const a=C(null),[o,c]=p(null),{t:m}=i(),d=Math.floor(24/e.length),v=n=>n.forbidConfirm?t.createElement(u,{info:n,isHover:o}):r&&n.key==="setValidity"?r({valid:l,isHover:!!o,singleSetQuestionImg:n.onClick}):t.createElement(y,{title:t.createElement(h,{info:n}),placement:"topRight",okText:m("Confirm"),cancelText:m("Cancel"),getPopupContainer:()=>{var s;return(s=a.current)!=null?s:document.body},onConfirm:n.onClick,onVisibleChange:n.onConfirmVisibleChange,overlayClassName:`${g}-pop-confirm`},t.createElement("div",null,t.createElement(u,{info:n,isHover:o})));return t.createElement("div",{className:"generalOperation",ref:a},e.map((n,s)=>t.createElement(E,{span:d,key:s,className:"generalOperation-col"},t.createElement("div",{key:n.key,className:"item",onMouseEnter:()=>{c(n.key)},onMouseLeave:()=>{c(null)}},v(n)))))};export{x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import i,{useState as d,useMemo as I,useCallback as V}from"react";import{Checkbox as D}from"antd";import{connect as S}from"react-redux";import M from"../../../../utils/StepUtils.js";import{jsonParser as v}from"../../../../utils/index.js";import h from"./ActionsConfirm.js";import j from"./useOperationList.js";import{LabelBeeContext as x}from"../../../../store/ctx.js";import F from"../../../../assets/annotation/pointCloudTool/unitAttribute.svg.js";import K from"../../../../assets/annotation/pointCloudTool/unitAttributeForbid.svg.js";import $ from"../../../../assets/annotation/pointCloudTool/unitAttributeHover.svg.js";import{useTranslation as G}from"react-i18next";import N from"../../../../components/pointCloudView/components/UnifyParamsModal/index.js";import{useSingleBox as H}from"../../../../components/pointCloudView/hooks/useSingleBox.js";import{composeResultByToolInstance as q}from"../../../../store/annotation/reducer.js";import{useStatus as z}from"../../../../components/pointCloudView/hooks/useStatus.js";import{POINT_CLOUD_DEFAULT_STEP as J}from"@labelbee/lb-utils";var Q=Object.defineProperty,W=Object.defineProperties,X=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,k=(t,o,e)=>o in t?Q(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,tt=(t,o)=>{for(var e in o||(o={}))Y.call(o,e)&&k(t,e,o[e]);if(w)for(var e of w(o))Z.call(o,e)&&k(t,e,o[e]);return t},ot=(t,o)=>W(t,X(o));const L=t=>{var o,e;const r=M.getCurrentStepInfo((o=t.annotation)==null?void 0:o.step,(e=t.annotation)==null?void 0:e.stepList);return{toolInstance:t.annotation.toolInstance,stepInfo:r,imgList:t.annotation.imgList,imgIndex:t.annotation.imgIndex,stepList:t.annotation.stepList}},et=({toolInstance:t,stepInfo:o,hideValidity:e})=>{const r=j(t),s=v(o==null?void 0:o.config),a=[r.empty];return(o==null?void 0:o.dataSourceStep)===0&&!e&&a.push(r.setValidity),(s==null?void 0:s.copyBackwardResult)&&a.push(r.copyPrevious),i.createElement(h,{allOperation:a})},nt=S(L,null,null,{context:x})(({toolInstance:t,stepInfo:o,imgList:e,stepList:r,imgIndex:s,setBatchSetValid:a})=>{const{t:P}=G(),{selectedBox:c}=H(),u=j(t),[R,g]=d(!1),[T,E]=d([]),[C,m]=d(!1),{isPointCloudDetectionPattern:y,isPointCloudSegmentationPattern:U}=z(),_=v(o.config),l=e==null?void 0:e[s],O=I(()=>{var n;const f=(n=v(l==null?void 0:l.preResult))==null?void 0:n[J];return Boolean(f)},[l==null?void 0:l.preResult])&&y,A=ot(tt({},u.empty),{confirmExtra:O?i.createElement("div",{onClick:n=>n.stopPropagation(),style:{marginTop:8,textAlign:"left",width:"100%"}},i.createElement(D,{checked:C,onChange:n=>m(n.target.checked),style:{marginLeft:0}},P("KeepPreAnnotation"))):void 0,onConfirmVisibleChange:n=>{n&&m(!1)},onClick:()=>{t.clearResult({keepPreResult:O&&C}),m(!1)}});let p=[u.copyPrevious,A,u.setValidity];if(y&&_.trackConfigurable===!0){const n=!c,f={name:P("UnifyParams"),key:"UnifyParams",imgSvg:n?K:F,hoverSvg:$,onClick:()=>{E(q({toolInstance:t,imgList:e,imgIndex:s,stepList:r})),g(!0)},forbidConfirm:!0,forbidOperation:n};p.unshift(f)}const B=V(()=>{g(!1)},[]),b=c==null?void 0:c.info;return U&&(p=p.filter(n=>!["setValidity","copyPrevious"].includes(n.key))),i.createElement(i.Fragment,null,i.createElement(h,{allOperation:p,setBatchSetValid:a,valid:t==null?void 0:t.valid}),i.createElement(N,{id:b==null?void 0:b.trackID,visible:R,onCancel:B,config:_,imgList:T}))});var rt=S(L,null,null,{context:x})(et);export{nt as PointCloudOperation,rt as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.24.0-alpha.
|
|
3
|
+
"version": "1.24.0-alpha.63",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.28.0-alpha.
|
|
47
|
-
"@labelbee/lb-utils": "1.20.0-alpha.
|
|
48
|
-
"@labelbee/wavesurfer": "1.1.
|
|
46
|
+
"@labelbee/lb-annotation": "1.28.0-alpha.33",
|
|
47
|
+
"@labelbee/lb-utils": "1.20.0-alpha.10",
|
|
48
|
+
"@labelbee/wavesurfer": "1.1.1-alpha.1",
|
|
49
49
|
"@types/react-dom": "18.3.1",
|
|
50
50
|
"@types/react-transition-group": "^4.4.9",
|
|
51
51
|
"ahooks": "3.8.5",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"@svgr/rollup": "^8.1.0",
|
|
90
90
|
"@types/diff-match-patch": "^1.0.36",
|
|
91
91
|
"@types/lodash": "^4.14.168",
|
|
92
|
+
"@types/node": "^18.19.130",
|
|
92
93
|
"@types/react": "16.14.62",
|
|
93
94
|
"@types/react-redux": "^7.1.16",
|
|
94
95
|
"@types/react-syntax-highlighter": "^15.5.0",
|