@labelbee/lb-components 1.24.0-alpha.61 → 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.
@@ -1 +1 @@
1
- import{getClassName as u}from"../../utils/dom.js";import{cKeyCode as te,PointCloud as oe}from"@labelbee/lb-annotation";import{PointCloudUtils as y,EPerspectiveView as h}from"@labelbee/lb-utils";import A from"classnames";import o,{useContext as B,useState as L,useRef as ne,useEffect as p,useMemo as ie}from"react";import{PointCloudContainer as le}from"./PointCloudLayout.js";import{PointCloudContext as se}from"./PointCloudContext.js";import{a2MapStateToProps as re}from"../../store/annotation/map.js";import{connect as ae}from"react-redux";import{jsonParser as F}from"../../utils/index.js";import{useSingleBox as H}from"./hooks/useSingleBox.js";import{useSphere as ce}from"./hooks/useSphere.js";import{Switch as de,Tooltip as ue}from"antd";import me from"../../hooks/useSize.js";import{usePointCloudViews as pe}from"./hooks/usePointCloudViews.js";import{useTranslation as U}from"react-i18next";import{LabelBeeContext as we}from"../../store/ctx.js";import ve from"./components/PointCloudSizeSlider/index.js";import fe from"./components/TitleButton/index.js";import{LeftOutlined as Ce}from"@ant-design/icons";import{useToolStyleContext as Ve}from"../../hooks/useToolStyle.js";import{usePointCloudAttribute as ge}from"./hooks/usePointCloudAttribute.js";var Ie=Object.defineProperty,K=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,M=(n,l,s)=>l in n?Ie(n,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[l]=s,he=(n,l)=>{for(var s in l||(l={}))Pe.call(l,s)&&M(n,s,l[s]);if(K)for(var s of K(l))Ee.call(l,s)&&M(n,s,l[s]);return n};const xe=te.default,_e="LABELBEE-POINTCLOUD",x=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),v=({perspectiveView:n})=>{const{isActive:l,setTarget3DView:s}=B(x),f=w=>A({[u("point-cloud-3d-view",w)]:!0,active:l});return o.createElement("span",{onClick:()=>{s(h[n])},className:f(n.toLocaleLowerCase())})},Z=({isEnlarge:n})=>{const{reset3DView:l,followTopView:s}=B(x),{t:f}=U(),w=o.createElement(o.Fragment,null,o.createElement(v,{perspectiveView:"Top"}),o.createElement(v,{perspectiveView:"Front"}),o.createElement(v,{perspectiveView:"Left"}),o.createElement(v,{perspectiveView:"Back"}),o.createElement(v,{perspectiveView:"Right"}),o.createElement(v,{perspectiveView:"LFT"}),o.createElement(v,{perspectiveView:"RBT"})),e=o.createElement(o.Fragment,null,o.createElement(ue,{title:f("CameraFollowTopView")},o.createElement("span",{onClick:()=>{s()},className:u("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{l()},className:u("point-cloud-3d-view","reset")}));return n?o.createElement("div",{className:u("point-cloud-3d-sidebarZoom")},e,w):o.createElement("div",{className:u("point-cloud-3d-sidebar")},w,e)},Se=({currentData:n,config:l,highlightAttribute:s,setResourceLoading:f})=>{var w;const e=B(se),{setIsLargeStatus:j}=e,[q,G]=L(!0),[C,_]=L(!1),V=ne(null),{initPointCloud3d:D,generateRects:J}=pe(),g=me(V),{t:S}=U(),{value:R}=Ve(),{hiddenText:z}=R||{},{updatePointCloudAttribute:Q}=ge(f,l),{updateSelectedBox:W}=H({generateRects:J});p(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(z,e.pointCloudBoxList)},[R]),p(()=>{!e.mainViewInstance||D==null||D(g)},[g]);const{selectedBox:m}=H(),{selectedSphere:E}=ce(),[X,O]=L(!0),T=t=>{var i,r;const a=m==null?void 0:m.info;if(a){const c=he({},a.center);c.x=c.x-.01,c.z=1e3;const d=t===h.Top;(i=e.mainViewInstance)==null||i.updateCameraByBox(a,t,d?c:void 0)}E&&((r=e.mainViewInstance)==null||r.updateCameraBySphere(E,t))},Y=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},$=()=>{var t,i;const r=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;r&&((i=e.mainViewInstance)==null||i.applyCameraTarget(r))};p(()=>{if(V.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&g.width&&(t=new oe({container:V.current,isOrthographicCamera:!0,orthographicParams:y.getDefaultOrthographicParams(g),config:l,hiddenText:z,view:"3DView"}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:O}),e.setMainViewInstance(t))}},[g,n]),p(()=>{var t,i;if(V.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let r=e.mainViewInstance;const a=y.getRectParamsFromResultList(n.result),c=y.getBoxParamsFromResultList(n.result),d=c.find(b=>b.id===e.selectedID);d&&((t=e.topViewInstance)==null||t.updatePolygonList(c,void 0),Q(d.attribute),W(d),e.setSelectedIDs(d.id));const I=F(n.result),P=F(n.preResult);e.setPointCloudValid((i=I==null?void 0:I.valid)!=null?i:P==null?void 0:P.valid),e.setPointCloudResult(c),e.setRectList(a),r.generateBoxes(c)}},[n.result,e.mainViewInstance]),p(()=>{var t,i,r,a,c,d,I;const P=(t=m==null?void 0:m.info)==null?void 0:t.id;if(!X){O(!0);return}if(P!==void 0){T(h.Top);const b=(a=(r=(i=e.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:r.camera.zoom)!=null?a:1;(c=e.mainViewInstance)==null||c.updateCameraZoom(b)}(d=e.mainViewInstance)==null||d.setHighlightColor(P),(I=e.mainViewInstance)==null||I.render()},[(w=m==null?void 0:m.info)==null?void 0:w.id]),p(()=>{var t,i,r,a;if(E){T(h.Top);const c=(r=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?r:1;(a=e.mainViewInstance)==null||a.updateCameraZoom(c)}},[E]),p(()=>(window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k)}),[]);const k=t=>{if(t.keyCode===xe.Esc){_(!1);return}},N=ie(()=>({reset3DView:Y,setTarget3DView:T,isActive:!!m,followTopView:$}),[m,e.mainViewInstance]);p(()=>{var t,i,r;const a=e.pointCloudBoxList.filter(c=>c.attribute===s);(a==null?void 0:a.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(i=e.mainViewInstance)==null||i.highlightBoxes(a)),a.length===0&&((r=e.mainViewInstance)==null||r.clearHighlightBoxesAndRender())},[s,e.mainViewInstance]);const ee=o.createElement(o.Fragment,null,o.createElement(ve,{onChange:t=>{var i;(i=e.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),o.createElement("span",{style:{marginRight:8}},S("ShowArrows")),o.createElement(de,{size:"small",checked:q,onChange:t=>{var i;G(t),(i=e.mainViewInstance)==null||i.setShowDirection(t)}}),C&&o.createElement(x.Provider,{value:N},o.createElement(Z,{isEnlarge:C})));return o.createElement(le,{className:A({[u("point-cloud-3d-container")]:!0,[u("point-cloud-container","zoom")]:C}),title:C?o.createElement("div",{style:{display:"flex",alignItems:"center"}},o.createElement(Ce,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{j(!1),_(!1)}}),S("3DView")):o.createElement(fe,{title:S("3DView"),onClick:()=>{j(!0),_(!0)}}),toolbar:ee},o.createElement("div",{className:u("point-cloud-3d-content")},!C&&o.createElement(x.Provider,{value:N},o.createElement(Z,null)),o.createElement("div",{className:u("point-cloud-3d-view"),id:_e,ref:V})))};var Te=ae(re,null,null,{context:we})(Se);export{Te as default};
1
+ import{getClassName as d}from"../../utils/dom.js";import{cKeyCode as ee,PointCloud as te}from"@labelbee/lb-annotation";import{PointCloudUtils as S,EPerspectiveView as P}from"@labelbee/lb-utils";import O from"classnames";import o,{useContext as T,useState as y,useRef as oe,useEffect as m,useMemo as ne}from"react";import{PointCloudContainer as ie}from"./PointCloudLayout.js";import{PointCloudContext as le}from"./PointCloudContext.js";import{a2MapStateToProps as se}from"../../store/annotation/map.js";import{connect as re}from"react-redux";import{resolveFileItemValid as ae}from"../../utils/index.js";import{useSingleBox as A}from"./hooks/useSingleBox.js";import{useSphere as ce}from"./hooks/useSphere.js";import{Switch as de,Tooltip as ue}from"antd";import me from"../../hooks/useSize.js";import{usePointCloudViews as pe}from"./hooks/usePointCloudViews.js";import{useTranslation as F}from"react-i18next";import{LabelBeeContext as we}from"../../store/ctx.js";import ve from"./components/PointCloudSizeSlider/index.js";import fe from"./components/TitleButton/index.js";import{LeftOutlined as Ce}from"@ant-design/icons";import{useToolStyleContext as Ve}from"../../hooks/useToolStyle.js";import{usePointCloudAttribute as ge}from"./hooks/usePointCloudAttribute.js";var Ie=Object.defineProperty,H=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,U=(n,s,r)=>s in n?Ie(n,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[s]=r,he=(n,s)=>{for(var r in s||(s={}))Pe.call(s,r)&&U(n,r,s[r]);if(H)for(var r of H(s))Ee.call(s,r)&&U(n,r,s[r]);return n};const xe=ee.default,_e="LABELBEE-POINTCLOUD",E=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),w=({perspectiveView:n})=>{const{isActive:s,setTarget3DView:r}=T(E),f=p=>O({[d("point-cloud-3d-view",p)]:!0,active:s});return o.createElement("span",{onClick:()=>{r(P[n])},className:f(n.toLocaleLowerCase())})},K=({isEnlarge:n})=>{const{reset3DView:s,followTopView:r}=T(E),{t:f}=F(),p=o.createElement(o.Fragment,null,o.createElement(w,{perspectiveView:"Top"}),o.createElement(w,{perspectiveView:"Front"}),o.createElement(w,{perspectiveView:"Left"}),o.createElement(w,{perspectiveView:"Back"}),o.createElement(w,{perspectiveView:"Right"}),o.createElement(w,{perspectiveView:"LFT"}),o.createElement(w,{perspectiveView:"RBT"})),e=o.createElement(o.Fragment,null,o.createElement(ue,{title:f("CameraFollowTopView")},o.createElement("span",{onClick:()=>{r()},className:d("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{s()},className:d("point-cloud-3d-view","reset")}));return n?o.createElement("div",{className:d("point-cloud-3d-sidebarZoom")},e,p):o.createElement("div",{className:d("point-cloud-3d-sidebar")},p,e)},Se=({currentData:n,config:s,highlightAttribute:r,setResourceLoading:f})=>{var p;const e=T(le),{setIsLargeStatus:b}=e,[M,Z]=y(!0),[C,h]=y(!1),V=oe(null),{initPointCloud3d:B,generateRects:q}=pe(),g=me(V),{t:x}=F(),{value:L}=Ve(),{hiddenText:j}=L||{},{updatePointCloudAttribute:G}=ge(f,s),{updateSelectedBox:J}=A({generateRects:q});m(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(j,e.pointCloudBoxList)},[L]),m(()=>{!e.mainViewInstance||B==null||B(g)},[g]);const{selectedBox:u}=A(),{selectedSphere:I}=ce(),[Q,D]=y(!0),_=t=>{var i,a;const l=u==null?void 0:u.info;if(l){const c=he({},l.center);c.x=c.x-.01,c.z=1e3;const v=t===P.Top;(i=e.mainViewInstance)==null||i.updateCameraByBox(l,t,v?c:void 0)}I&&((a=e.mainViewInstance)==null||a.updateCameraBySphere(I,t))},W=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},X=()=>{var t,i;const a=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;a&&((i=e.mainViewInstance)==null||i.applyCameraTarget(a))};m(()=>{if(V.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&g.width&&(t=new te({container:V.current,isOrthographicCamera:!0,orthographicParams:S.getDefaultOrthographicParams(g),config:s,hiddenText:j,view:"3DView"}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:D}),e.setMainViewInstance(t))}},[g,n]),m(()=>{var t;if(V.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let i=e.mainViewInstance;const a=S.getRectParamsFromResultList(n.result),l=S.getBoxParamsFromResultList(n.result),c=l.find(v=>v.id===e.selectedID);c&&((t=e.topViewInstance)==null||t.updatePolygonList(l,void 0),G(c.attribute),J(c),e.setSelectedIDs(c.id)),e.setPointCloudValid(ae(n.result,n.preResult)),e.setPointCloudResult(l),e.setRectList(a),i.generateBoxes(l)}},[n.result,e.mainViewInstance]),m(()=>{var t,i,a,l,c,v,k;const N=(t=u==null?void 0:u.info)==null?void 0:t.id;if(!Q){D(!0);return}if(N!==void 0){_(P.Top);const $=(l=(a=(i=e.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(c=e.mainViewInstance)==null||c.updateCameraZoom($)}(v=e.mainViewInstance)==null||v.setHighlightColor(N),(k=e.mainViewInstance)==null||k.render()},[(p=u==null?void 0:u.info)==null?void 0:p.id]),m(()=>{var t,i,a,l;if(I){_(P.Top);const c=(a=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?a:1;(l=e.mainViewInstance)==null||l.updateCameraZoom(c)}},[I]),m(()=>(window.addEventListener("keydown",z),()=>{window.removeEventListener("keydown",z)}),[]);const z=t=>{if(t.keyCode===xe.Esc){h(!1);return}},R=ne(()=>({reset3DView:W,setTarget3DView:_,isActive:!!u,followTopView:X}),[u,e.mainViewInstance]);m(()=>{var t,i,a;const l=e.pointCloudBoxList.filter(c=>c.attribute===r);(l==null?void 0:l.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(i=e.mainViewInstance)==null||i.highlightBoxes(l)),l.length===0&&((a=e.mainViewInstance)==null||a.clearHighlightBoxesAndRender())},[r,e.mainViewInstance]);const Y=o.createElement(o.Fragment,null,o.createElement(ve,{onChange:t=>{var i;(i=e.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),o.createElement("span",{style:{marginRight:8}},x("ShowArrows")),o.createElement(de,{size:"small",checked:M,onChange:t=>{var i;Z(t),(i=e.mainViewInstance)==null||i.setShowDirection(t)}}),C&&o.createElement(E.Provider,{value:R},o.createElement(K,{isEnlarge:C})));return o.createElement(ie,{className:O({[d("point-cloud-3d-container")]:!0,[d("point-cloud-container","zoom")]:C}),title:C?o.createElement("div",{style:{display:"flex",alignItems:"center"}},o.createElement(Ce,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{b(!1),h(!1)}}),x("3DView")):o.createElement(fe,{title:x("3DView"),onClick:()=>{b(!0),h(!0)}}),toolbar:Y},o.createElement("div",{className:d("point-cloud-3d-content")},!C&&o.createElement(E.Provider,{value:R},o.createElement(K,null)),o.createElement("div",{className:d("point-cloud-3d-view"),id:_e,ref:V})))};var Te=re(se,null,null,{context:we})(Se);export{Te as default};
@@ -1 +1 @@
1
- import{PointCloudContext as re}from"./PointCloudContext.js";import{useRotate as se}from"./hooks/useRotate.js";import{useRotateEdge as ne}from"./hooks/useRotateEdge.js";import{useBoxes as ie}from"./hooks/useBoxes.js";import{useSingleBox as ae}from"./hooks/useSingleBox.js";import{useSphere as le}from"./hooks/useSphere.js";import{useContext as ue,useEffect as c}from"react";import{CommonToolUtils as ce,EToolName as v,cTool as de}from"@labelbee/lb-annotation";import{Modal as pe,message as f}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as ve}from"../../store/annotation/map.js";import{useStatus as Pe}from"./hooks/useStatus.js";import{usePointCloudViews as we}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as be}from"../../store/ctx.js";import{useHistory as ye}from"./hooks/useHistory.js";import{useAttribute as fe}from"./hooks/useAttribute.js";import{useConfig as he}from"./hooks/useConfig.js";import{usePolygon as Ce}from"./hooks/usePolygon.js";import{useLine as Se}from"./hooks/useLine.js";import{useUpdatePointCloudColor as ge}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as ke}from"react-i18next";import{useLatest as L}from"ahooks";var Ve=Object.defineProperty,xe=Object.defineProperties,_e=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,O=(i,r,l)=>r in i?Ve(i,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[r]=l,P=(i,r)=>{for(var l in r||(r={}))Ie.call(r,l)&&O(i,l,r[l]);if(B)for(var l of B(r))Le.call(r,l)&&O(i,l,r[l]);return i},w=(i,r)=>xe(i,_e(r));const{EPolygonPattern:Be}=de,Oe=({currentData:i,config:r,checkMode:l,configString:j,imgIndex:h,toolInstanceRef:a,setResourceLoading:C,isBatchSetValid:T})=>{const e=ue(re),{changeSelectedBoxValid:A,selectNextBox:E,selectPrevBox:D,updateSelectedBox:H,deleteSelectedPointCloudBoxAndPolygon:K}=ae(),{selectedSphere:b,updatePointCloudSphere:N}=le(),{clearAllResult:S,updatePointCloudPattern:U}=Pe(),{copySelectedBoxes:z,pasteSelectedBoxes:R,copiedBoxes:Te}=ie({config:r,currentData:i}),{updateRotate:g}=se({currentData:i}),{updateRotateEdge:F}=ne({currentData:i}),{updatePointCloudData:p,topViewSelectedChanged:M}=we({setResourceLoading:C}),{redo:k,undo:V,pushHistoryWithList:q,pushHistoryUnderUpdatePolygon:G,pushHistoryUnderUpdateLine:W}=ye(),{syncThreeViewsAttribute:x}=fe(),{syncAllViewsConfig:Y,reRenderTopViewRange:$,reRenderTopViewTipScopeList:J}=he(),{selectedPolygon:_}=Ce(),{selectedLine:I}=Se(),{t:y}=ke(),{updatePointCloudColor:Q}=ge(C,r),X=L(i),m=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},Z=(t,o)=>{const{topViewInstance:s,mainViewInstance:n}=e;if(!s)return;const{pointCloud2dOperation:u}=s;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":F(-90);break;case"u":{const d=u.pattern===Be.Normal?v.Rect:v.Polygon;U(d);const oe={[v.Polygon]:y("PolygonPattern"),[v.Rect]:y("RectPattern")};f.success(y("ChangePatternMsg",{pattern:oe[d]})),u.clearActiveStatus(),u.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":T?(pe.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){D();break}E(),o.preventDefault();break;case"f":A();break;case"arrowup":m({y:-1});break;case"arrowdown":m({y:1});break;case"arrowleft":m({x:-1});break;case"arrowright":m({x:1});break;case"delete":K(X.current);break}},ee=(t,o)=>{switch(t){case"c":z();break;case"v":R();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?k():V();break}}},te=L(t=>{if(!ce.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){ee(o,t);return}Z(o,t)});return c(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(u=>te.current(u))},[e,e.topViewInstance,e.windowKeydownListenerHook]),c(()=>{Y(r)},[j]),c(()=>{(r==null?void 0:r.radius)&&$(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{(r==null?void 0:r.tipScopeList)&&J(r==null?void 0:r.tipScopeList)},[r==null?void 0:r.tipScopeList]),c(()=>{p==null||p()},[h,e.mainViewInstance]),c(()=>{e.setHideAttributes([])},[h]),c(()=>{a.current.setAttrChangeTrigger=t=>{var o;(o=e.topViewInstance)==null||o.toolInstance.setAttrChangeTrigger(t)},a.current.setDefaultAttribute=t=>{var o;if(x(t),Q(t),_&&G(w(P({},_),{attribute:t})),I&&W(w(P({},I),{attribute:t})),b){const s=N(w(P({},b),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),M({newSelectedSphere:b,newSphereList:s}))}},a.current.setSubAttribute=(t,o)=>{var s;const n=e.selectedPointCloudBox;if(n){const u=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=w(P({},u),{[t]:o}),H(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},a.current.clearResult=()=>{S==null||S()},a.current.redo=()=>{k()},a.current.undo=()=>{V()},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(()=>{p==null||p(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),c(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),c(()=>{a.current.history={pushHistory:t=>{q({pointCloudBoxList:t})},initRecord:()=>{}}},[]),c(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||l)return;const s=d=>{x(d)},n=d=>{f.error(d)},u=d=>{f.info(d)};return o.on("syncAttribute",s),o.on("messageError",n),o.on("messageInfo",u),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",n),o.unbind("messageInfo",u)}},[e.topViewInstance]),null};var je=me(ve,null,null,{context:be})(Oe);export{je as default};
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 rt,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as q,PointCloudUtils as k,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as ht}from"react";import{PointCloudContext as xt}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as lo}from"./useSphere.js";import{pick as ro}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as W}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as tt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,SetAnnotationLoading as vt,SetLoadPCDFileLoading as Lt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as ot}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n)=>{for(var t in n||(n={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(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 et=5,nt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,n,t,d,p)=>{const{x:o,y:f}=k.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?x(x({},d),a):A(x({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},ct=(e,n,t,d,p,o)=>{let f=e.pointList.map(S=>k.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]),R=w.getLineLength(P,v),U=w.getLineLength(v,T),j=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?R+It:R,depth:a,rotation:j,id:e.id},N=x(d?x(x({},d),z):A(x({},z),{attribute:"",valid:!0}),h);p&&Object.assign(N,p);const E=f.map(S=>k.transferWorld2Canvas(S,n));return{boxParams:N,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},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},R=w.getLineLength(p,o),U=w.getLineLength(u,a),j=R-U,z=w.getLineLength(o,f),N=w.getLineLength(a,h),E=z-N,{newBoxParams:S}=d.getNewBoxBySideUpdate(V,E,j,t);return S},vo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},Lo=(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},R=w.getLineLength(p,o),U=w.getLineLength(u,a),j=R-U,z=w.getLineLength(o,f),N=w.getLineLength(a,h),E=z-N;let{newBoxParams:S}=d.getNewBoxByBackUpdate(V,E,j,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:nt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,q.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(x(x({},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:et,depth:et});const{cameraPositionVector:f}=o.updateOrthoCamera(e,q.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:nt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,q.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(x(x({},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:et,depth:et});const{cameraPositionVector:f}=o.updateOrthoCamera(e,q.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)},Ot=(e,n,t,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,q.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(x(x({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ut=(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)},yo=e=>{const n=mt(xt),{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:R,imageSizes:U,history:j,linkageImageNameRectMap:z}=n,{addHistory:N,initHistory:E,pushHistoryUnderUpdatePolygon:S}=go(),{selectedPolygon:kt}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:pt,selectedSphere:K}=lo(),{currentData:Z,config:y}=ao(s=>{const{stepList:i,step:c,imgList:r,imgIndex:g}=s.annotation;return{currentData:r[g],config:tt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=ot(R),Ut=ot(z),zt=ht((s,i)=>{const c=Ut.current,r=i.id;return s.filter(l=>{if(!l)return!1;const m=c.get(l.imageName);return m===void 0?!0:Boolean(m.get(r))})},[]),it=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=Z;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:O,updateSelectedBox:jt,updateSelectedBoxes:st,getPointCloudByID:Nt}=so({generateRects:it}),gt=O==null?void 0:O.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:lt}=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:r})=>{var g;const l={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};r===!0&&Object.assign(l,{trackID:k.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const m=at(s,i,lt,void 0,l);a(s.id);const C=u(m);J(b.Top,s,m,c,C,y),N({newSphereParams:m})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:r,zoom:g,intelligentFit:l})=>{var m,C,D;const _={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};r===!0&&Object.assign(_,{trackID:k.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})}),t==null||t.toolInstance;const L=x({},s);let{boxParams:I,newPointList:B}=ct(L,i,lt,void 0,_,l);I=M(dt({tool:rt.PointCloud,dataList:[I],stepConfig:y,action:"viewUpdateBox"}))[0],l&&(B==null?void 0:B.length)&&(L.pointList=B);const H=T.includes(L.attribute);it(I);const F=f(I),X=(C=n==null?void 0:n.polygonList)!=null?C:[];I.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(D=y==null?void 0:y.inputList)!=null?D:[]:[]),t==null||t.updatePolygonList(F!=null?F:[],X,!1),H?a([]):(a(I.id),l&&ut(I,L,t,o)),N({newBoxParams:I})},Ft=s=>{const{boxID:i,imageName:c,width:r,height:g,x:l,y:m}=s,C=P.find(B=>B.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===c))return;const _=C.rects.map(B=>B.imageName===c?A(x({},B),{width:r,height:g,x:l,y:m}):B),L=A(x({},C),{rects:_}),I=P.map(B=>B.id===i?L:B);return t==null||t.updatePolygonList(I!=null?I:[]),I},Wt=s=>{const{boxID:i,imageName:c}=s,r=P.find(C=>C.id===i);if(!(r==null?void 0:r.rects))return;const g=r.rects.filter(C=>C.imageName!==c),l=A(x({},r),{rects:g}),m=P.map(C=>C.id===i?l:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:r})=>{var g;const l=t==null?void 0:t.toolInstance;if(!(h.length===0||!l)){if(s||(O==null?void 0:O.info)){const m=s!=null?s:O==null?void 0:O.info;(g=l==null?void 0:l.selection)==null||g.setSelectedIDs(h[0]);const C=l.selectedPolygon;if(h.length===1&&m){Q({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||K)&&h.length===1){const m=c!=null?c:K;l.setSelectedID(h[0]);const C=l.selectedPoint;m&&J(b.Top,C,m,void 0,r,y)}}},ft=(s,i,c,r=W.Default)=>{if(gt){let g,l;switch(c){case b.Back:g=Lo;break;case b.Side:g=St;break;default:g=St;break}if(l=g(s,i,gt,d.pointCloudInstance),o){const{count:L}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=A(x({},l),{count:L})}const C=M(dt({tool:rt.PointCloud,dataList:[l],stepConfig:y,action:"viewUpdateBox"}))[0],D=l.valid!==C.valid;l=C;const _=jt(l);return l=_.find(L=>L.id===l.id),Q({omitView:D?void 0:c,polygon:s,boxParams:l,newPointCloudBoxList:_},r),_}},Ct=(s,i,c)=>{if(K){let r,g;switch(c){case b.Back:r=vo;break;case b.Side:r=wt;break;default:r=wt;break}g=r(s,i,K);const l=pt(g);return J(c,s,g,void 0,l,y),l}},Gt=(s,i)=>{Ct(s,i,b.Side)},Jt=(s,i)=>{Ct(s,i,b.Back)},Qt=(s,i)=>{ft(s,i,b.Side,W.Single)},Xt=(s,i)=>{ft(s,i,b.Back,W.Single)},Yt=(s,i)=>{const c=At(s.id),r=at(s,i,lt,c),g=pt(r);J(b.Top,s,r,void 0,g,y)},qt=(s,i)=>{if(kt){const r=x({},s[0].newPolygon);r.pointList=r.pointList.map(g=>k.transferCanvas2World(g,i)),S(r);return}let c=s.map(({newPolygon:r})=>{const g=Nt(r.id),{boxParams:l}=ct(r,i,t.pointCloudInstance,g);return l});if(c=M(dt({tool:rt.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:r}=s[0],g=st(c);Q({polygon:r,boxParams:c[0],newPointCloudBoxList:g},W.Single)}else{const r=st(c);r&&n.syncAllViewPointCloudColor(W.MultiMove,r)}},Kt=s=>{var i,c,r,g,l;if(O){const m=Number(s.widthDefault),C=Number(s.depthDefault),D=Number(s.heightDefault),_=O==null?void 0:O.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find($=>($==null?void 0:$.trackID)===_),B={width:(r=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:r.width,height:(l=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:l.height},G=I.pointList.map($=>k.transferCanvas2World($,B)),H=w.getModifiedRectangleCoordinates(G,D,m),F=H[0],X=H[2],Y=w.getLineCenterPoint([F,X]),$t=O.info.center.z-O.info.depth/2,Pt=A(x({},O.info),{center:{x:Y.x,y:Y.y,z:$t+C/2},width:m,height:D,depth:C,valid:!0}),to=st([Pt]);Q({omitView:b["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:to})}},J=(s,i,c,r,g,l)=>bt(void 0,null,function*(){const m=Z==null?void 0:Z.url,C={[b.Side]:()=>{Dt(c,i,d,m,l)},[b.Back]:()=>{p&&_t(c,i,p,m,l)},[b.Top]:()=>{Ot(c,i,t,o)}};Object.keys(C).forEach(D=>{D!==s&&C[D]()}),r&&(o==null||o.updateCameraZoom(r)),Et(c)}),Q=(s,i=W.Default)=>{const{omitView:c,polygon:r,boxParams:g,zoom:l,newPointCloudBoxList:m}=s,C=Z==null?void 0:Z.url;m&&n.syncAllViewPointCloudColor(i,m);const D={[b.Side]:()=>{Rt(g,r,d,C)},[b.Back]:()=>{p&&Vt(g,r,p,C)},[b.Top]:()=>{ut(g,r,t,o)}};Object.keys(D).forEach(_=>{_!==c&&D[_]()}),l&&(o==null||o.updateCameraZoom(l))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=k.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=Z){var c,r,g,l,m,C,D,_;if(!(i==null?void 0:i.url)||!o)return;V([]),vt(M,!0),Lt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(r=y==null?void 0:y.radius)!=null?r:nt,y==null?void 0:y.tipScopeList),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let L=[],I=[],B=[],G=[];o.updateTopCamera();const H=tt(i.result),F=tt(i.preResult),X=(l=(g=H==null?void 0:H.valid)!=null?g:F==null?void 0:F.valid)!=null?l:!0;if(n.setPointCloudValid(X),(m=n.sideViewInstance)==null||m.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(L=k.getBoxParamsFromResultList(i.result),(L==null?void 0:L.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){L=yield o==null?void 0:o.filterPreResult(i.url,y,L);const Y=tt(i.result);Y[no].result=L,i.result=JSON.stringify(Y),n.setPointCloudResult(L)}B=k.getPolygonListFromResultList(i.result),I=k.getLineListFromResultList(i.result),G=k.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(D=y==null?void 0:y.radius)!=null?D:nt}),o==null||o.generateBoxes(L),o==null||o.generateSpheres(G),yield n.syncAllViewPointCloudColor(W.Default,L,[])}E({pointCloudBoxList:L,polygonList:B,lineList:I,pointCloudSphereList:G}),vt(M,!1),Lt(M,!1),(_=e==null?void 0:e.setResourceLoading)==null||_.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:it,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=ot(e),p=ot(n);return{syncToPointCloudBoxList:ht(()=>{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=ro(P,["x","y","width","height"]);let R=a.get(v);R||(R=new Map,a.set(v,R)),R.set(T,V),h.add(v)}),a.size){const P=f.map(v=>{var T;const V=v.id;if(h.has(V)){const R=x({},v);return(T=R.rects)==null||T.forEach(U=>{var j;const z=U.imageName;Object.assign(U,(j=a.get(V))==null?void 0:j.get(z))}),R}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,Dt as syncSideViewByPoint,Ot as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,yo 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&&gt(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{getClassName as i}from"../../utils/dom.js";import e,{useContext as K,useRef as b,useState as w,useEffect as f}from"react";import O from"./PointCloud3DView.js";import Z from"./PointCloudBackView.js";import Q from"./PointCloudTopView.js";import U from"./PointCloudSideView.js";import $ from"./PointCloud2DView.js";import q from"./PointCloudListener.js";import J from"./PointCloudSegmentListener.js";import X from"./PointCloudSegment.js";import Y from"./PointCloudSegmentStatus.js";import tt from"./PointCloudSegmentToolbar.js";import et from"./PointCloudSegment2DView.js";import{connect as ot}from"react-redux";import{LabelBeeContext as nt,useDispatch as it}from"../../store/ctx.js";import{AnnotatedAttributesPanelFixedLeft as lt,AnnotatedAttributesPanelFixedRight as rt}from"../../views/MainView/toolFooter/AnnotatedAttributes/index.js";import{PointCloudContext as at}from"./PointCloudContext.js";import{PointCloudUtils as st,EPointCloudPattern as ut}from"@labelbee/lb-utils";import{useCustomToolInstance as mt}from"../../hooks/annotation.js";import{jsonParser as dt}from"../../utils/index.js";import{a2MapStateToProps as ct}from"../../store/annotation/map.js";import j from"classnames";import pt from"./components/sideAndBackOverView/index.js";import{SetLoadPCDFileLoading as ft}from"../../store/annotation/actionCreators.js";import x from"../DynamicResizer/DynamicResizer.js";const gt=D=>{const{currentData:u,imgList:y,drawLayerSlot:g,checkMode:l,intelligentFit:I,imgIndex:R,config:A,measureVisible:B,setResourceLoading:L,stepInfo:o,setBatchSetValid:C}=D,t=K(at),{globalPattern:P,setGlobalPattern:k,selectedIDs:h,isLargeStatus:m,setIsLargeStatus:T}=t,N=it(),v=b(null),S=b(null),[_,M]=w(0),[r,E]=w(!1),F=(h==null?void 0:h.length)>0&&r,H=dt(u.result),{toolInstanceRef:s,clearToolInstance:z}=mt({basicInfo:H});if(f(()=>{s.current.setPointCloudGlobalPattern=n=>{n!==P&&(k(n),t.clearAllDetectionInstance(),z())}},[P]),f(()=>{var n;if(ft(N,!0),u){const{boxParamsList:a,polygonList:d,lineList:c,sphereParamsList:p,segmentation:W,rectList:G}=st.parsePointCloudCurrentResult((n=u==null?void 0:u.result)!=null?n:"");t.setPointCloudResult(a),t.setPolygonList(d),t.setLineList(c),t.setPointCloudSphereList(p),t.setRectList(G),t.setSegmentation(W)}},[R]),f(()=>{var n;if(v.current){const a=((n=v.current)==null?void 0:n.offsetHeight)-233;M(a)}},[S.current]),f(()=>{s.current.exportData=()=>[t.pointCloudBoxList,{valid:t.valid}],s.current.exportCustomData=()=>{var n,a,d,c,p;return{resultPolygon:(n=t.polygonList)!=null?n:[],resultLine:(a=t.lineList)!=null?a:[],resultPoint:(d=t.pointCloudSphereList)!=null?d:[],resultRect:(c=t.rectList)!=null?c:[],segmentation:(p=t.segmentation)!=null?p:[]}}},[t.pointCloudBoxList,t.rectList,t.valid,t.polygonList,t.lineList,t.pointCloudSphereList,t.ptSegmentInstance,t.segmentation]),y.length===0)return null;if(P===ut.Segmentation)return e.createElement(e.Fragment,null,e.createElement(J,{checkMode:l,toolInstanceRef:s}),e.createElement(tt,null),e.createElement("div",{className:i("point-cloud-layout")},e.createElement(X,{checkMode:l}),e.createElement(et,null)),e.createElement(Y,{config:A}),g==null?void 0:g({direct:!0}));let V=e.createElement("div",{className:i("point-cloud-container","left-bottom")},e.createElement(Z,{checkMode:l}),e.createElement(U,{checkMode:l}));return r&&(V=e.createElement(pt,{selectAndEnlarge:F,checkMode:l})),e.createElement(e.Fragment,null,e.createElement(q,{checkMode:l,toolInstanceRef:s,setResourceLoading:L,isBatchSetValid:!!C}),e.createElement("div",{className:i("point-cloud-layout"),onContextMenu:n=>n.preventDefault()},e.createElement("div",{className:i("point-cloud-wrapper")},e.createElement(lt,null),e.createElement("div",{className:i("point-cloud-content"),ref:S},e.createElement(x,{direction:"horizontal",localKey:"leftAllViewid:"+(o==null?void 0:o.id)+"taskID:"+(o==null?void 0:o.taskID)+"step:"+(o==null?void 0:o.step)+"type:"+(o==null?void 0:o.type),defaultWidth:360,minLeftWidth:244,minRightWidth:"50%",disabled:m},e.createElement("div",{className:i("point-cloud-container",m?"left-large":"left-noLarge")},e.createElement(O,{setResourceLoading:L}),V),e.createElement("div",{className:j({[i("point-cloud-container","right")]:!0,[i("point-cloud-container","rightZoom")]:r}),ref:v},e.createElement(x,{localKey:"rightAllViewid:"+(o==null?void 0:o.id)+"taskID:"+(o==null?void 0:o.taskID)+"step:"+(o==null?void 0:o.step)+"type:"+(o==null?void 0:o.type),defaultHeight:300,minTopHeight:_,minBottomHeight:160,disabled:m},e.createElement(Q,{drawLayerSlot:g,checkMode:l,intelligentFit:I,setIsEnlargeTopView:E,onExitZoom:()=>{T(!1),E(!1)},isEnlargeTopView:r}),e.createElement("div",{className:j({[i("point-cloud-container",m?"right-bottom-large":"right-bottom-noLarge")]:!r,[i("point-cloud-container","right-bottom-floatLeft")]:r})},e.createElement($,{isEnlargeTopView:r,thumbnailWidth:r?300:455,checkMode:l,measureVisible:B})))))),e.createElement(rt,null))),t.visibleBatchSetValid&&(C==null?void 0:C({valid:t.valid,isModal:!0,visibleModal:t.visibleBatchSetValid,onClose:()=>t.setBatchSetValidModal(!1),singleSetQuestionImg:()=>t.setPointCloudValid(!t.valid)})))};var Ct=ot(ct,null,null,{context:nt})(gt);export{Ct as default};
1
+ import{getClassName as i}from"../../utils/dom.js";import e,{useContext as K,useRef as b,useState as w,useEffect as f}from"react";import O from"./PointCloud3DView.js";import Z from"./PointCloudBackView.js";import Q from"./PointCloudTopView.js";import U from"./PointCloudSideView.js";import $ from"./PointCloud2DView.js";import q from"./PointCloudListener.js";import J from"./PointCloudSegmentListener.js";import X from"./PointCloudSegment.js";import Y from"./PointCloudSegmentStatus.js";import tt from"./PointCloudSegmentToolbar.js";import et from"./PointCloudSegment2DView.js";import{connect as ot}from"react-redux";import{LabelBeeContext as nt,useDispatch as it}from"../../store/ctx.js";import{AnnotatedAttributesPanelFixedLeft as lt,AnnotatedAttributesPanelFixedRight as rt}from"../../views/MainView/toolFooter/AnnotatedAttributes/index.js";import{PointCloudContext as at}from"./PointCloudContext.js";import{PointCloudUtils as st,EPointCloudPattern as ut}from"@labelbee/lb-utils";import{useCustomToolInstance as dt}from"../../hooks/annotation.js";import{jsonParser as mt,resolveFileItemValid as ct}from"../../utils/index.js";import{a2MapStateToProps as pt}from"../../store/annotation/map.js";import j from"classnames";import ft from"./components/sideAndBackOverView/index.js";import{SetLoadPCDFileLoading as gt}from"../../store/annotation/actionCreators.js";import x from"../DynamicResizer/DynamicResizer.js";const Ct=D=>{const{currentData:l,imgList:y,drawLayerSlot:g,checkMode:r,intelligentFit:I,imgIndex:R,config:A,measureVisible:B,setResourceLoading:L,stepInfo:o,setBatchSetValid:C}=D,t=K(at),{globalPattern:P,setGlobalPattern:k,selectedIDs:h,isLargeStatus:d,setIsLargeStatus:T}=t,N=it(),v=b(null),S=b(null),[_,F]=w(0),[a,E]=w(!1),M=(h==null?void 0:h.length)>0&&a,H=mt(l.result),{toolInstanceRef:u,clearToolInstance:z}=dt({basicInfo:H});if(f(()=>{u.current.setPointCloudGlobalPattern=n=>{n!==P&&(k(n),t.clearAllDetectionInstance(),z())}},[P]),f(()=>{var n;if(gt(N,!0),l){const{boxParamsList:s,polygonList:m,lineList:c,sphereParamsList:p,segmentation:W,rectList:G}=st.parsePointCloudCurrentResult((n=l==null?void 0:l.result)!=null?n:"");t.setPointCloudResult(s),t.setPolygonList(m),t.setLineList(c),t.setPointCloudSphereList(p),t.setRectList(G),t.setSegmentation(W),t.setPointCloudValid(ct(l==null?void 0:l.result,l==null?void 0:l.preResult))}},[R]),f(()=>{var n;if(v.current){const s=((n=v.current)==null?void 0:n.offsetHeight)-233;F(s)}},[S.current]),f(()=>{u.current.exportData=()=>[t.pointCloudBoxList,{valid:t.valid}],u.current.exportCustomData=()=>{var n,s,m,c,p;return{resultPolygon:(n=t.polygonList)!=null?n:[],resultLine:(s=t.lineList)!=null?s:[],resultPoint:(m=t.pointCloudSphereList)!=null?m:[],resultRect:(c=t.rectList)!=null?c:[],segmentation:(p=t.segmentation)!=null?p:[]}}},[t.pointCloudBoxList,t.rectList,t.valid,t.polygonList,t.lineList,t.pointCloudSphereList,t.ptSegmentInstance,t.segmentation]),y.length===0)return null;if(P===ut.Segmentation)return e.createElement(e.Fragment,null,e.createElement(J,{checkMode:r,toolInstanceRef:u}),e.createElement(tt,null),e.createElement("div",{className:i("point-cloud-layout")},e.createElement(X,{checkMode:r}),e.createElement(et,null)),e.createElement(Y,{config:A}),g==null?void 0:g({direct:!0}));let V=e.createElement("div",{className:i("point-cloud-container","left-bottom")},e.createElement(Z,{checkMode:r}),e.createElement(U,{checkMode:r}));return a&&(V=e.createElement(ft,{selectAndEnlarge:M,checkMode:r})),e.createElement(e.Fragment,null,e.createElement(q,{checkMode:r,toolInstanceRef:u,setResourceLoading:L,isBatchSetValid:!!C}),e.createElement("div",{className:i("point-cloud-layout"),onContextMenu:n=>n.preventDefault()},e.createElement("div",{className:i("point-cloud-wrapper")},e.createElement(lt,null),e.createElement("div",{className:i("point-cloud-content"),ref:S},e.createElement(x,{direction:"horizontal",localKey:"leftAllViewid:"+(o==null?void 0:o.id)+"taskID:"+(o==null?void 0:o.taskID)+"step:"+(o==null?void 0:o.step)+"type:"+(o==null?void 0:o.type),defaultWidth:360,minLeftWidth:244,minRightWidth:"50%",disabled:d},e.createElement("div",{className:i("point-cloud-container",d?"left-large":"left-noLarge")},e.createElement(O,{setResourceLoading:L}),V),e.createElement("div",{className:j({[i("point-cloud-container","right")]:!0,[i("point-cloud-container","rightZoom")]:a}),ref:v},e.createElement(x,{localKey:"rightAllViewid:"+(o==null?void 0:o.id)+"taskID:"+(o==null?void 0:o.taskID)+"step:"+(o==null?void 0:o.step)+"type:"+(o==null?void 0:o.type),defaultHeight:300,minTopHeight:_,minBottomHeight:160,disabled:d},e.createElement(Q,{drawLayerSlot:g,checkMode:r,intelligentFit:I,setIsEnlargeTopView:E,onExitZoom:()=>{T(!1),E(!1)},isEnlargeTopView:a}),e.createElement("div",{className:j({[i("point-cloud-container",d?"right-bottom-large":"right-bottom-noLarge")]:!a,[i("point-cloud-container","right-bottom-floatLeft")]:a})},e.createElement($,{isEnlargeTopView:a,thumbnailWidth:a?300:455,checkMode:r,measureVisible:B})))))),e.createElement(rt,null))),t.visibleBatchSetValid&&(C==null?void 0:C({valid:t.valid,isModal:!0,visibleModal:t.visibleBatchSetValid,onClose:()=>t.setBatchSetValidModal(!1),singleSetQuestionImg:()=>t.setPointCloudValid(!t.valid)})))};var Pt=ot(pt,null,null,{context:nt})(Ct);export{Pt as default};
@@ -1 +1 @@
1
- import{getFormatSize as Ct}from"../../components/customResizeHook/index.js";import{ESubmitType as W}from"../../constant/index.js";import ht from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as r}from"../Actions.js";import{jsonParser as j}from"../../utils/index.js";import Y from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as pt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as gt,composeResult as J}from"../../utils/data.js";import h from"../../utils/StepUtils.js";import q from"../../utils/ToolUtils.js";import{MathUtils as _t,CommonToolUtils as Ot,AnnotationEngine as bt,ImgUtils as Nt}from"@labelbee/lb-annotation";import{PointCloudUtils as It,i18n as M}from"@labelbee/lb-utils";import{Modal as mt}from"antd";import{message as ft}from"antd/es";import Tt from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as O}from"../../data/enums/ToolType.js";var Ut=Object.defineProperty,Bt=Object.defineProperties,xt=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,Et=(t,e,u)=>e in t?Ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,o=(t,e)=>{for(var u in e||(e={}))wt.call(e,u)&&Et(t,u,e[u]);if(Lt)for(var u of Lt(e))Ft.call(e,u)&&Et(t,u,e[u]);return t},l=(t,e)=>Bt(t,xt(e)),At=(t,e,u)=>new Promise((A,d)=>{var S=f=>{try{E(u.next(f))}catch(y){d(y)}},L=f=>{try{E(u.throw(f))}catch(y){d(y)}},E=f=>f.done?A(f.value):Promise.resolve(f.value).then(S,L);E((u=u.apply(t,e)).next())});const b=(t,e)=>t.find(u=>u.step===e),St={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:"",confirmPageTurning:!1},jt=t=>{const{imgList:e,imgPageSize:u}=t;return Math.ceil(e.length/u)},Dt=(t,e)=>t.reduce((u,A)=>{if(A){const d=A.result;if(j(d)[`step_${e}`])return u+1}return u},0)/t.length,Gt=(t,e)=>{const{step:u,stepList:A}=t,d=h.getCurrentStepInfo(u,A),S=pt.jsonParser(d.config);if(q.isVideoTool(d==null?void 0:d.tool)||q.isAudioTool(d==null?void 0:d.tool)||q.isPointCloudTool(d==null?void 0:d.tool)||[O.LLM,O.NLP,O.LLMMultiWheel].includes(d==null?void 0:d.tool))return;const L=document.getElementById("toolContainer");if(!L)throw"Not exist dom named id-toolContainer";const E=Ct({width:window.innerWidth,height:window.innerHeight}),f=new bt({container:L,toolName:d.tool,size:E,imgNode:e,config:S,style:JSON.parse(ht)});return{toolInstance:f==null?void 0:f.toolInstance,annotationEngine:f}},Mt=(t,e)=>(u,A)=>At(void 0,null,function*(){var d,S;const{stepList:L,step:E}=A().annotation,f=h.currentToolIsVideo(E,L),y=h.currentToolIsPointCloud(E,L),N=[O.LLM,O.LLMMultiWheel].includes((d=h.getCurrentStepInfo(E,L))==null?void 0:d.tool),U=((S=h.getCurrentStepInfo(E,L))==null?void 0:S.tool)===O.NLP,B=h.currentToolIsAudio(E,L);if($(u,!0),yield u(Vt(t)),f){u(kt(t));return}if(y||N||B||U){u(Ht(t));return}u(zt(t,e))}),Vt=t=>(e,u)=>At(void 0,null,function*(){const{getFileData:A,imgList:d}=u().annotation;if(A){const S=yield A(d[t],t);e({type:r.SET_FILE_DATA,payload:{fileData:S,index:t}})}}),kt=t=>e=>{e({type:r.LOAD_FILE_DATA,payload:{nextIndex:t}})},Ht=t=>e=>{$(e,!1),e({type:r.LOAD_FILE_DATA,payload:{nextIndex:t}})},zt=(t,e)=>(u,A)=>{var d;const{toolInstance:S,imgList:L}=A().annotation,E=(d=L==null?void 0:L[t])==null?void 0:d.url;Nt.load(E).then(f=>{$(u,!1),u({type:r.LOAD_FILE_DATA,payload:{imgNode:f,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(u,!1),S==null||S.setErrorImg(),u({type:r.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},Kt=({toolInstance:t,imgList:e,imgIndex:u,stepList:A,step:d=1})=>{var S,L,E,f;const y=((S=e[u])==null?void 0:S.result)||"",[N,U,B]=(L=t==null?void 0:t.exportData())!=null?L:[],V=(f=(E=t==null?void 0:t.exportCustomData)==null?void 0:E.call(t))!=null?f:{},k=gt(y,U),H=J(k,{step:d,stepList:A},{rect:N},V);return e.map((G,z)=>z===u?o(l(o({},G),{result:H}),B):o({},G))},Wt=(t=o({},St),e)=>{var u,A,d,S,L,E,f,y,N,U,B,V,k,H,G,z,Z,Q,tt,et,nt,ot,st,lt,it,rt,ut,at,ct;switch(e.type){case r.INIT_ALL_STATE:return o(o({},t),St);case r.UPDATE_TOOL_INSTANCE:return l(o({},t),{toolInstance:e.payload.toolInstance});case r.UPDATE_IMG_LIST:return l(o({},t),{imgList:e.payload.imgList});case r.CALC_STEP_PROGRESS:{const{imgList:n,step:s}=t,i=Dt(n,s);return l(o({},t),{stepProgress:i})}case r.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:s,step:i,stepList:a,toolInstance:p,onSubmit:c,resultList:m}=t;if(!p||!n[s])return t;const _=((u=n[s])==null?void 0:u.result)||"",[,I,g]=(A=p==null?void 0:p.exportData())!=null?A:[],T=(S=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?S:{},D=gt(_,I),v=J(D,{step:i,stepList:a},{rect:m},T),R=t.imgList.map((C,P)=>{if(P===s){const w=Y.dataCorrection(v,_,i,a);return o(l(o({},C),{result:w}),g)}return C});if(((L=e.payload)==null?void 0:L.submitType)===W.SyncImgList)return l(o({},t),{imgList:R});const x=Dt(R,i);return l(o({},t),{stepProgress:x,imgList:R})}case r.SAVE_RESULT:{const{imgList:n,imgIndex:s,onSave:i}=t;return i==null||i(n[s],s,n),o({},t)}case r.SUBMIT_RESULT:{const{imgList:n,basicIndex:s,resultList:i,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(E=a==null?void 0:a.exportData())!=null?E:[];let m=c;if((p==null?void 0:p.length)>0){const _=(f=p[s])==null?void 0:f.id,I=c.map(g=>l(o({},g),{sourceID:_}));m=Tt.cloneDeep(i).filter(g=>g.sourceID!==_),m.push(...I)}return l(o({},t),{resultList:m,imgList:n})}case r.SET_BASIC_INDEX:{const{toolInstance:n,step:s,imgList:i,imgIndex:a,stepList:p,annotationEngine:c,resultList:m,basicResultList:_}=t;if(!n||!c)return t;const I=e.payload.basicIndex,g=(y=_[I])==null?void 0:y.id,T=j((N=i[a])==null?void 0:N.result),D=(m||[]).filter(w=>w.sourceID===g),v=b(p,s),{dataSourceStep:R,tool:x}=v,C=b(p,R);let P=[];return R&&x&&(P=(U=T[`step_${R}`])==null?void 0:U.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[I]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),ft.info(M.t("NoDependency")))),n==null||n.setResult(D),n==null||n.history.initRecord(D,!0),l(o({},t),{basicIndex:I})}case r.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=e.payload;return l(o({},t),{triggerEventAfterIndexChanged:!!n})}case r.LOAD_FILE_DATA:{const{imgList:n,step:s,toolInstance:i,annotationEngine:a,stepList:p}=t;if(!i)return l(o({},t),{imgIndex:e.payload.nextIndex});const c=h.getCurrentStepInfo(s,p),{nextIndex:m,imgNode:_,nextBasicIndex:I,imgError:g}=e.payload,T=I!=null?I:0,D=j((B=n[m])==null?void 0:B.result),v=D[`step_${c.step}`],R=!v,x={rotate:(V=D.rotate)!=null?V:0,valid:(k=D.valid)!=null?k:!0};_&&g!==!0?a==null||a.setImgNode(_,x):i==null||i.setValid(x.valid);const C=b(p,c.step),{dataSourceStep:P,tool:w}=C,dt=b(p,P),X=P&&w,F=(G=(H=D[`step_${P}`])==null?void 0:H.result)!=null?G:[],K=Y.getInitialResultList(v==null?void 0:v.result,i,C,F,R);a==null||a.launchOperation();const vt=[O.Cuboid,O.ScribbleTool].includes(w);if(X&&((F==null?void 0:F.length)>0?a==null||a.setBasicInfo(dt.tool,F[T]):(a==null||a.setBasicInfo(dt.tool),a==null||a.forbidOperation(),ft.info(M.t("NoDependency")))),c.tool!=="check"&&(vt||X)){const yt=(Z=(z=F[T])==null?void 0:z.id)!=null?Z:"",Pt=X?K.filter(Rt=>Ot.isSameSourceID(Rt.sourceID,yt)):K;(Q=i==null?void 0:i.history)==null||Q.initRecord(K,!0),i==null||i.setResult(Pt)}return l(o({},t),{imgIndex:m,basicIndex:T,basicResultList:F,resultList:K})}case r.UPDATE_ANNOTATION_CONFIG:return l(o({},t),{config:(tt=e.payload.config)!=null?tt:"{}"});case r.SET_TASK_STEP_LIST:{const{stepList:n}=e.payload;return l(o({},t),{stepList:n})}case r.SET_TASK_CONFIG:{const{stepList:n,step:s}=e.payload;return l(o({},t),{stepList:n,step:s})}case r.INIT_TOOL:{const{imgNode:n}=t,s=Gt(t,n);if(s){const{toolInstance:i,annotationEngine:a}=s;return l(o({},t),{toolInstance:i,annotationEngine:a})}return o({},t)}case r.SET_TOOL:{const n=(et=e.payload)==null?void 0:et.instance;return n?l(o({},t),{toolInstance:n}):o({},t)}case r.UPDATE_ON_SUBMIT:return l(o({},t),{onSubmit:e.payload.onSubmit});case r.UPDATE_ON_SAVE:return l(o({},t),{onSave:e.payload.onSave});case r.UPDATE_ON_PAGE_CHANGE:return l(o({},t),{onPageChange:e.payload.onPageChange});case r.SET_PREDICT_RESULT:return l(o({},t),{predictionResult:e.payload.result});case r.SET_PREDICT_RESULT_VISIBLE:return l(o({},t),{predictionResultVisible:e.payload.visible});case r.UPDATE_ON_STEP_CHANGE:return l(o({},t),{onStepChange:e.payload.onStepChange});case r.UPDATE_GET_FILE_DATA:return l(o({},t),{getFileData:e.payload.getFileData});case r.UPDATE_PAGE_SIZE:return l(o({},t),{pageSize:e.payload.pageSize});case r.UPDATE_LOAD_FILE_LIST:return l(o({},t),{loadFileList:e.payload.loadFileList});case r.UPDATE_BEFORE_ROTATE:return l(o({},t),{beforeRotate:e.payload.beforeRotate});case r.UPDATE_PRE_DATA_PROCESS:return l(o({},t),{preDataProcess:e.payload.preDataProcess});case r.UPDATE_IMG_INDEX_BY_EXTERNAL:return l(o({},t),{getImgIndexByExternal:e.payload.getImgIndexByExternal});case r.SKIP_BEFORE_PAGE_TURNING:return l(o({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case r.SET_FILE_DATA:{const{fileData:n,index:s}=e.payload,{imgList:i}=t,a=[...i];return a[s]=o(o({},a[s]),n),l(o({},t),{imgList:a})}case r.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:s}=t;return s&&s()===!1||(nt=n==null?void 0:n.updateRotate)==null||nt.call(n),t}case r.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=t,s=(ot=n==null?void 0:n.valid)!=null?ot:!0;return mt.destroyAll(),mt.confirm({content:M.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!s)},okText:M.t("Confirm"),cancelText:M.t("Cancel")}),t}case r.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:s,imgList:i,step:a,stepList:p}=t;if(!n)return t;if(s===0||s>=i.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const c=i[s-1].result;if(!c)return t;const m=h.getCurrentStepInfo(a,p),_=(st=m==null?void 0:m.step)!=null?st:a,I=(lt=n==null?void 0:n.valid)!=null?lt:!0,g=Y.copyResultChange({copyResult:c,step:_,currentResult:(it=i[s].result)!=null?it:"",preMappingImgList:(rt=i[s-1].mappingImgList)!=null?rt:[],mappingImgList:(ut=i[s].mappingImgList)!=null?ut:[],valid:I});i[s]=l(o({},i[s]),{result:g});const D=j(g)[`step_${a}`],v=(D==null?void 0:D.result)||[];return n==null||n.setResult(v),n==null||n.history.pushHistory(v),(at=n==null?void 0:n.asyncData)==null||at.call(n,i[s]),l(o({},t),{imgList:[...i]})}case r.SET_STEP:{const{stepList:n,annotationEngine:s}=t,{toStep:i}=e.payload;if(s){const a=b(n,i);return s==null||s.setToolName(a.tool,a.config),l(o({},t),{step:i,toolInstance:s==null?void 0:s.toolInstance})}return l(o({},t),{step:i})}case r.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=e.payload;return l(o({},t),{loadPCDFileLoading:!!n})}case r.SET_LOADING:{const{loading:n}=e.payload;return l(o({},t),{loading:!!n})}case r.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=e.payload;return l(o({},t),{pointCloudLoading:!!n})}case r.SET_CHECK_MODE:{const{checkMode:n}=e.payload;return l(o({},t),{checkMode:!!n})}case r.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=e.payload;return l(o({},t),{highlightAttribute:n})}case r.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:s,rangeIndex:i,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,m=[],_=a.map((I,g)=>{if(_t.isInRange(g,i)){const T=l(o({},I),{result:It.batchUpdateTrackID({id:n,newID:s,result:I.result})});return m.push({imgIndex:g,newInfo:T}),T}return I});return c&&c([_[p]],W.BatchUpdateTrackID,p,_,{updateImgList:m}),l(o({},t),{imgList:_})}case r.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const n=e,{id:s,newData:i,rangeIndex:a,imgList:p}=n.payload,{imgIndex:c,onSubmit:m}=t,_=[],I=p.map((g,T)=>{if(_t.isInRange(T,a)){const D=l(o({},g),{result:It.batchUpdateResultByTrackID({id:s,newData:i,result:g.result})});return _.push({imgIndex:T,newInfo:D}),D}return g});return m&&m([I[c]],W.BatchUpdateTrackID,c,I,{updateImgList:_}),l(o({},t),{imgList:I})}case r.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:s,stepList:i,step:a,predictionResult:p}=t,c={};p.forEach(g=>{const{index:T}=g;c[T]=Tt.pick(g,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const m=`step_${a}`,_=[],I=s.map((g,T)=>{if(c[T]){const D=g.result==="{}"?j(J("",{step:a,stepList:i},{rect:[]},{})):j(g.result);D[m].result.push(c[T]);const v=l(o({},g),{result:JSON.stringify(D)});return _.push({imgIndex:T,newInfo:v}),v}return g});return n==null||n(I,W.BatchUpdateImgList,-1,I,{updateImgList:_}),l(o({},t),{imgList:I})}case r.CHANGE_PAGE_CHECK:{const{toolInstance:n,step:s,stepList:i}=t;if(!n)return t;const[a]=(ct=n==null?void 0:n.exportData())!=null?ct:[],p=b(i,s),c=pt.jsonParser(p.config),m=a.some(_=>(_==null?void 0:_.result)&&Object.keys(_.result).length>0);return l(o({},t),{confirmPageTurning:c.showConfirm&&!m})}default:return t}};export{Mt as LoadFileAndFileData,Wt as annotationReducer,Kt as composeResultByToolInstance,b as getStepConfig,jt as getTotalPage};
1
+ import{getFormatSize as ht}from"../../components/customResizeHook/index.js";import{ESubmitType as W}from"../../constant/index.js";import Ot from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as r}from"../Actions.js";import{jsonParser as j,resolveFileItemValid as bt}from"../../utils/index.js";import Y from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as gt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as _t,composeResult as J}from"../../utils/data.js";import h from"../../utils/StepUtils.js";import q from"../../utils/ToolUtils.js";import{MathUtils as It,CommonToolUtils as Nt,AnnotationEngine as Ut,ImgUtils as Bt}from"@labelbee/lb-annotation";import{PointCloudUtils as mt,i18n as M}from"@labelbee/lb-utils";import{Modal as ft}from"antd";import{message as Tt}from"antd/es";import Lt from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as O}from"../../data/enums/ToolType.js";var xt=Object.defineProperty,wt=Object.defineProperties,Ft=Object.getOwnPropertyDescriptors,Et=Object.getOwnPropertySymbols,jt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,At=(t,n,u)=>n in t?xt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[n]=u,o=(t,n)=>{for(var u in n||(n={}))jt.call(n,u)&&At(t,u,n[u]);if(Et)for(var u of Et(n))Gt.call(n,u)&&At(t,u,n[u]);return t},s=(t,n)=>wt(t,Ft(n)),St=(t,n,u)=>new Promise((A,d)=>{var S=f=>{try{E(u.next(f))}catch(y){d(y)}},L=f=>{try{E(u.throw(f))}catch(y){d(y)}},E=f=>f.done?A(f.value):Promise.resolve(f.value).then(S,L);E((u=u.apply(t,n)).next())});const b=(t,n)=>t.find(u=>u.step===n),Dt={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:"",confirmPageTurning:!1},Mt=t=>{const{imgList:n,imgPageSize:u}=t;return Math.ceil(n.length/u)},vt=(t,n)=>t.reduce((u,A)=>{if(A){const d=A.result;if(j(d)[`step_${n}`])return u+1}return u},0)/t.length,Vt=(t,n)=>{const{step:u,stepList:A}=t,d=h.getCurrentStepInfo(u,A),S=gt.jsonParser(d.config);if(q.isVideoTool(d==null?void 0:d.tool)||q.isAudioTool(d==null?void 0:d.tool)||q.isPointCloudTool(d==null?void 0:d.tool)||[O.LLM,O.NLP,O.LLMMultiWheel].includes(d==null?void 0:d.tool))return;const L=document.getElementById("toolContainer");if(!L)throw"Not exist dom named id-toolContainer";const E=ht({width:window.innerWidth,height:window.innerHeight}),f=new Ut({container:L,toolName:d.tool,size:E,imgNode:n,config:S,style:JSON.parse(Ot)});return{toolInstance:f==null?void 0:f.toolInstance,annotationEngine:f}},kt=(t,n)=>(u,A)=>St(void 0,null,function*(){var d,S;const{stepList:L,step:E}=A().annotation,f=h.currentToolIsVideo(E,L),y=h.currentToolIsPointCloud(E,L),N=[O.LLM,O.LLMMultiWheel].includes((d=h.getCurrentStepInfo(E,L))==null?void 0:d.tool),U=((S=h.getCurrentStepInfo(E,L))==null?void 0:S.tool)===O.NLP,B=h.currentToolIsAudio(E,L);if($(u,!0),yield u(Ht(t)),f){u(zt(t));return}if(y||N||B||U){u(Kt(t));return}u(Wt(t,n))}),Ht=t=>(n,u)=>St(void 0,null,function*(){const{getFileData:A,imgList:d}=u().annotation;if(A){const S=yield A(d[t],t);n({type:r.SET_FILE_DATA,payload:{fileData:S,index:t}})}}),zt=t=>n=>{n({type:r.LOAD_FILE_DATA,payload:{nextIndex:t}})},Kt=t=>n=>{$(n,!1),n({type:r.LOAD_FILE_DATA,payload:{nextIndex:t}})},Wt=(t,n)=>(u,A)=>{var d;const{toolInstance:S,imgList:L}=A().annotation,E=(d=L==null?void 0:L[t])==null?void 0:d.url;Bt.load(E).then(f=>{$(u,!1),u({type:r.LOAD_FILE_DATA,payload:{imgNode:f,nextIndex:t,nextBasicIndex:n}})}).catch(()=>{$(u,!1),S==null||S.setErrorImg(),u({type:r.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:n}})})},$t=({toolInstance:t,imgList:n,imgIndex:u,stepList:A,step:d=1})=>{var S,L,E,f;const y=((S=n[u])==null?void 0:S.result)||"",[N,U,B]=(L=t==null?void 0:t.exportData())!=null?L:[],V=(f=(E=t==null?void 0:t.exportCustomData)==null?void 0:E.call(t))!=null?f:{},k=_t(y,U),H=J(k,{step:d,stepList:A},{rect:N},V);return n.map((G,z)=>z===u?o(s(o({},G),{result:H}),B):o({},G))},Xt=(t=o({},Dt),n)=>{var u,A,d,S,L,E,f,y,N,U,B,V,k,H,G,z,Z,Q,tt,et,nt,ot,lt,st,it,rt,ut,at,ct,dt;switch(n.type){case r.INIT_ALL_STATE:return o(o({},t),Dt);case r.UPDATE_TOOL_INSTANCE:return s(o({},t),{toolInstance:n.payload.toolInstance});case r.UPDATE_IMG_LIST:return s(o({},t),{imgList:n.payload.imgList});case r.CALC_STEP_PROGRESS:{const{imgList:e,step:l}=t,i=vt(e,l);return s(o({},t),{stepProgress:i})}case r.SUBMIT_FILE_DATA:{const{imgList:e,imgIndex:l,step:i,stepList:a,toolInstance:p,onSubmit:c,resultList:I}=t;if(!p||!e[l])return t;const _=((u=e[l])==null?void 0:u.result)||"",[,m,g]=(A=p==null?void 0:p.exportData())!=null?A:[],T=(S=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?S:{},D=_t(_,m),v=J(D,{step:i,stepList:a},{rect:I},T),R=t.imgList.map((C,P)=>{if(P===l){const w=Y.dataCorrection(v,_,i,a);return o(s(o({},C),{result:w}),g)}return C});if(((L=n.payload)==null?void 0:L.submitType)===W.SyncImgList)return s(o({},t),{imgList:R});const x=vt(R,i);return s(o({},t),{stepProgress:x,imgList:R})}case r.SAVE_RESULT:{const{imgList:e,imgIndex:l,onSave:i}=t;return i==null||i(e[l],l,e),o({},t)}case r.SUBMIT_RESULT:{const{imgList:e,basicIndex:l,resultList:i,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(E=a==null?void 0:a.exportData())!=null?E:[];let I=c;if((p==null?void 0:p.length)>0){const _=(f=p[l])==null?void 0:f.id,m=c.map(g=>s(o({},g),{sourceID:_}));I=Lt.cloneDeep(i).filter(g=>g.sourceID!==_),I.push(...m)}return s(o({},t),{resultList:I,imgList:e})}case r.SET_BASIC_INDEX:{const{toolInstance:e,step:l,imgList:i,imgIndex:a,stepList:p,annotationEngine:c,resultList:I,basicResultList:_}=t;if(!e||!c)return t;const m=n.payload.basicIndex,g=(y=_[m])==null?void 0:y.id,T=j((N=i[a])==null?void 0:N.result),D=(I||[]).filter(w=>w.sourceID===g),v=b(p,l),{dataSourceStep:R,tool:x}=v,C=b(p,R);let P=[];return R&&x&&(P=(U=T[`step_${R}`])==null?void 0:U.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[m]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),Tt.info(M.t("NoDependency")))),e==null||e.setResult(D),e==null||e.history.initRecord(D,!0),s(o({},t),{basicIndex:m})}case r.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:e}=n.payload;return s(o({},t),{triggerEventAfterIndexChanged:!!e})}case r.LOAD_FILE_DATA:{const{imgList:e,step:l,toolInstance:i,annotationEngine:a,stepList:p}=t;if(!i)return s(o({},t),{imgIndex:n.payload.nextIndex});const c=h.getCurrentStepInfo(l,p),{nextIndex:I,imgNode:_,nextBasicIndex:m,imgError:g}=n.payload,T=m!=null?m:0,D=j((B=e[I])==null?void 0:B.result),v=D[`step_${c.step}`],R=!v,x={rotate:(V=D.rotate)!=null?V:0,valid:bt((k=e[I])==null?void 0:k.result,(H=e[I])==null?void 0:H.preResult)};_&&g!==!0?a==null||a.setImgNode(_,x):i==null||i.setValid(x.valid);const C=b(p,c.step),{dataSourceStep:P,tool:w}=C,pt=b(p,P),X=P&&w,F=(z=(G=D[`step_${P}`])==null?void 0:G.result)!=null?z:[],K=Y.getInitialResultList(v==null?void 0:v.result,i,C,F,R);a==null||a.launchOperation();const yt=[O.Cuboid,O.ScribbleTool].includes(w);if(X&&((F==null?void 0:F.length)>0?a==null||a.setBasicInfo(pt.tool,F[T]):(a==null||a.setBasicInfo(pt.tool),a==null||a.forbidOperation(),Tt.info(M.t("NoDependency")))),c.tool!=="check"&&(yt||X)){const Pt=(Q=(Z=F[T])==null?void 0:Z.id)!=null?Q:"",Rt=X?K.filter(Ct=>Nt.isSameSourceID(Ct.sourceID,Pt)):K;(tt=i==null?void 0:i.history)==null||tt.initRecord(K,!0),i==null||i.setResult(Rt)}return s(o({},t),{imgIndex:I,basicIndex:T,basicResultList:F,resultList:K})}case r.UPDATE_ANNOTATION_CONFIG:return s(o({},t),{config:(et=n.payload.config)!=null?et:"{}"});case r.SET_TASK_STEP_LIST:{const{stepList:e}=n.payload;return s(o({},t),{stepList:e})}case r.SET_TASK_CONFIG:{const{stepList:e,step:l}=n.payload;return s(o({},t),{stepList:e,step:l})}case r.INIT_TOOL:{const{imgNode:e}=t,l=Vt(t,e);if(l){const{toolInstance:i,annotationEngine:a}=l;return s(o({},t),{toolInstance:i,annotationEngine:a})}return o({},t)}case r.SET_TOOL:{const e=(nt=n.payload)==null?void 0:nt.instance;return e?s(o({},t),{toolInstance:e}):o({},t)}case r.UPDATE_ON_SUBMIT:return s(o({},t),{onSubmit:n.payload.onSubmit});case r.UPDATE_ON_SAVE:return s(o({},t),{onSave:n.payload.onSave});case r.UPDATE_ON_PAGE_CHANGE:return s(o({},t),{onPageChange:n.payload.onPageChange});case r.SET_PREDICT_RESULT:return s(o({},t),{predictionResult:n.payload.result});case r.SET_PREDICT_RESULT_VISIBLE:return s(o({},t),{predictionResultVisible:n.payload.visible});case r.UPDATE_ON_STEP_CHANGE:return s(o({},t),{onStepChange:n.payload.onStepChange});case r.UPDATE_GET_FILE_DATA:return s(o({},t),{getFileData:n.payload.getFileData});case r.UPDATE_PAGE_SIZE:return s(o({},t),{pageSize:n.payload.pageSize});case r.UPDATE_LOAD_FILE_LIST:return s(o({},t),{loadFileList:n.payload.loadFileList});case r.UPDATE_BEFORE_ROTATE:return s(o({},t),{beforeRotate:n.payload.beforeRotate});case r.UPDATE_PRE_DATA_PROCESS:return s(o({},t),{preDataProcess:n.payload.preDataProcess});case r.UPDATE_IMG_INDEX_BY_EXTERNAL:return s(o({},t),{getImgIndexByExternal:n.payload.getImgIndexByExternal});case r.SKIP_BEFORE_PAGE_TURNING:return s(o({},t),{skipBeforePageTurning:n.payload.skipBeforePageTurning});case r.SET_FILE_DATA:{const{fileData:e,index:l}=n.payload,{imgList:i}=t,a=[...i];return a[l]=o(o({},a[l]),e),s(o({},t),{imgList:a})}case r.UPDATE_ROTATE:{const{toolInstance:e,beforeRotate:l}=t;return l&&l()===!1||(ot=e==null?void 0:e.updateRotate)==null||ot.call(e),t}case r.UPDATE_ANNOTATION_VALID:{const{toolInstance:e}=t,l=(lt=e==null?void 0:e.valid)!=null?lt:!0;return ft.destroyAll(),ft.confirm({content:M.t(l?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{e==null||e.setValid(!l)},okText:M.t("Confirm"),cancelText:M.t("Cancel")}),t}case r.COPY_BACKWARD_RESULT:{const{toolInstance:e,imgIndex:l,imgList:i,step:a,stepList:p}=t;if(!e)return t;if(l===0||l>=i.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const c=i[l-1].result;if(!c)return t;const I=h.getCurrentStepInfo(a,p),_=(st=I==null?void 0:I.step)!=null?st:a,m=(it=e==null?void 0:e.valid)!=null?it:!0,g=Y.copyResultChange({copyResult:c,step:_,currentResult:(rt=i[l].result)!=null?rt:"",preMappingImgList:(ut=i[l-1].mappingImgList)!=null?ut:[],mappingImgList:(at=i[l].mappingImgList)!=null?at:[],valid:m});i[l]=s(o({},i[l]),{result:g});const D=j(g)[`step_${a}`],v=(D==null?void 0:D.result)||[];return e==null||e.setResult(v),e==null||e.history.pushHistory(v),(ct=e==null?void 0:e.asyncData)==null||ct.call(e,i[l]),s(o({},t),{imgList:[...i]})}case r.SET_STEP:{const{stepList:e,annotationEngine:l}=t,{toStep:i}=n.payload;if(l){const a=b(e,i);return l==null||l.setToolName(a.tool,a.config),s(o({},t),{step:i,toolInstance:l==null?void 0:l.toolInstance})}return s(o({},t),{step:i})}case r.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:e}=n.payload;return s(o({},t),{loadPCDFileLoading:!!e})}case r.SET_LOADING:{const{loading:e}=n.payload;return s(o({},t),{loading:!!e})}case r.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:e}=n.payload;return s(o({},t),{pointCloudLoading:!!e})}case r.SET_CHECK_MODE:{const{checkMode:e}=n.payload;return s(o({},t),{checkMode:!!e})}case r.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:e}=n.payload;return s(o({},t),{highlightAttribute:e})}case r.BATCH_UPDATE_TRACK_ID:{const{id:e,newID:l,rangeIndex:i,imgList:a}=n.payload,{imgIndex:p,onSubmit:c}=t,I=[],_=a.map((m,g)=>{if(It.isInRange(g,i)){const T=s(o({},m),{result:mt.batchUpdateTrackID({id:e,newID:l,result:m.result})});return I.push({imgIndex:g,newInfo:T}),T}return m});return c&&c([_[p]],W.BatchUpdateTrackID,p,_,{updateImgList:I}),s(o({},t),{imgList:_})}case r.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const e=n,{id:l,newData:i,rangeIndex:a,imgList:p}=e.payload,{imgIndex:c,onSubmit:I}=t,_=[],m=p.map((g,T)=>{if(It.isInRange(T,a)){const D=s(o({},g),{result:mt.batchUpdateResultByTrackID({id:l,newData:i,result:g.result})});return _.push({imgIndex:T,newInfo:D}),D}return g});return I&&I([m[c]],W.BatchUpdateTrackID,c,m,{updateImgList:_}),s(o({},t),{imgList:m})}case r.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:e,imgList:l,stepList:i,step:a,predictionResult:p}=t,c={};p.forEach(g=>{const{index:T}=g;c[T]=Lt.pick(g,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const I=`step_${a}`,_=[],m=l.map((g,T)=>{if(c[T]){const D=g.result==="{}"?j(J("",{step:a,stepList:i},{rect:[]},{})):j(g.result);D[I].result.push(c[T]);const v=s(o({},g),{result:JSON.stringify(D)});return _.push({imgIndex:T,newInfo:v}),v}return g});return e==null||e(m,W.BatchUpdateImgList,-1,m,{updateImgList:_}),s(o({},t),{imgList:m})}case r.CHANGE_PAGE_CHECK:{const{toolInstance:e,step:l,stepList:i}=t;if(!e)return t;const[a]=(dt=e==null?void 0:e.exportData())!=null?dt:[],p=b(i,l),c=gt.jsonParser(p.config),I=a.some(_=>(_==null?void 0:_.result)&&Object.keys(_.result).length>0);return s(o({},t),{confirmPageTurning:c.showConfirm&&!I})}default:return t}};export{kt as LoadFileAndFileData,Xt as annotationReducer,$t as composeResultByToolInstance,b as getStepConfig,Mt as getTotalPage};
package/es/utils/index.js CHANGED
@@ -1 +1 @@
1
- import f from"lodash";import{pointCloudLidar2image as y}from"@labelbee/lb-annotation";var _=Object.defineProperty,x=Object.defineProperties,O=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))P.call(t,n)&&h(e,n,t[n]);if(g)for(var n of g(t))v.call(t,n)&&h(e,n,t[n]);return e},b=(e,t)=>x(e,O(t));const I=(e,t={})=>{try{return typeof e=="string"?JSON.parse(e):f.isObject(e)?e:t}catch(n){return t}},j=e=>{if(Array.isArray(e))return e.filter(t=>t).join(" ");if(f.isObject(e)){const t=[];return Object.keys(e).forEach(n=>{e[n]&&t.push(n)}),t.join(" ")}return""},m=e=>{let t=Infinity,n=Infinity,r=-Infinity,o=-Infinity;for(const i of e)t=Math.min(t,i.x),n=Math.min(n,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:n,width:r-t,height:o-n}},u=(()=>{const e=(t,n)=>{const r=Math.max(t.x,n.x),o=Math.max(t.y,n.y),i=Math.min(t.x+t.width,n.x+n.width),c=Math.min(t.y+t.height,n.y+n.height),s=i-r,a=c-o;return s>=0&&a>=0?{x:r,y:o,width:s,height:a}:null};return(t,n,r)=>{if(r[n]){const o=r[n].width,i=r[n].height;return e(t,{x:0,y:0,width:o,height:i})!==null}return!1}})(),d=e=>{var t;const{pointCloudBox:n,mappingData:r,imageSizes:o}=e,{transferViewData:i}=(t=y(n,r.calib))!=null?t:{};if(!i)return;const c=i.reduce((p,l)=>l.type==="line"?[...p,...l.pointList]:p,[]),s=b(w({},m(c)),{imageName:r.path});if(u(s,r.path,o))return s},R=(e,t)=>{var n;const{pointCloudBox:r,mappingImgList:o,imageSizes:i}=e,s=o.map(a=>d({pointCloudBox:r,mappingData:a,imageSizes:i})).filter(a=>a!==void 0);if(s.length>0){const a=(n=t==null?void 0:t.prepareRectsFn)!=null?n:void 0,p=a?a(s,r):s;p.length>0&&Object.assign(r,{rects:p})}};export{j as classnames,R as generatePointCloudBoxRects,m as getBoundingRect,d as getRectPointCloudBox,u as isBoundingRectInImage,I as jsonParser};
1
+ import f from"lodash";import{pointCloudLidar2image as _}from"@labelbee/lb-annotation";var v=Object.defineProperty,x=Object.defineProperties,O=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))b.call(t,n)&&h(e,n,t[n]);if(g)for(var n of g(t))P.call(t,n)&&h(e,n,t[n]);return e},I=(e,t)=>x(e,O(t));const p=(e,t={})=>{try{return typeof e=="string"?JSON.parse(e):f.isObject(e)?e:t}catch(n){return t}},j=(e,t)=>{var n,r;const o=p(e),i=p(t);return(r=(n=o==null?void 0:o.valid)!=null?n:i==null?void 0:i.valid)!=null?r:!0},R=e=>{if(Array.isArray(e))return e.filter(t=>t).join(" ");if(f.isObject(e)){const t=[];return Object.keys(e).forEach(n=>{e[n]&&t.push(n)}),t.join(" ")}return""},m=e=>{let t=Infinity,n=Infinity,r=-Infinity,o=-Infinity;for(const i of e)t=Math.min(t,i.x),n=Math.min(n,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:n,width:r-t,height:o-n}},d=(()=>{const e=(t,n)=>{const r=Math.max(t.x,n.x),o=Math.max(t.y,n.y),i=Math.min(t.x+t.width,n.x+n.width),l=Math.min(t.y+t.height,n.y+n.height),s=i-r,a=l-o;return s>=0&&a>=0?{x:r,y:o,width:s,height:a}:null};return(t,n,r)=>{if(r[n]){const o=r[n].width,i=r[n].height;return e(t,{x:0,y:0,width:o,height:i})!==null}return!1}})(),y=e=>{var t;const{pointCloudBox:n,mappingData:r,imageSizes:o}=e,{transferViewData:i}=(t=_(n,r.calib))!=null?t:{};if(!i)return;const l=i.reduce((c,u)=>u.type==="line"?[...c,...u.pointList]:c,[]),s=I(w({},m(l)),{imageName:r.path});if(d(s,r.path,o))return s},M=(e,t)=>{var n;const{pointCloudBox:r,mappingImgList:o,imageSizes:i}=e,s=o.map(a=>y({pointCloudBox:r,mappingData:a,imageSizes:i})).filter(a=>a!==void 0);if(s.length>0){const a=(n=t==null?void 0:t.prepareRectsFn)!=null?n:void 0,c=a?a(s,r):s;c.length>0&&Object.assign(r,{rects:c})}};export{R as classnames,M as generatePointCloudBoxRects,m as getBoundingRect,y as getRectPointCloudBox,d as isBoundingRectInImage,p as jsonParser,j as resolveFileItemValid};
@@ -1 +1 @@
1
- import r,{useRef as p,useState as C}from"react";import{Col as y,Popconfirm as E}from"antd";import{useTranslation as i}from"react-i18next";import{prefix as g}from"../../../../constant/index.js";const k={color:"#CCCCCC"},f=({info:e})=>{const{t}=i();return e.key.startsWith("sure")?r.createElement("div",{key:e.key},`${t("ConfirmTo")}${e.name.slice(0)}\uFF1F`,(e==null?void 0:e.content)?e.content:""):r.createElement("span",null,e.name)},h=({icon:e})=>typeof e=="string"?r.createElement("img",{width:23,height:25,src:e}):e,u=({isHover:e,info:t})=>{const l=!!t.forbidOperation,a=t.key===e&&!l;let o={color:a?"#666fff":""};return l&&(o=k),r.createElement("div",{style:{cursor:l?"not-allowed":"default"},onClick:()=>{var c;return(t==null?void 0:t.forbidConfirm)&&!l&&((c=t==null?void 0:t.onClick)==null?void 0:c.call(t))}},r.createElement("div",{className:"icon"},r.createElement(h,{icon:a?t.hoverSvg:t.imgSvg})),r.createElement("div",{className:"toolName",style:o},t.name))},x=({allOperation:e,setBatchSetValid:t,valid:l})=>{const a=p(null),[o,c]=C(null),{t:m}=i(),d=Math.floor(24/e.length),v=n=>n.forbidConfirm?r.createElement(u,{info:n,isHover:o}):t&&n.key==="setValidity"?t({valid:l,isHover:!!o,singleSetQuestionImg:n.onClick}):r.createElement(E,{title:r.createElement(f,{info:n}),placement:"topRight",okText:m("Confirm"),cancelText:m("Cancel"),getPopupContainer:()=>{var s;return(s=a.current)!=null?s:document.body},onConfirm:n.onClick,overlayClassName:`${g}-pop-confirm`},r.createElement("div",null,r.createElement(u,{info:n,isHover:o})));return r.createElement("div",{className:"generalOperation",ref:a},e.map((n,s)=>r.createElement(y,{span:d,key:s,className:"generalOperation-col"},r.createElement("div",{key:n.key,className:"item",onMouseEnter:()=>{c(n.key)},onMouseLeave:()=>{c(null)}},v(n)))))};export{x as default};
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 s,{useState as f,useCallback as U}from"react";import{connect as g}from"react-redux";import w from"../../../../utils/StepUtils.js";import{jsonParser as v}from"../../../../utils/index.js";import C from"./ActionsConfirm.js";import y from"./useOperationList.js";import{LabelBeeContext as S}from"../../../../store/ctx.js";import T from"../../../../assets/annotation/pointCloudTool/unitAttribute.svg.js";import V from"../../../../assets/annotation/pointCloudTool/unitAttributeForbid.svg.js";import A from"../../../../assets/annotation/pointCloudTool/unitAttributeHover.svg.js";import{useTranslation as I}from"react-i18next";import E from"../../../../components/pointCloudView/components/UnifyParamsModal/index.js";import{useSingleBox as M}from"../../../../components/pointCloudView/hooks/useSingleBox.js";import{composeResultByToolInstance as _}from"../../../../store/annotation/reducer.js";import{useStatus as R}from"../../../../components/pointCloudView/hooks/useStatus.js";const x=o=>{var t,i;const n=w.getCurrentStepInfo((t=o.annotation)==null?void 0:t.step,(i=o.annotation)==null?void 0:i.stepList);return{toolInstance:o.annotation.toolInstance,stepInfo:n,imgList:o.annotation.imgList,imgIndex:o.annotation.imgIndex,stepList:o.annotation.stepList}},$=({toolInstance:o,stepInfo:t,hideValidity:i})=>{const n=y(o),r=v(t==null?void 0:t.config),e=[n.empty];return(t==null?void 0:t.dataSourceStep)===0&&!i&&e.push(n.setValidity),(r==null?void 0:r.copyBackwardResult)&&e.push(n.copyPrevious),s.createElement(C,{allOperation:e})},D=g(x,null,null,{context:S})(({toolInstance:o,stepInfo:t,imgList:i,stepList:n,imgIndex:r,setBatchSetValid:e})=>{const{t:P}=I(),{selectedBox:m}=M(),u=y(o),[j,c]=f(!1),[L,b]=f([]),{isPointCloudDetectionPattern:k,isPointCloudSegmentationPattern:h}=R(),p=v(t.config);let a=[u.copyPrevious,u.empty,u.setValidity];if(k&&p.trackConfigurable===!0){const l=!m,B={name:P("UnifyParams"),key:"UnifyParams",imgSvg:l?V:T,hoverSvg:A,onClick:()=>{b(_({toolInstance:o,imgList:i,imgIndex:r,stepList:n})),c(!0)},forbidConfirm:!0,forbidOperation:l};a.unshift(B)}const O=U(()=>{c(!1)},[]),d=m==null?void 0:m.info;return h&&(a=a.filter(l=>!["setValidity","copyPrevious"].includes(l.key))),s.createElement(s.Fragment,null,s.createElement(C,{allOperation:a,setBatchSetValid:e,valid:o==null?void 0:o.valid}),s.createElement(E,{id:d==null?void 0:d.trackID,visible:j,onCancel:O,config:p,imgList:L}))});var F=g(x,null,null,{context:S})($);export{D as PointCloudOperation,F as default};
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.61",
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.32",
47
- "@labelbee/lb-utils": "1.20.0-alpha.9",
48
- "@labelbee/wavesurfer": "1.1.0",
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",