@labelbee/lb-components 1.23.0-alpha.4 → 1.23.0-alpha.41

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.
Files changed (126) hide show
  1. package/dist/App.js +1 -1
  2. package/dist/assets/annotation/icon_link.svg.js +1 -0
  3. package/dist/assets/annotation/icon_unlink.svg.js +1 -0
  4. package/dist/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
  5. package/dist/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
  6. package/dist/components/LLMToolView/index.js +1 -1
  7. package/dist/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
  8. package/dist/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
  9. package/dist/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
  10. package/dist/components/LLMToolView/sidebar/index.js +1 -1
  11. package/dist/components/LLMToolView/utils/data.js +1 -1
  12. package/dist/components/NLPToolView/index.js +1 -1
  13. package/dist/components/NLPToolView/textContent/index.js +1 -1
  14. package/dist/components/audioAnnotate/audioContext/index.js +1 -1
  15. package/dist/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  16. package/dist/components/audioAnnotate/index.js +1 -1
  17. package/dist/components/audioAnnotate/textInput/index.js +1 -1
  18. package/dist/components/audioAnnotate/textInput/index.module.scss.js +1 -1
  19. package/dist/components/audioAnnotate/utils/dataTransform.js +1 -0
  20. package/dist/components/audioPlayer/clipRegion/index.js +1 -1
  21. package/dist/components/audioPlayer/index.js +1 -1
  22. package/dist/components/audioPlayer/useAudioCombine/index.js +3 -2
  23. package/dist/components/audioPlayer/useAudioSegment/index.js +1 -1
  24. package/dist/components/longText/index.js +1 -1
  25. package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
  26. package/dist/components/pointCloudView/PointCloud2DSingleView.js +1 -1
  27. package/dist/components/pointCloudView/PointCloud2DView.js +1 -1
  28. package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
  29. package/dist/components/pointCloudView/PointCloudContext.js +1 -1
  30. package/dist/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -0
  31. package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  32. package/dist/components/pointCloudView/hooks/useStatus.js +1 -1
  33. package/dist/components/pointCloudView/index.js +1 -1
  34. package/dist/components/subAttributeList/index.js +1 -0
  35. package/dist/components/videoAnnotate/videoClipTool/index.js +1 -1
  36. package/dist/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
  37. package/dist/index.css +31 -9
  38. package/dist/index.js +1 -1
  39. package/dist/store/Actions.js +1 -1
  40. package/dist/store/annotation/actionCreators.js +1 -1
  41. package/dist/store/annotation/reducer.js +1 -1
  42. package/dist/types/App.d.ts +3 -1
  43. package/dist/types/components/LLMToolView/utils/data.d.ts +1 -1
  44. package/dist/types/components/audioAnnotate/audioContext/index.d.ts +10 -2
  45. package/dist/types/components/audioAnnotate/textInput/index.d.ts +1 -0
  46. package/dist/types/components/audioAnnotate/utils/dataTransform.d.ts +9 -0
  47. package/dist/types/components/audioPlayer/index.d.ts +28 -21
  48. package/dist/types/components/longText/index.d.ts +1 -0
  49. package/dist/types/components/pointCloud2DRectOperationView/index.d.ts +1 -0
  50. package/dist/types/components/pointCloudView/PointCloud2DView.d.ts +1 -1
  51. package/dist/types/components/pointCloudView/PointCloudContext.d.ts +12 -1
  52. package/dist/types/components/pointCloudView/hooks/useDataLinkSwitch.d.ts +21 -0
  53. package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +5 -0
  54. package/dist/types/components/subAttributeList/index.d.ts +10 -0
  55. package/dist/types/components/videoAnnotate/index.d.ts +2 -1
  56. package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +2 -1
  57. package/dist/types/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.d.ts +1 -1
  58. package/dist/types/index.d.ts +4 -1
  59. package/dist/types/store/Actions.d.ts +1 -0
  60. package/dist/types/store/annotation/actionCreators.d.ts +3 -2
  61. package/dist/types/store/annotation/reducer.d.ts +1 -0
  62. package/dist/types/store/annotation/types.d.ts +9 -2
  63. package/dist/types/utils/AnnotationDataUtils.d.ts +57 -1
  64. package/dist/types/utils/index.d.ts +25 -1
  65. package/dist/types/views/MainView/sidebar/TextToolSidebar/index.d.ts +1 -1
  66. package/dist/types/views/MainView/toolFooter/index.d.ts +1 -1
  67. package/dist/types/views/MainView/toolHeader/StepSwitch/index.d.ts +1 -1
  68. package/dist/types/views/MainView/toolHeader/index.d.ts +1 -1
  69. package/dist/utils/AnnotationDataUtils.js +1 -1
  70. package/dist/utils/index.js +1 -1
  71. package/dist/views/MainView/index.js +1 -1
  72. package/dist/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
  73. package/dist/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
  74. package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  75. package/dist/views/MainView/sidebar/TagSidebar/index.js +1 -1
  76. package/dist/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
  77. package/es/App.js +1 -1
  78. package/es/assets/annotation/icon_link.svg.js +1 -0
  79. package/es/assets/annotation/icon_unlink.svg.js +1 -0
  80. package/es/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
  81. package/es/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
  82. package/es/components/LLMToolView/index.js +1 -1
  83. package/es/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
  84. package/es/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
  85. package/es/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
  86. package/es/components/LLMToolView/sidebar/index.js +1 -1
  87. package/es/components/LLMToolView/utils/data.js +1 -1
  88. package/es/components/NLPToolView/index.js +1 -1
  89. package/es/components/NLPToolView/textContent/index.js +1 -1
  90. package/es/components/audioAnnotate/audioContext/index.js +1 -1
  91. package/es/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  92. package/es/components/audioAnnotate/index.js +1 -1
  93. package/es/components/audioAnnotate/textInput/index.js +1 -1
  94. package/es/components/audioAnnotate/textInput/index.module.scss.js +1 -1
  95. package/es/components/audioAnnotate/utils/dataTransform.js +1 -0
  96. package/es/components/audioPlayer/clipRegion/index.js +1 -1
  97. package/es/components/audioPlayer/index.js +1 -1
  98. package/es/components/audioPlayer/useAudioCombine/index.js +3 -2
  99. package/es/components/audioPlayer/useAudioSegment/index.js +1 -1
  100. package/es/components/longText/index.js +1 -1
  101. package/es/components/pointCloud2DRectOperationView/index.js +1 -1
  102. package/es/components/pointCloudView/PointCloud2DSingleView.js +1 -1
  103. package/es/components/pointCloudView/PointCloud2DView.js +1 -1
  104. package/es/components/pointCloudView/PointCloud3DView.js +1 -1
  105. package/es/components/pointCloudView/PointCloudContext.js +1 -1
  106. package/es/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -0
  107. package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  108. package/es/components/pointCloudView/hooks/useStatus.js +1 -1
  109. package/es/components/pointCloudView/index.js +1 -1
  110. package/es/components/subAttributeList/index.js +1 -0
  111. package/es/components/videoAnnotate/videoClipTool/index.js +1 -1
  112. package/es/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
  113. package/es/index.css +31 -9
  114. package/es/index.js +1 -1
  115. package/es/store/Actions.js +1 -1
  116. package/es/store/annotation/actionCreators.js +1 -1
  117. package/es/store/annotation/reducer.js +1 -1
  118. package/es/utils/AnnotationDataUtils.js +1 -1
  119. package/es/utils/index.js +1 -1
  120. package/es/views/MainView/index.js +1 -1
  121. package/es/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
  122. package/es/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
  123. package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  124. package/es/views/MainView/sidebar/TagSidebar/index.js +1 -1
  125. package/es/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
  126. package/package.json +3 -3
@@ -1 +1 @@
1
- import{EPointCloudPattern as z}from"@labelbee/lb-utils";import nt,{useState as n,useRef as Vt,useMemo as it,useEffect as E}from"react";import{ActionsHistory as st,EToolName as G}from"@labelbee/lb-annotation";import{useDispatch as Bt}from"../../store/ctx.js";import{ChangeSave as Ot}from"../../store/annotation/actionCreators.js";import Ht from"../../store/annotatedBox/index.js";var Rt=Object.defineProperty,jt=Object.defineProperties,zt=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,rt=(a,e,i)=>e in a?Rt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[e]=i,Nt=(a,e)=>{for(var i in e||(e={}))Et.call(e,i)&&rt(a,i,e[i]);if(lt)for(var i of lt(e))Gt.call(e,i)&&rt(a,i,e[i]);return a},Ft=(a,e)=>jt(a,zt(e)),Mt=(a,e,i)=>new Promise((m,C)=>{var S=v=>{try{f(i.next(v))}catch(s){C(s)}},_=v=>{try{f(i.throw(v))}catch(s){C(s)}},f=v=>v.done?m(v.value):Promise.resolve(v.value).then(S,_);f((i=i.apply(a,e)).next())});const at=nt.createContext({pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new st,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:G.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:z.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:a=>{},imageSizes:{},cacheImageNodeSize:()=>{}}),Tt=({children:a})=>{const[e,i]=n([]),[m,C]=n([]),[S,_]=n([]),[f,v]=n([]),[s,x]=n([]),[y,V]=n([]),[N,dt]=n(!0),[F,ct]=n(!0),[M,ut]=n(1),[d,T]=n(),[Z,k]=n(),[q,J]=n(),[l,K]=n(),[Q,pt]=n(""),[B,gt]=n(G.Rect),ht=Vt(new st).current,[p,O]=n([]),[U,vt]=n(""),[H,Pt]=n(z.Detection),[b,W]=n(void 0),[R,ft]=n([]),[j,mt]=n([]),g=Ht(),[X,bt]=n({}),It=Bt(),Ct=r=>{const{imgNode:c,path:u}=r;u&&c&&bt(P=>Ft(Nt({},P),{[u]:{width:c.width,height:c.height}}))},Y=it(()=>s.length===1?s[0]:"",[s]),w=it(()=>{const r=e.find(t=>t.id===Y),c=t=>{const o=e.concat(t);return i(o),o},u=t=>{const o=m.concat(t);return C(o),o},P=t=>{dt(t!==!1)},h=t=>{t===void 0&&x([]),typeof t=="string"&&x([t]),Array.isArray(t)&&x(Array.from(new Set(t)))},yt=t=>{s.includes(t)?h(s.filter(o=>o!==t)):h([...s,t])},Lt=t=>{y.includes(t)?V([]):V([t])},Dt=()=>{if(B===G.Rect){const t=e.map(o=>o.id);h(t),d==null||d.pointCloud2dOperation.setSelectedIDs(t)}},wt=t=>{h(e.filter(o=>o.attribute===t).map(o=>o.id))},$=e.filter(t=>!p.includes(t.attribute)),tt=m.filter(t=>!p.includes(t.attribute)),et=f.filter(t=>t.attribute&&!p.includes(t.attribute)),At=t=>{if(p.includes(t))O(p.filter(o=>o!==t));else{const o=p.concat(t);O(o)}},_t=(t=$,o=S,L=tt,A=et,D=R)=>{var I;l==null||l.clearAllBox(),l==null||l.clearAllSphere(),d==null||d.updatePolygonList(t,o),d==null||d.updatePointList(L),d==null||d.updateLineList(A),l==null||l.generateBoxes(t),l==null||l.generateSpheres(L),(I=b==null?void 0:b.store)==null||I.updateCurrentSegment(D),ot(t)},xt=()=>{T(void 0),k(void 0),J(void 0),K(void 0)},ot=(t,o)=>Mt(void 0,null,function*(){var L;if(!l)return;const A=l.pointCloudObject;if(!!A)try{const D=yield l.getHighlightIndexByMappingImgList({mappingImgList:o!=null?o:j,points:A.geometry.attributes.position.array}),I=yield l==null?void 0:l.highlightOriginPointCloud(t,D);return I&&((L=d==null?void 0:d.pointCloudInstance)==null||L.updateColor(I)),I}catch(D){console.error(D)}});return{selectedID:Y,pointCloudBoxList:e,pointCloudSphereList:m,displayPointCloudList:$,displaySphereList:tt,displayLineList:et,selectedIDs:s,setPointCloudResult:i,setSelectedIDs:h,addPointCloudBox:c,addPointCloudSphere:u,setPointCloudSphereList:C,valid:N,selectedPointCloudBox:r,setPointCloudValid:P,addSelectedID:yt,addHighlightID:Lt,selectedAllBoxes:Dt,topViewInstance:d,setTopViewInstance:T,sideViewInstance:Z,setSideViewInstance:k,backViewInstance:q,setBackViewInstance:J,mainViewInstance:l,setMainViewInstance:K,polygonList:S,setPolygonList:_,lineList:f,setLineList:v,zoom:M,setZoom:ut,history:ht,toggleAttributesVisible:At,hideAttributes:p,setHideAttributes:O,reRender:_t,attrPanelLayout:U,setAttrPanelLayout:vt,syncAllViewPointCloudColor:ot,defaultAttribute:Q,setDefaultAttribute:pt,pointCloudPattern:B,setPointCloudPattern:gt,selectSpecAttr:wt,globalPattern:H,setGlobalPattern:t=>{H!==t&&(It(Ot),Pt(t),t===z.Detection&&W(void 0))},ptSegmentInstance:b,setPtSegmentInstance:W,segmentation:R,setSegmentation:ft,clearAllDetectionInstance:xt,highlight2DDataList:j,setHighlight2DDataList:mt,cuboidBoxIn2DView:F,setCuboidBoxIn2DView:ct,imageSizes:X,cacheImageNodeSize:Ct,highlightIDs:y,setHighlightIDs:V}},[N,s,e,m,S,f,d,Z,q,l,M,p,U,Q,B,H,b,R,j,F,X,y]);E(()=>{var r,c,u;(r=g==null?void 0:g.setPointCloudBoxList)==null||r.call(g,e),(c=g==null?void 0:g.setHighlightIDs)==null||c.call(g,y),(u=g==null?void 0:g.setSelectedIDs)==null||u.call(g,s)},[e,s,y]),E(()=>{var r;(r=g==null?void 0:g.setPtCtx)==null||r.call(g,w)},[w]);const St=()=>{const r=e.filter(h=>p.includes(h.attribute)),{setSelectedIDs:c,reRender:u}=w,P=r.map(h=>h.id);P.length>0&&c(s.filter(h=>!P.includes(h))),u()};return E(()=>{var r,c,u,P;St(),(c=(r=d==null?void 0:d.toolInstance)==null?void 0:r.setHiddenAttributes)==null||c.call(r,p),(P=(u=b==null?void 0:b.store)==null?void 0:u.setHiddenAttributes)==null||P.call(u,p)},[p]),nt.createElement(at.Provider,{value:w},a)};export{at as PointCloudContext,Tt as PointCloudProvider};
1
+ import{EPointCloudPattern as J}from"@labelbee/lb-utils";import gt,{useState as s,useRef as Zt,useMemo as ht,useCallback as K,useEffect as Q}from"react";import{ActionsHistory as It,EToolName as U,uuid as qt}from"@labelbee/lb-annotation";import{useDispatch as Jt}from"../../store/ctx.js";import{ChangeSave as Kt}from"../../store/annotation/actionCreators.js";import Qt from"../../store/annotatedBox/index.js";import vt from"lodash";var Ut=Object.defineProperty,Wt=Object.defineProperties,Xt=Object.getOwnPropertyDescriptors,Pt=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable,bt=(l,e,a)=>e in l?Ut(l,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):l[e]=a,N=(l,e)=>{for(var a in e||(e={}))Yt.call(e,a)&&bt(l,a,e[a]);if(Pt)for(var a of Pt(e))$t.call(e,a)&&bt(l,a,e[a]);return l},yt=(l,e)=>Wt(l,Xt(e)),te=(l,e,a)=>new Promise((L,A)=>{var _=f=>{try{y(a.next(f))}catch(C){A(C)}},j=f=>{try{y(a.throw(f))}catch(C){A(C)}},y=f=>f.done?L(f.value):Promise.resolve(f.value).then(_,j);y((a=a.apply(l,e)).next())});const Ct=l=>vt.pick(l,["id","attribute","width","height","x","y","imageName"]),wt=gt.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new It,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:U.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:J.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:l=>{},imageSizes:{},cacheImageNodeSize:()=>{},unlinkImageItems:[],addRectFromPointCloudBoxByImageName:l=>!1,removeRectBySpecifyId:(l,e,a)=>!1,removeRectByPointCloudBoxId:l=>!1}),ee=({children:l})=>{const[e,a]=s([]),[L,A]=s([]),[_,j]=s([]),[y,f]=s([]),[C,St]=s([]),[v,F]=s([]),[R,k]=s([]),[W,Lt]=s(!0),[X,Dt]=s(!0),[Y,xt]=s(1),[m,$]=s(),[tt,et]=s(),[nt,it]=s(),[u,ot]=s(),[st,At]=s(""),[z,_t]=s(U.Rect),Rt=Zt(new It).current,[g,E]=s([]),[rt,Vt]=s(""),[G,Bt]=s(J.Detection),[D,lt]=s(void 0),[M,Ot]=s([]),[T,Ht]=s([]),h=Qt(),[at,Nt]=s({}),jt=Jt(),Ft=o=>{const{imgNode:r,path:i}=o;i&&r&&Nt(p=>yt(N({},p),{[i]:{width:r.width,height:r.height}}))},dt=ht(()=>v.length===1?v[0]:"",[v]),V=K((o,r,i="extId")=>{const p=i||"id",c=new Set(r);return f(I=>{let w=!1;const S=I.filter(O=>{const Z=O[p],H=c.has(Z)?O.imageName!==o:!0;return H||(w=!0),H});return w?S:I}),!0},[]),ct=K(o=>{const r=e.map(i=>i.id);return V(o,r,"extId")},[e,V]),ut=K(o=>{if(!o)return!1;const r=e.filter(i=>Array.isArray(i.rects)).map(i=>{const{id:p,attribute:c,trackID:I}=i,w=i.rects.find(S=>S.imageName===o);if(w){const S=vt.pick(w,["width","height","x","y","imageName"]);return yt(N({},S),{id:qt(),attribute:c,order:I,extId:p,lineDash:[]})}return null}).filter(i=>i!==null);return r.length?(f(i=>{const p=new Set(i.filter(I=>o===I.imageName).map(I=>I.extId)),c=r.filter(I=>p.has(I.extId)===!1);return c.length?[...i,...c]:i}),!0):!1},[e]),B=ht(()=>{const o=e.find(t=>t.id===dt),r=t=>{const n=e.concat(t);return a(n),n},i=t=>{const n=L.concat(t);return A(n),n},p=t=>{Lt(t!==!1)},c=t=>{t===void 0&&F([]),typeof t=="string"&&F([t]),Array.isArray(t)&&F(Array.from(new Set(t)))},I=t=>{v.includes(t)?c(v.filter(n=>n!==t)):c([...v,t])},w=t=>{const n=Ct(t);f(d=>[...d,n])},S=(t,n=!1)=>{const d=Ct(t);f(b=>b.map(P=>P.id===t.id?n?N(N({},P),d):d:P))},O=t=>{f(n=>n.filter(d=>!t.find(b=>b.id===d.id)))},Z=t=>{R.includes(t)?k([]):k([t])},H=()=>{if(z===U.Rect){const t=e.map(n=>n.id);c(t),m==null||m.pointCloud2dOperation.setSelectedIDs(t)}},zt=t=>{c(e.filter(n=>n.attribute===t).map(n=>n.id))},q=e.filter(t=>!g.includes(t.attribute)),pt=L.filter(t=>!g.includes(t.attribute)),ft=C.filter(t=>t.attribute&&!g.includes(t.attribute)),Et=t=>{if(g.includes(t))E(g.filter(n=>n!==t));else{const n=g.concat(t);E(n)}},Gt=(()=>{const t=q.map(d=>d.id),n=new Set(t);return y.filter(d=>d.extId&&n.has(d.extId)).map(d=>d.imageName)})(),Mt=(t=q,n=_,d=pt,b=ft,P=M)=>{var x;u==null||u.clearAllBox(),u==null||u.clearAllSphere(),m==null||m.updatePolygonList(t,n),m==null||m.updatePointList(d),m==null||m.updateLineList(b),u==null||u.generateBoxes(t),u==null||u.generateSpheres(d),(x=D==null?void 0:D.store)==null||x.updateCurrentSegment(P),mt(t)},Tt=()=>{$(void 0),et(void 0),it(void 0),ot(void 0)},mt=(t,n)=>te(void 0,null,function*(){var d;if(!u)return;const b=u.pointCloudObject;if(!!b)try{const P=yield u.getHighlightIndexByMappingImgList({mappingImgList:n!=null?n:T,points:b.geometry.attributes.position.array}),x=yield u==null?void 0:u.highlightOriginPointCloud(t,P);return x&&((d=m==null?void 0:m.pointCloudInstance)==null||d.updateColor(x)),x}catch(P){console.error(P)}});return{selectedID:dt,pointCloudBoxList:e,pointCloudSphereList:L,displayPointCloudList:q,displaySphereList:pt,displayLineList:ft,selectedIDs:v,setPointCloudResult:a,setSelectedIDs:c,addPointCloudBox:r,addPointCloudSphere:i,setPointCloudSphereList:A,valid:W,selectedPointCloudBox:o,setPointCloudValid:p,addSelectedID:I,addHighlightID:Z,selectedAllBoxes:H,topViewInstance:m,setTopViewInstance:$,sideViewInstance:tt,setSideViewInstance:et,backViewInstance:nt,setBackViewInstance:it,mainViewInstance:u,setMainViewInstance:ot,polygonList:_,setPolygonList:j,rectList:y,setRectList:f,addRectIn2DView:w,removeRectIn2DView:O,updateRectIn2DView:S,lineList:C,setLineList:St,zoom:Y,setZoom:xt,history:Rt,toggleAttributesVisible:Et,hideAttributes:g,setHideAttributes:E,reRender:Mt,attrPanelLayout:rt,setAttrPanelLayout:Vt,syncAllViewPointCloudColor:mt,defaultAttribute:st,setDefaultAttribute:At,pointCloudPattern:z,setPointCloudPattern:_t,selectSpecAttr:zt,globalPattern:G,setGlobalPattern:t=>{G!==t&&(jt(Kt),Bt(t),t===J.Detection&&lt(void 0))},ptSegmentInstance:D,setPtSegmentInstance:lt,segmentation:M,setSegmentation:Ot,clearAllDetectionInstance:Tt,highlight2DDataList:T,setHighlight2DDataList:Ht,cuboidBoxIn2DView:X,setCuboidBoxIn2DView:Dt,imageSizes:at,cacheImageNodeSize:Ft,highlightIDs:R,setHighlightIDs:k,unlinkImageItems:Gt,removeRectByPointCloudBoxId:ct,removeRectBySpecifyId:V,addRectFromPointCloudBoxByImageName:ut}},[W,v,e,L,_,C,y,m,tt,nt,u,Y,g,rt,st,z,G,D,M,T,X,at,R,ct,V,ut]);Q(()=>{var o,r,i;(o=h==null?void 0:h.setPointCloudBoxList)==null||o.call(h,e),(r=h==null?void 0:h.setHighlightIDs)==null||r.call(h,R),(i=h==null?void 0:h.setSelectedIDs)==null||i.call(h,v)},[e,v,R]),Q(()=>{var o;(o=h==null?void 0:h.setPtCtx)==null||o.call(h,B)},[B]);const kt=()=>{const o=e.filter(c=>g.includes(c.attribute)),{setSelectedIDs:r,reRender:i}=B,p=o.map(c=>c.id);p.length>0&&r(v.filter(c=>!p.includes(c))),i()};return Q(()=>{var o,r,i,p;kt(),(r=(o=m==null?void 0:m.toolInstance)==null?void 0:o.setHiddenAttributes)==null||r.call(o,g),(p=(i=D==null?void 0:D.store)==null?void 0:i.setHiddenAttributes)==null||p.call(i,g)},[g]),gt.createElement(wt.Provider,{value:B},l)};export{wt as PointCloudContext,ee as PointCloudProvider};
@@ -0,0 +1 @@
1
+ import c,{useState as C,useRef as v,useContext as y,useCallback as m,useMemo as N,useEffect as R}from"react";import{useLatest as d}from"ahooks";import{PointCloudContext as D}from"../PointCloudContext.js";import S from"../../../assets/annotation/icon_link.svg.js";import V from"../../../assets/annotation/icon_unlink.svg.js";const g={width:16,height:16},b=e=>{e.imageName||console.warn("missing imageName");const[t,f]=C(!0),r=v(e.imageName);r.current=e.imageName;const{unlinkImageItems:l,addRectFromPointCloudBoxByImageName:w,removeRectByPointCloudBoxId:h}=y(D),I=d(w),k=d(h),i=m(n=>{const s=r.current;if(!s){console.warn("invalid image name");return}f(n),n?k.current(s):I.current(s)},[]),u=m(()=>{i(!t)},[i,t]),x=N(()=>{var n;if(!e.is2DView||e.is2DView||!e.is2DView)return null;const o={zIndex:(n=e.zIndex)!=null?n:999,position:"absolute",top:16,right:16+28+12,background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,cursor:"pointer"};return c.createElement("div",{style:o,onClick:u},t&&c.createElement("img",{src:S,style:g}),!t&&c.createElement("img",{src:V,style:g}))},[t,e.is2DView,e.zIndex,u]),a=m(()=>{if(!e.is2DView)return;const n=r.current;if(!n){console.warn("invalid image name");return}const o=new Set(l).has(n)===!1;i(o)},[e.is2DView,l,i]);return R(()=>{a()},[a]),{rendered:x,isLinking:t,swapSwitch:i,syncIsLinking:a}};export{b as default};
@@ -1 +1 @@
1
- import{EPointCloudName as nt,MathUtils as B,getCuboidFromPointCloudBox as Mt}from"@labelbee/lb-annotation";import{EPerspectiveView as J,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Gt,DEFAULT_SPHERE_PARAMS as Jt}from"@labelbee/lb-utils";import{useContext as Qt}from"react";import{PointCloudContext as Xt}from"../PointCloudContext.js";import{useSingleBox as Yt}from"./useSingleBox.js";import{useSphere as qt}from"./useSphere.js";import{useSelector as Kt,useDispatch as $t}from"../../../store/ctx.js";import to from"../../../utils/StepUtils.js";import{jsonParser as it,getRectPointCloudBox as oo}from"../../../utils/index.js";import{PreDataProcess as st,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as eo}from"./useHistory.js";import{usePolygon as no}from"./usePolygon.js";import{useLatest as io}from"ahooks";var so=Object.defineProperty,ro=Object.defineProperties,lo=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable,xt=(e,t,i)=>t in e?so(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,L=(e,t)=>{for(var i in t||(t={}))ao.call(t,i)&&xt(e,i,t[i]);if(ht)for(var i of ht(t))co.call(t,i)&&xt(e,i,t[i]);return e},O=(e,t)=>ro(e,lo(t)),rt=(e,t,i)=>new Promise((d,o)=>{var a=u=>{try{c(i.next(u))}catch(h){o(h)}},g=u=>{try{c(i.throw(u))}catch(h){o(h)}},c=u=>u.done?d(u.value):Promise.resolve(u.value).then(a,g);c((i=i.apply(e,t)).next())});const q=5,K=90,mt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(e,t,i,d,o)=>{const{x:a,y:g}=V.transferCanvas2World(e,t),{defaultZ:c}=Jt,u={center:{x:a,y:g,z:c},id:e.id},h=d?L(L({},d),u):O(L({},u),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},dt=(e,t,i,d,o,a)=>{let g=e.pointList.map(v=>V.transferCanvas2World(v,t)),c=0,u=1,h={};if(i){const v=i.getSensesPointZAxisInPolygon(g,void 0,a);a&&v.fittedCoordinates.length>0&&(g=v.fittedCoordinates),c=(v.maxZ+v.minZ)/2,u=v.maxZ-v.minZ,h={count:v.zCount}}const[m,I,W]=g,z=B.getLineCenterPoint([m,W]),T=B.getLineLength(m,I),R=B.getLineLength(I,W),E=B.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,u=d.depth);const j={center:{x:z.x,y:z.y,z:c},width:a?R+mt:R,height:a?T+mt:T,depth:u,rotation:E,id:e.id},N=L(d?L(L({},d),j):O(L({},j),{attribute:"",valid:!0}),h);o&&Object.assign(N,o);const F=g.map(v=>V.transferWorld2Canvas(v,t));return{boxParams:N,newPointList:F}},Lt=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x-d.x,y:i.center.y,z:i.center.z-d.y}})},yt=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,h]=t.pointList,m=B.getLineCenterPoint([o,g]),I=B.getLineCenterPoint([c,h]),z={x:{x:m.x-I.x,y:m.y-I.y}.x,y:0,z:m.y-I.y},T=B.getLineLength(o,a),R=B.getLineLength(c,u),E=T-R,j=B.getLineLength(a,g),N=B.getLineLength(u,h),F=j-N,{newBoxParams:v}=d.getNewBoxBySideUpdate(z,F,E,i);return v},uo=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x,y:i.center.y-d.x,z:i.center.z-d.y}})},po=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,h]=t.pointList,m=B.getLineCenterPoint([o,g]),I=B.getLineCenterPoint([c,h]),z={x:{x:m.x-I.x,y:m.y-I.y}.x,y:0,z:m.y-I.y},T=B.getLineLength(o,a),R=B.getLineLength(c,u),E=T-R,j=B.getLineLength(a,g),N=B.getLineLength(u,h),F=j-N;let{newBoxParams:v}=d.getNewBoxByBackUpdate(z,F,E,i);return v},vt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,J.Left);c.setInitCameraPosition(u);const{point2d:h,zoom:m}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=m,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(m),g.setResult([O(L(L({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{width:q,depth:q});const{cameraPositionVector:g}=a.updateOrthoCamera(e,J.Left);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,J.Back);c.setInitCameraPosition(u);const{point2d:h,zoom:m}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=m,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(m),g.setResult([O(L(L({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{height:q,depth:q});const{cameraPositionVector:g}=a.updateOrthoCamera(e,J.Back);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,i,d)=>{if(!i||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,J.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=i,{point2d:g}=a.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},at=(e,t,i,d)=>{var o,a;if(!i||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:g,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),h=[...g.polygonList],m=h.find(I=>I.id===t.id);m?(m.pointList=u,m.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(a=e.valid)!=null?a:!0}),g.setResultAndSelectedID(h,t.id)},go=()=>{const e=Qt(Xt),{topViewInstance:t,sideViewInstance:i,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:g,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:h,pointCloudSphereList:m,hideAttributes:I,setHighlight2DDataList:W,cuboidBoxIn2DView:z,imageSizes:T}=e,{addHistory:R,initHistory:E,pushHistoryUnderUpdatePolygon:j}=eo(),{selectedPolygon:N}=no(),{getPointCloudSphereByID:F,updatePointCloudSphere:v,selectedSphere:Q}=qt(),{currentData:Z,config:S}=Kt(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:it(to.getCurrentStepInfo(p,s).config)}}),H=$t(),St=io(z),$=n=>{if(!St.current){const{mappingImgList:s=[]}=Z,p=s.map(r=>oo({pointCloudBox:n,mappingData:r,imageSizes:T}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:_,updateSelectedBox:Dt,updateSelectedBoxes:tt,getPointCloudByID:_t}=Yt({generateRects:$}),ct=_==null?void 0:_.info;if(!t||!i||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ot=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},kt=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const P=lt(n,s,ot,void 0,f);c(n.id);const x=g(P);X(y.Top,n,P,p,x,S),R({newSphereParams:P})},Rt=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var P,x;const C={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};r===!0&&Object.assign(C,{trackID:V.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:m})});const D=t==null?void 0:t.toolInstance,w=L({},n);let{boxParams:b,newPointList:A}=dt(w,s,ot,void 0,C,f);b=H(st({tool:nt.PointCloud,dataList:[b],stepConfig:S,action:"viewUpdateBox"}))[0],f&&(A==null?void 0:A.length)&&(w.pointList=A);const k=I.includes(w.attribute);$(b);const G=a(b),et=(x=e==null?void 0:e.polygonList)!=null?x:[];t==null||t.updatePolygonList(G!=null?G:[],et),k?c([]):(c(b.id),D.selection.setSelectedIDs(w.id),M({omitView:y.Top,polygon:w,boxParams:b,zoom:l,newPointCloudBoxList:G}),f&&at(b,w,t,o)),R({newBoxParams:b})},At=n=>{const{boxID:s,imageName:p,width:r,height:l,x:f,y:P}=n,x=h.find(C=>C.id===s);if(x==null?void 0:x.rects){const{rects:C=[]}=x,D=C.find(w=>w.imageName===p);if(D){let w=C;const b=O(L({},D),{width:r,height:l,x:f,y:P});w=C.map(k=>k===D?b:k);const A=O(L({},x),{rects:w}),U=h.map(k=>k===x?A:k);return t==null||t.updatePolygonList(U!=null?U:[]),U}}},Ut=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(u.length===0||!f)){if(n||(_==null?void 0:_.info)){const P=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(u[0]);const x=f.selectedPolygon;if(u.length===1&&P){M({omitView:y.Top,polygon:x,boxParams:P,newPointCloudBoxList:s});return}}if((p||Q)&&u.length===1){const P=p!=null?p:Q;f.setSelectedID(u[0]);const x=f.selectedPoint;P&&X(y.Top,x,P,void 0,r,S)}}},ut=(n,s,p)=>{if(ct){let r,l;switch(p){case y.Back:r=po;break;case y.Side:r=yt;break;default:r=yt;break}if(l=r(n,s,ct,i.pointCloudInstance),o){const{count:D}=o.getSensesPointZAxisInPolygon(Mt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:D})}const P=H(st({tool:nt.PointCloud,dataList:[l],stepConfig:S,action:"viewUpdateBox"}))[0],x=l.valid!==P.valid;l=P;const C=Dt(l);return l=C.find(D=>D.id===l.id),M({omitView:x?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:C}),C}},pt=(n,s,p)=>{if(Q){let r,l;switch(p){case y.Back:r=uo;break;case y.Side:r=Lt;break;default:r=Lt;break}l=r(n,s,Q);const f=v(l);return X(p,n,l,void 0,f,S),f}},zt=(n,s)=>{pt(n,s,y.Side)},Tt=(n,s)=>{pt(n,s,y.Back)},jt=(n,s)=>{ut(n,s,y.Side)},Nt=(n,s)=>{ut(n,s,y.Back)},Et=(n,s)=>{const p=F(n.id),r=lt(n,s,ot,p),l=v(r);X(y.Top,n,r,void 0,l,S)},Ft=(n,s)=>{if(N){const r=L({},n[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,s)),j(r);return}let p=n.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=dt(r,s,t.pointCloudInstance,l);return f});if(p=H(st({tool:nt.PointCloud,dataList:p,stepConfig:S,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=tt(p);M({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=tt(p);r&&e.syncAllViewPointCloudColor(r)}},Ht=n=>{var s,p,r,l,f;if(_){const P=Number(n.widthDefault),x=Number(n.depthDefault),C=Number(n.heightDefault),D=_==null?void 0:_.info.trackID,b=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===D),A={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},U=b.pointList.map(Y=>V.transferCanvas2World(Y,A)),k=B.getModifiedRectangleCoordinates(U,C,P),G=k[0],et=k[2],gt=B.getLineCenterPoint([G,et]),Wt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:gt.x,y:gt.y,z:Wt+x/2},width:P,height:C,depth:x,valid:!0}),Zt=tt([ft]);M({omitView:y["3D"],polygon:b,boxParams:ft,newPointCloudBoxList:Zt})}},X=(n,s,p,r,l,f)=>rt(void 0,null,function*(){const P=Z==null?void 0:Z.url,x={[y.Side]:()=>{vt(p,s,i,P,f)},[y.Back]:()=>{d&&bt(p,s,d,P,f)},[y.Top]:()=>{It(p,s,t,o)}};Object.keys(x).forEach(C=>{C!==n&&x[C]()}),r&&(o==null||o.updateCameraZoom(r)),Ot(p)}),M=n=>rt(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:f}=n,P=Z==null?void 0:Z.url;f&&(yield e.syncAllViewPointCloudColor(f));const x={[y.Side]:()=>{Bt(r,p,i,P)},[y.Back]:()=>{d&&wt(r,p,d,P)},[y.Top]:()=>{at(r,p,t,o)}};Object.keys(x).forEach(C=>{C!==s&&x[C]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(r)});return{topViewAddSphere:kt,topViewAddBox:Rt,topViewSelectedChanged:Ut,topViewUpdatePoint:Et,sideViewUpdatePoint:zt,backViewUpdatePoint:Tt,topViewUpdateBox:Ft,sideViewUpdateBox:jt,backViewUpdateBox:Nt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>rt(void 0,[...n],function*(s=Z){var p,r,l,f,P,x;if(!(s==null?void 0:s.url)||!o)return;W([]),Ct(H,!0),Pt(H,!0),yield o.loadPCDFile(s.url,(p=S==null?void 0:S.radius)!=null?p:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let C=[],D=[],w=[],b=[];o.updateTopCamera();const A=(l=(r=it(s.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(A),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),s.result){if(C=V.getBoxParamsFromResultList(s.result),(C==null?void 0:C.length)>0&&s.isPreResult&&(S==null?void 0:S.lowerLimitPointsNumInBox)>0){C=yield o==null?void 0:o.filterPreResult(s.url,S,C);const U=it(s.result);U[Gt].result=C,s.result=JSON.stringify(U),e.setPointCloudResult(C)}w=V.getPolygonListFromResultList(s.result),D=V.getLineListFromResultList(s.result),b=V.getSphereParamsFromResultList(s.result),t.updateData(s.url,s.result,{radius:(x=S==null?void 0:S.radius)!=null?x:K}),o==null||o.generateBoxes(C),o==null||o.generateSpheres(b),yield e.syncAllViewPointCloudColor(C,[])}E({pointCloudBoxList:C,polygonList:w,lineList:D,pointCloudSphereList:b}),Ct(H,!1),Pt(H,!1)}),updateViewsByDefaultSize:Ht,generateRects:$,update2DViewRect:At}};export{bt as syncBackViewByPoint,vt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,go as usePointCloudViews};
1
+ import{EPointCloudName as it,TagUtils as Gt,MathUtils as w,getCuboidFromPointCloudBox as Jt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Qt,DEFAULT_SPHERE_PARAMS as Xt}from"@labelbee/lb-utils";import{useContext as Yt}from"react";import{PointCloudContext as qt}from"../PointCloudContext.js";import{useSingleBox as Kt}from"./useSingleBox.js";import{useSphere as $t}from"./useSphere.js";import{useSelector as to,useDispatch as oo}from"../../../store/ctx.js";import eo from"../../../utils/StepUtils.js";import{jsonParser as st,generatePointCloudBoxRects as no}from"../../../utils/index.js";import{PreDataProcess as rt,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as io}from"./useHistory.js";import{usePolygon as so}from"./usePolygon.js";import{useLatest as ro}from"ahooks";var lo=Object.defineProperty,ao=Object.defineProperties,co=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,xt=(e,t,s)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,L=(e,t)=>{for(var s in t||(t={}))uo.call(t,s)&&xt(e,s,t[s]);if(mt)for(var s of mt(t))po.call(t,s)&&xt(e,s,t[s]);return e},O=(e,t)=>ao(e,co(t)),lt=(e,t,s)=>new Promise((a,o)=>{var c=p=>{try{u(s.next(p))}catch(m){o(m)}},g=p=>{try{u(s.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((s=s.apply(e,t)).next())});const q=5,K=90,ht=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,t,s,a,o)=>{const{x:c,y:g}=V.transferCanvas2World(e,t),{defaultZ:u}=Xt,p={center:{x:c,y:g,z:u},id:e.id},m=a?L(L({},a),p):O(L({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},at=(e,t,s,a,o,c)=>{let g=e.pointList.map(b=>V.transferCanvas2World(b,t)),u=0,p=1,m={};if(s){const b=s.getSensesPointZAxisInPolygon(g,void 0,c);c&&b.fittedCoordinates.length>0&&(g=b.fittedCoordinates),u=(b.maxZ+b.minZ)/2,p=b.maxZ-b.minZ,m={count:b.zCount}}const[v,D,H]=g,A=w.getLineCenterPoint([v,H]),k=w.getLineLength(v,D),R=w.getLineLength(D,H),j=w.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const U={center:{x:A.x,y:A.y,z:u},width:c?R+ht:R,height:c?k+ht:k,depth:p,rotation:j,id:e.id},T=L(a?L(L({},a),U):O(L({},U),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(b=>V.transferWorld2Canvas(b,t));return{boxParams:T,newPointList:N}},vt=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},s),{center:{x:s.center.x-a.x,y:s.center.y,z:s.center.z-a.y}})},Lt=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T,{newBoxParams:b}=a.getNewBoxBySideUpdate(A,N,j,s);return b},go=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},s),{center:{x:s.center.x,y:s.center.y-a.x,z:s.center.z-a.y}})},fo=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T;let{newBoxParams:b}=a.getNewBoxByBackUpdate(A,N,j,s);return b},yt=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Left);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{width:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Left);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Back);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{height:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Back);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,s,a)=>{if(!s||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=s,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},ct=(e,t,s,a)=>{var o,c;if(!s||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=s,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],v=m.find(D=>D.id===t.id);v?(v.pointList=p,v.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),g.setResultAndSelectedID(m,t.id)},Co=()=>{const e=Yt(qt),{topViewInstance:t,sideViewInstance:s,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:v,hideAttributes:D,setHighlight2DDataList:H,cuboidBoxIn2DView:A,imageSizes:k}=e,{addHistory:R,initHistory:j,pushHistoryUnderUpdatePolygon:U}=io(),{selectedPolygon:T}=so(),{getPointCloudSphereByID:N,updatePointCloudSphere:b,selectedSphere:J}=$t(),{currentData:W,config:B}=to(i=>{const{stepList:n,step:d,imgList:r,imgIndex:l}=i.annotation;return{currentData:r[l],config:st(eo.getCurrentStepInfo(d,n).config)}}),E=oo(),Dt=ro(A),$=i=>{const{enableAutoMap2DRect:n=!1}=B;if(!Dt.current||n){const{mappingImgList:d=[]}=W;no({pointCloudBox:i,mappingImgList:d,imageSizes:k})}},{selectedBox:_,updateSelectedBox:St,updateSelectedBoxes:tt,getPointCloudByID:_t}=Kt({generateRects:$}),ut=_==null?void 0:_.info;if(!t||!s||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},Ot=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},Rt=({newPoint:i,size:n,zoom:d,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const P=dt(i,n,ot,void 0,f);u(i.id);const C=g(P);Q(y.Top,i,P,d,C,B),R({newSphereParams:P})},At=({polygon:i,size:n,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var P,C,x;const S={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};r===!0&&Object.assign(S,{trackID:V.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:v})});const F=t==null?void 0:t.toolInstance,I=L({},i);let{boxParams:h,newPointList:z}=at(I,n,ot,void 0,S,f);h=E(rt({tool:it.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],f&&(z==null?void 0:z.length)&&(I.pointList=z);const nt=D.includes(I.attribute);$(h);const M=c(h),X=(C=e==null?void 0:e.polygonList)!=null?C:[];h.subAttribute=Gt.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(x=B==null?void 0:B.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(M!=null?M:[],X),nt?u([]):(u(h.id),F.selection.setSelectedIDs(I.id),Z({omitView:y.Top,polygon:I,boxParams:h,zoom:l,newPointCloudBoxList:M}),f&&ct(h,I,t,o)),R({newBoxParams:h})},kt=i=>{const{boxID:n,imageName:d,width:r,height:l,x:f,y:P}=i,C=m.find(h=>h.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(h=>h.imageName===d))return;const S=C.rects.map(h=>h.imageName===d?O(L({},h),{width:r,height:l,x:f,y:P}):h),F=O(L({},C),{rects:S}),I=m.map(h=>h.id===n?F:h);return t==null||t.updatePolygonList(I!=null?I:[]),I},Ut=i=>{const{boxID:n,imageName:d}=i,r=m.find(C=>C.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(C=>C.imageName!==d),f=O(L({},r),{rects:l}),P=m.map(C=>C.id===n?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},Tt=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(i||(_==null?void 0:_.info)){const P=i!=null?i:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){Z({omitView:y.Top,polygon:C,boxParams:P,newPointCloudBoxList:n});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(y.Top,C,P,void 0,r,B)}}},pt=(i,n,d)=>{if(ut){let r,l;switch(d){case y.Back:r=fo;break;case y.Side:r=Lt;break;default:r=Lt;break}if(l=r(i,n,ut,s.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(Jt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:S})}const P=E(rt({tool:it.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const x=St(l);return l=x.find(S=>S.id===l.id),Z({omitView:C?void 0:d,polygon:i,boxParams:l,newPointCloudBoxList:x}),x}},gt=(i,n,d)=>{if(J){let r,l;switch(d){case y.Back:r=go;break;case y.Side:r=vt;break;default:r=vt;break}l=r(i,n,J);const f=b(l);return Q(d,i,l,void 0,f,B),f}},zt=(i,n)=>{gt(i,n,y.Side)},jt=(i,n)=>{gt(i,n,y.Back)},Nt=(i,n)=>{pt(i,n,y.Side)},Et=(i,n)=>{pt(i,n,y.Back)},Ft=(i,n)=>{const d=N(i.id),r=dt(i,n,ot,d),l=b(r);Q(y.Top,i,r,void 0,l,B)},Ht=(i,n)=>{if(T){const r=L({},i[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,n)),U(r);return}let d=i.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=at(r,n,t.pointCloudInstance,l);return f});if(d=E(rt({tool:it.PointCloud,dataList:d,stepConfig:B,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=i[0],l=tt(d);Z({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=tt(d);r&&e.syncAllViewPointCloudColor(r)}},Wt=i=>{var n,d,r,l,f;if(_){const P=Number(i.widthDefault),C=Number(i.depthDefault),x=Number(i.heightDefault),S=_==null?void 0:_.info.trackID,I=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===S),h={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},z=I.pointList.map(Y=>V.transferCanvas2World(Y,h)),et=w.getModifiedRectangleCoordinates(z,x,P),nt=et[0],M=et[2],X=w.getLineCenterPoint([nt,M]),Zt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:X.x,y:X.y,z:Zt+C/2},width:P,height:x,depth:C,valid:!0}),Mt=tt([ft]);Z({omitView:y["3D"],polygon:I,boxParams:ft,newPointCloudBoxList:Mt})}},Q=(i,n,d,r,l,f)=>lt(void 0,null,function*(){const P=W==null?void 0:W.url,C={[y.Side]:()=>{yt(d,n,s,P,f)},[y.Back]:()=>{a&&bt(d,n,a,P,f)},[y.Top]:()=>{It(d,n,t,o)}};Object.keys(C).forEach(x=>{x!==i&&C[x]()}),r&&(o==null||o.updateCameraZoom(r)),Ot(d)}),Z=i=>lt(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:f}=i,P=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const C={[y.Side]:()=>{Bt(r,d,s,P)},[y.Back]:()=>{a&&wt(r,d,a,P)},[y.Top]:()=>{ct(r,d,t,o)}};Object.keys(C).forEach(x=>{x!==n&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(r)});return{topViewAddSphere:Rt,topViewAddBox:At,topViewSelectedChanged:Tt,topViewUpdatePoint:Ft,sideViewUpdatePoint:zt,backViewUpdatePoint:jt,topViewUpdateBox:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=V.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>lt(void 0,[...i],function*(n=W){var d,r,l,f,P,C;if(!(n==null?void 0:n.url)||!o)return;H([]),Ct(E,!0),Pt(E,!0),yield o.loadPCDFile(n.url,(d=B==null?void 0:B.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],S=[],F=[],I=[];o.updateTopCamera();const h=(l=(r=st(n.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(h),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),n.result){if(x=V.getBoxParamsFromResultList(n.result),(x==null?void 0:x.length)>0&&n.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(n.url,B,x);const z=st(n.result);z[Qt].result=x,n.result=JSON.stringify(z),e.setPointCloudResult(x)}F=V.getPolygonListFromResultList(n.result),S=V.getLineListFromResultList(n.result),I=V.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(C=B==null?void 0:B.radius)!=null?C:K}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(I),yield e.syncAllViewPointCloudColor(x,[])}j({pointCloudBoxList:x,polygonList:F,lineList:S,pointCloudSphereList:I}),Ct(E,!1),Pt(E,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:kt,remove2DViewRect:Ut}};export{bt as syncBackViewByPoint,yt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,Co as usePointCloudViews};
@@ -1 +1 @@
1
- import{useContext as S,useMemo as P}from"react";import{PointCloudContext as I}from"../PointCloudContext.js";import{cTool as E}from"@labelbee/lb-annotation";import{useHistory as x}from"./useHistory.js";import{EPointCloudPattern as C}from"@labelbee/lb-utils";const{EToolName:t,EPolygonPattern:p}=E,A=()=>{const{topViewInstance:r,sideViewInstance:a,backViewInstance:u,mainViewInstance:e,setPointCloudResult:v,setPointCloudSphereList:h,setPolygonList:m,pointCloudPattern:c,setPointCloudPattern:n,syncAllViewPointCloudColor:b,globalPattern:l,setLineList:w}=S(I),{pushHistoryWithList:y}=x(),L=()=>{e==null||e.clearAllBox(),e==null||e.clearAllSphere(),e==null||e.render(),v([]),m([]),h([]),w([]),r==null||r.toolScheduler.clearStatusAndResult(),b([]),y({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},i=()=>{a==null||a.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()},f=d=>{if(d===c)return;const s=[r,a,u];switch(d){case t.Rect:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(p.Rect)}),n(t.Rect);break;case t.Polygon:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(p.Normal)}),n(t.Polygon);break;case t.Point:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.Point)}),n(t.Point);break;case t.Line:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.Line)}),n(t.Line);break}},g=P(()=>l===C.Detection,[l]),R=P(()=>l===C.Segmentation,[l]);return{clearAllResult:L,updatePointCloudPattern:f,pointCloudPattern:c,isPointCloudDetectionPattern:g,isPointCloudSegmentationPattern:R}};export{A as useStatus};
1
+ import{useContext as I,useMemo as P}from"react";import{PointCloudContext as E}from"../PointCloudContext.js";import{cTool as x}from"@labelbee/lb-annotation";import{useHistory as A}from"./useHistory.js";import{EPointCloudPattern as C}from"@labelbee/lb-utils";const{EToolName:o,EPolygonPattern:p}=x,T=()=>{const{topViewInstance:r,sideViewInstance:a,backViewInstance:u,mainViewInstance:e,setPointCloudResult:v,setPointCloudSphereList:h,setPolygonList:m,setRectList:b,pointCloudPattern:c,setPointCloudPattern:n,syncAllViewPointCloudColor:L,globalPattern:l,setLineList:w}=I(E),{pushHistoryWithList:y}=A(),f=()=>{e==null||e.clearAllBox(),e==null||e.clearAllSphere(),e==null||e.render(),v([]),m([]),h([]),w([]),b([]),r==null||r.toolScheduler.clearStatusAndResult(),L([]),y({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},i=()=>{a==null||a.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()},g=d=>{if(d===c)return;const s=[r,a,u];switch(d){case o.Rect:i(),s.forEach(t=>{t==null||t.switchToCanvas(o.PointCloudPolygon),t==null||t.toolInstance.setPattern(p.Rect)}),n(o.Rect);break;case o.Polygon:i(),s.forEach(t=>{t==null||t.switchToCanvas(o.PointCloudPolygon),t==null||t.toolInstance.setPattern(p.Normal)}),n(o.Polygon);break;case o.Point:i(),s.forEach(t=>{t==null||t.switchToCanvas(o.Point)}),n(o.Point);break;case o.Line:i(),s.forEach(t=>{t==null||t.switchToCanvas(o.Line)}),n(o.Line);break}},R=P(()=>l===C.Detection,[l]),S=P(()=>l===C.Segmentation,[l]);return{clearAllResult:f,updatePointCloudPattern:g,pointCloudPattern:c,isPointCloudDetectionPattern:R,isPointCloudSegmentationPattern:S}};export{T as useStatus};
@@ -1 +1 @@
1
- import{getClassName as n}from"../../utils/dom.js";import t,{useContext as I,useState as T,useEffect as p}from"react";import y from"./PointCloud3DView.js";import k from"./PointCloudBackView.js";import B from"./PointCloudTopView.js";import F from"./PointCloudSideView.js";import _ from"./PointCloud2DView.js";import R from"./PointCloudListener.js";import M from"./PointCloudSegmentListener.js";import G from"./PointCloudSegment.js";import O from"./PointCloudSegmentStatus.js";import Z from"./PointCloudSegmentToolbar.js";import U from"./PointCloudSegment2DView.js";import{connect as W}from"react-redux";import{LabelBeeContext as $,useDispatch as q}from"../../store/ctx.js";import{AnnotatedAttributesPanelFixedLeft as z,AnnotatedAttributesPanelFixedRight as H}from"../../views/MainView/toolFooter/AnnotatedAttributes/index.js";import{PointCloudContext as J}from"./PointCloudContext.js";import{PointCloudUtils as K,EPointCloudPattern as Q}from"@labelbee/lb-utils";import{useCustomToolInstance as X}from"../../hooks/annotation.js";import{jsonParser as Y}from"../../utils/index.js";import{a2MapStateToProps as tt}from"../../store/annotation/map.js";import g from"classnames";import et from"./components/sideAndBackOverView/index.js";import{SetLoadPCDFileLoading as ot}from"../../store/annotation/actionCreators.js";const nt=E=>{const{currentData:a,imgList:L,drawLayerSlot:c,checkMode:i,intelligentFit:S,imgIndex:w,config:x,measureVisible:b}=E,e=I(J),{globalPattern:d,setGlobalPattern:j,selectedIDs:C}=e,v=q(),[l,P]=T(!1),V=(C==null?void 0:C.length)>0&&l,h=Y(a.result),{toolInstanceRef:r,clearToolInstance:D}=X({basicInfo:h});if(p(()=>{r.current.setPointCloudGlobalPattern=o=>{o!==d&&(j(o),e.clearAllDetectionInstance(),D())}},[d]),p(()=>{var o;if(ot(v,!0),a){const{boxParamsList:s,polygonList:m,lineList:u,sphereParamsList:A,segmentation:N}=K.parsePointCloudCurrentResult((o=a==null?void 0:a.result)!=null?o:"");e.setPointCloudResult(s),e.setPolygonList(m),e.setLineList(u),e.setPointCloudSphereList(A),e.setSegmentation(N)}},[w]),p(()=>{r.current.exportData=()=>[e.pointCloudBoxList,{valid:e.valid}],r.current.exportCustomData=()=>{var o,s,m,u;return{resultPolygon:(o=e.polygonList)!=null?o:[],resultLine:(s=e.lineList)!=null?s:[],resultPoint:(m=e.pointCloudSphereList)!=null?m:[],segmentation:(u=e.segmentation)!=null?u:[]}}},[e.pointCloudBoxList,e.valid,e.polygonList,e.lineList,e.pointCloudSphereList,e.ptSegmentInstance,e.segmentation]),L.length===0)return null;if(d===Q.Segmentation)return t.createElement(t.Fragment,null,t.createElement(M,{checkMode:i,toolInstanceRef:r}),t.createElement(Z,null),t.createElement("div",{className:n("point-cloud-layout")},t.createElement(G,{checkMode:i}),t.createElement(U,null)),t.createElement(O,{config:x}),c==null?void 0:c({direct:!0}));let f=t.createElement("div",{className:n("point-cloud-container","left-bottom")},t.createElement(k,{checkMode:i}),t.createElement(F,{checkMode:i}));return l&&(f=t.createElement(et,{selectAndEnlarge:V,checkMode:i})),t.createElement(t.Fragment,null,t.createElement(R,{checkMode:i,toolInstanceRef:r}),t.createElement("div",{className:n("point-cloud-layout"),onContextMenu:o=>o.preventDefault()},t.createElement("div",{className:n("point-cloud-wrapper")},t.createElement(z,null),t.createElement("div",{className:n("point-cloud-content")},t.createElement("div",{className:n("point-cloud-container","left")},t.createElement(y,null),f),t.createElement("div",{className:g({[n("point-cloud-container","right")]:!0,[n("point-cloud-container","rightZoom")]:l})},t.createElement(B,{drawLayerSlot:c,checkMode:i,intelligentFit:S,setIsEnlargeTopView:P,onExitZoom:()=>{P(!1)},isEnlargeTopView:l}),t.createElement("div",{className:g({[n("point-cloud-container","right-bottom")]:!l,[n("point-cloud-container","right-bottom-floatLeft")]:l})},t.createElement(_,{isEnlargeTopView:l,thumbnailWidth:l?300:455,checkMode:i,measureVisible:b})))),t.createElement(H,null))))};var it=W(tt,null,null,{context:$})(nt);export{it as default};
1
+ import{getClassName as n}from"../../utils/dom.js";import t,{useContext as T,useState as y,useEffect as C}from"react";import _ from"./PointCloud3DView.js";import k from"./PointCloudBackView.js";import B from"./PointCloudTopView.js";import F from"./PointCloudSideView.js";import R from"./PointCloud2DView.js";import M from"./PointCloudListener.js";import G from"./PointCloudSegmentListener.js";import O from"./PointCloudSegment.js";import Z from"./PointCloudSegmentStatus.js";import U from"./PointCloudSegmentToolbar.js";import W from"./PointCloudSegment2DView.js";import{connect as $}from"react-redux";import{LabelBeeContext as q,useDispatch as z}from"../../store/ctx.js";import{AnnotatedAttributesPanelFixedLeft as H,AnnotatedAttributesPanelFixedRight as J}from"../../views/MainView/toolFooter/AnnotatedAttributes/index.js";import{PointCloudContext as K}from"./PointCloudContext.js";import{PointCloudUtils as Q,EPointCloudPattern as X}from"@labelbee/lb-utils";import{useCustomToolInstance as Y}from"../../hooks/annotation.js";import{jsonParser as tt}from"../../utils/index.js";import{a2MapStateToProps as et}from"../../store/annotation/map.js";import L from"classnames";import ot from"./components/sideAndBackOverView/index.js";import{SetLoadPCDFileLoading as nt}from"../../store/annotation/actionCreators.js";const it=E=>{const{currentData:a,imgList:S,drawLayerSlot:d,checkMode:i,intelligentFit:w,imgIndex:x,config:b,measureVisible:j}=E,e=T(K),{globalPattern:p,setGlobalPattern:v,selectedIDs:P}=e,V=z(),[l,f]=y(!1),h=(P==null?void 0:P.length)>0&&l,D=tt(a.result),{toolInstanceRef:r,clearToolInstance:A}=Y({basicInfo:D});if(C(()=>{r.current.setPointCloudGlobalPattern=o=>{o!==p&&(v(o),e.clearAllDetectionInstance(),A())}},[p]),C(()=>{var o;if(nt(V,!0),a){const{boxParamsList:s,polygonList:m,lineList:u,sphereParamsList:c,segmentation:N,rectList:I}=Q.parsePointCloudCurrentResult((o=a==null?void 0:a.result)!=null?o:"");e.setPointCloudResult(s),e.setPolygonList(m),e.setLineList(u),e.setPointCloudSphereList(c),e.setRectList(I),e.setSegmentation(N)}},[x]),C(()=>{r.current.exportData=()=>[e.pointCloudBoxList,{valid:e.valid}],r.current.exportCustomData=()=>{var o,s,m,u,c;return{resultPolygon:(o=e.polygonList)!=null?o:[],resultLine:(s=e.lineList)!=null?s:[],resultPoint:(m=e.pointCloudSphereList)!=null?m:[],resultRect:(u=e.rectList)!=null?u:[],segmentation:(c=e.segmentation)!=null?c:[]}}},[e.pointCloudBoxList,e.rectList,e.valid,e.polygonList,e.lineList,e.pointCloudSphereList,e.ptSegmentInstance,e.segmentation]),S.length===0)return null;if(p===X.Segmentation)return t.createElement(t.Fragment,null,t.createElement(G,{checkMode:i,toolInstanceRef:r}),t.createElement(U,null),t.createElement("div",{className:n("point-cloud-layout")},t.createElement(O,{checkMode:i}),t.createElement(W,null)),t.createElement(Z,{config:b}),d==null?void 0:d({direct:!0}));let g=t.createElement("div",{className:n("point-cloud-container","left-bottom")},t.createElement(k,{checkMode:i}),t.createElement(F,{checkMode:i}));return l&&(g=t.createElement(ot,{selectAndEnlarge:h,checkMode:i})),t.createElement(t.Fragment,null,t.createElement(M,{checkMode:i,toolInstanceRef:r}),t.createElement("div",{className:n("point-cloud-layout"),onContextMenu:o=>o.preventDefault()},t.createElement("div",{className:n("point-cloud-wrapper")},t.createElement(H,null),t.createElement("div",{className:n("point-cloud-content")},t.createElement("div",{className:n("point-cloud-container","left")},t.createElement(_,null),g),t.createElement("div",{className:L({[n("point-cloud-container","right")]:!0,[n("point-cloud-container","rightZoom")]:l})},t.createElement(B,{drawLayerSlot:d,checkMode:i,intelligentFit:w,setIsEnlargeTopView:f,onExitZoom:()=>{f(!1)},isEnlargeTopView:l}),t.createElement("div",{className:L({[n("point-cloud-container","right-bottom")]:!l,[n("point-cloud-container","right-bottom-floatLeft")]:l})},t.createElement(R,{isEnlargeTopView:l,thumbnailWidth:l?300:455,checkMode:i,measureVisible:j})))),t.createElement(J,null))))};var lt=$(et,null,null,{context:q})(it);export{lt as default};
@@ -0,0 +1 @@
1
+ import o,{useEffect as g}from"react";import{Checkbox as y,Select as u,Divider as x}from"antd";import{I18nextProvider as S,useTranslation as _}from"react-i18next";import E from"../attributeList/index.js";import{i18n as v}from"@labelbee/lb-utils";var h=Object.defineProperty,s=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,f=(t,a,r)=>a in t?h(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r,P=(t,a)=>{for(var r in a||(a={}))w.call(a,r)&&f(t,r,a[r]);if(s)for(var r of s(a))O.call(a,r)&&f(t,r,a[r]);return t};const k={margin:"12px 20px 8px",fontSize:14,fontWeight:500,wordWrap:"break-word"},C=t=>{const{subAttributeList:a,setSubAttribute:r,getValue:i,lang:p}=t,{t:c}=_();g(()=>{var e;p&&((e=v)==null||e.changeLanguage(p))},[]);const m=(e,n)=>{if(Array.isArray(n)){r(e,n.join(";"));return}r(e,n)},d=e=>{const n=i(e);return(e==null?void 0:e.isMulti)?n?n==null?void 0:n.split(";"):[]:n};return o.createElement(o.Fragment,null,a.map(e=>{var n;return(e==null?void 0:e.subSelected)&&o.createElement("div",{style:{marginTop:12},key:e.value},o.createElement("div",{style:k},c("SubAttribute"),"-",e.key),((n=e.subSelected)==null?void 0:n.length)<5?(e==null?void 0:e.isMulti)?o.createElement(y.Group,{style:{padding:"0px 20px 16px 16px"},options:e.subSelected.map(l=>({label:l.key,value:l.value})),value:d(e),onChange:l=>m(e.value,l)}):o.createElement(E,{list:e.subSelected.map(l=>({label:l.key,value:l.value})),selectedAttribute:i(e),num:"-",forbidColor:!0,forbidDefault:!0,attributeChanged:l=>r(e.value,l),style:{marginBottom:12}}):o.createElement(u,{style:{margin:"0px 20px 16px 16px",width:"87%"},mode:(e==null?void 0:e.isMulti)?"multiple":void 0,value:d(e),placeholder:c("PleaseSelect"),onChange:l=>m(e.value,l),allowClear:!0},e.subSelected.map(l=>o.createElement(u.Option,{key:l.value,value:l.value},l.key))),o.createElement(x,{style:{margin:0}}))}))},L=t=>o.createElement(S,{i18n:v},o.createElement(C,P({},t)));export{L as default};
@@ -1 +1 @@
1
- import{MathUtils as C,CommonToolUtils as F,uuid as A,AttributeUtils as k}from"@labelbee/lb-annotation";import{jsonParser as P}from"../../../utils/index.js";import{precisionAdd as I,precisionMinus as V,isImageValue as R}from"../../../utils/audio.js";import{message as m}from"antd";import b from"lodash";import g from"react";import _ from"./index.module.scss.js";import{VideoClipToolContextProvider as B}from"./VideoClipToolContext.js";import{EClipStatus as o,ETimeSliceType as T,PER_SLICE_CHANGE as v,SLICE_MIN_TIME as x}from"./constant.js";import{VideoPlayer as j}from"../../videoPlayer/index.js";import M from"./components/videoTimeSlicesOverVideo/index.js";import U from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as L}from"../../videoPlayer/utils.js";class N extends g.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=b.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===o.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:l,start:u,type:a}=this.state.result[this.selectedSliceIndex],n=C.withinRange(I(u,t),[0,V(a===T.Time?s:l,v)]);this.updateSelectedSliceTimeProperty(n,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===o.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],l=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===T.Time){m.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:u,start:a}=s,n=C.withinRange(I(u,t),[I(a,v),l]);this.updateSelectedSliceTimeProperty(n,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:b.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!F.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-v);break;case"=":this.updateSelectedSliceTimeStartByPer(v);break;case"[":this.updateSelectedSliceTimeEndByPer(-v);break;case"]":this.updateSelectedSliceTimeEndByPer(v);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===o.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==o.Clipping)return;const s=t.findIndex(l=>l.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:o.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:l,selectedAttribute:u}=this.state,a=l!==o.Clipping;let n=a?o.Clipping:o.Stop,{result:d,selectedID:c,textValue:p}=this.state;const h=b.cloneDeep(d),S=t||((e=this.videoPlayer)==null?void 0:e.currentTime),y=(i=this.videoPlayer)==null?void 0:i.duration;if(y===void 0||S===void 0)return;const w=L(S,2);if(a){const f=A();c=f,h.push({start:w,end:null,attribute:u,textAttribute:this.defaultTextAttribute,duration:y,id:f,type:T.Period}),p=this.defaultTextAttribute}else{const f=h.findIndex(E=>E.id===c),D=h[f];D&&(S-D.start<x?(h.splice(f,1),m.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${x}s`),n=o.Stop,c="",p=""):(h[f].end=L(S,2),(s=this.videoPlayer)==null||s.pause(),m.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${d.length}`)))}this.setState({clipStatus:n,result:h,selectedID:c,textValue:p}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:l,selectedAttribute:u,selectedID:a}=this.state,n=A(),d=b.cloneDeep(l),c=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;d.push({start:c,end:c,attribute:u,textAttribute:this.defaultTextAttribute,id:n,type:T.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const p={result:d,selectedID:n,textValue:this.defaultTextAttribute},h=d.find(S=>S.id===a);this.isClipping&&h?(delete p.selectedID,delete p.textValue,m.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(p),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===o.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,l;const{result:u}=this.state,a=u.find(n=>n.id===t);if(a){const n=a.duration,d=e==="left",c=d?"start":"end",p=d?-n*i:n*i,h=d?[0,Math.max(((s=a.end)!=null?s:0)-x,0)]:[a.start+x,n],S=C.withinRange(p+((l=a==null?void 0:a[c])!=null?l:0),h);a[c]=S,this.throttledUpdateTime(S)}this.setState({result:[...u]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:l,videoError:u,valid:a,currentTime:n}=this.state;return g.createElement("div",{className:_.clipContainer},g.createElement(j,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:a,setVideoRef:d=>{this.videoPlayer=d},showVideoTrack:!u,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),g.createElement(M,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:l,currentTime:n,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&g.createElement("i",{className:_.clipping,style:{backgroundImage:U}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(l=>l.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const u=P(s[i].result)[`step_${this.stepInfo().step}`],a=(u==null?void 0:u.result)||[],n=R(s[i].result||"[]");this.setState({result:a,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:o.Stop,valid:n},()=>{this.updateSidebar(),n||m.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(l=>l.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(l=>l.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:o.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===o.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return k.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return P((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return g.createElement(B,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}export{N as default};
1
+ import{MathUtils as C,CommonToolUtils as F,uuid as A,AttributeUtils as R}from"@labelbee/lb-annotation";import{jsonParser as P}from"../../../utils/index.js";import{precisionAdd as y,precisionMinus as k,isImageValue as V}from"../../../utils/audio.js";import{message as m}from"antd";import b from"lodash";import g from"react";import _ from"./index.module.scss.js";import{VideoClipToolContextProvider as B}from"./VideoClipToolContext.js";import{EClipStatus as d,ETimeSliceType as T,PER_SLICE_CHANGE as v,SLICE_MIN_TIME as x}from"./constant.js";import{VideoPlayer as j}from"../../videoPlayer/index.js";import M from"./components/videoTimeSlicesOverVideo/index.js";import U from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as L}from"../../videoPlayer/utils.js";class N extends g.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=b.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:l,start:u,type:a}=this.state.result[this.selectedSliceIndex],n=C.withinRange(y(u,t),[0,k(a===T.Time?s:l,v)]);this.updateSelectedSliceTimeProperty(n,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],l=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===T.Time){m.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:u,start:a}=s,n=C.withinRange(y(u,t),[y(a,v),l]);this.updateSelectedSliceTimeProperty(n,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:b.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!F.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-v);break;case"=":this.updateSelectedSliceTimeStartByPer(v);break;case"[":this.updateSelectedSliceTimeEndByPer(-v);break;case"]":this.updateSelectedSliceTimeEndByPer(v);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===d.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==d.Clipping)return;const s=t.findIndex(l=>l.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:d.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i;if(typeof((e=this.props)==null?void 0:e.annotationBefore)=="function"){(i=this.props)==null||i.annotationBefore(()=>this.setClipResult(t));return}this.setClipResult(t)},this.setClipResult=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:l,selectedAttribute:u}=this.state,a=l!==d.Clipping;let n=a?d.Clipping:d.Stop,{result:o,selectedID:c,textValue:h}=this.state;const p=b.cloneDeep(o),S=t||((e=this.videoPlayer)==null?void 0:e.currentTime),I=(i=this.videoPlayer)==null?void 0:i.duration;if(I===void 0||S===void 0)return;const w=L(S,2);if(a){const f=A();c=f,p.push({start:w,end:null,attribute:u,textAttribute:this.defaultTextAttribute,duration:I,id:f,type:T.Period}),h=this.defaultTextAttribute}else{const f=p.findIndex(E=>E.id===c),D=p[f];D&&(S-D.start<x?(p.splice(f,1),m.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${x}s`),n=d.Stop,c="",h=""):(p[f].end=L(S,2),(s=this.videoPlayer)==null||s.pause(),m.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${o.length}`)))}this.setState({clipStatus:n,result:p,selectedID:c,textValue:h}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:l,selectedAttribute:u,selectedID:a}=this.state,n=A(),o=b.cloneDeep(l),c=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;o.push({start:c,end:c,attribute:u,textAttribute:this.defaultTextAttribute,id:n,type:T.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const h={result:o,selectedID:n,textValue:this.defaultTextAttribute},p=o.find(S=>S.id===a);this.isClipping&&p?(delete h.selectedID,delete h.textValue,m.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${o.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(h),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===d.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,l;const{result:u}=this.state,a=u.find(n=>n.id===t);if(a){const n=a.duration,o=e==="left",c=o?"start":"end",h=o?-n*i:n*i,p=o?[0,Math.max(((s=a.end)!=null?s:0)-x,0)]:[a.start+x,n],S=C.withinRange(h+((l=a==null?void 0:a[c])!=null?l:0),p);a[c]=S,this.throttledUpdateTime(S)}this.setState({result:[...u]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:l,videoError:u,valid:a,currentTime:n}=this.state;return g.createElement("div",{className:_.clipContainer},g.createElement(j,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:a,setVideoRef:o=>{this.videoPlayer=o},showVideoTrack:!u,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),g.createElement(M,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:l,currentTime:n,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&g.createElement("i",{className:_.clipping,style:{backgroundImage:U}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(l=>l.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const u=P(s[i].result)[`step_${this.stepInfo().step}`],a=(u==null?void 0:u.result)||[],n=V(s[i].result||"[]");this.setState({result:a,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:d.Stop,valid:n},()=>{this.updateSidebar(),n||m.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(l=>l.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(l=>l.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:d.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===d.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return R.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return P((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return g.createElement(B,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}export{N as default};
@@ -1 +1 @@
1
- import h from"react";import{TagUtils as p,CommonToolUtils as m,uuid as v}from"@labelbee/lb-annotation";import{jsonParser as c}from"../../../utils/index.js";import{VideoPlayer as f}from"../../videoPlayer/index.js";import{VideoTagLayer as y}from"../../videoPlayer/VideoTagLayer.js";import g from"lodash";import{getKeyCodeNumber as L}from"../../videoPlayer/utils.js";class R extends h.Component{constructor(s){super(s);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,e)=>{const l=e?this.state.tagResult.map(i=>((i==null?void 0:i.result[e])&&delete i.result[e],i)):[];this.setState({tagResult:l},()=>this.emitEvent("render"))},this.exportData=()=>{var t,e;const l=(e=(t=this.videoPlayer)==null?void 0:t.duration)!=null?e:0;return[this.state.tagResult,{valid:this.state.valid,duration:l}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,e={})=>{var l,i;const{isMulti:n}=t,{key:o,value:r}=t.value;if(n){let a=(i=(l=e[o])==null?void 0:l.split(";"))!=null?i:[];a.includes(r)?a=a.filter(u=>u!==r):a.push(r);const d=new Set(a);return e[o]=Array.from(d).join(";"),g.pickBy(e,u=>u)}return e[o]=e[o]===r?void 0:r,g.pickBy(e,a=>a)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,e)=>{this.setLabelBySelectedList(t,e)},this.keydown=t=>{var e;const l=L(t.keyCode);if(l){const i=l-1;if(((e=this.config.inputList)==null?void 0:e.length)===1){this.labelSelectedList=[0,i],this.setLabel(0,i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],i],this.setLabel(this.labelSelectedList[0],i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[i],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:e,imgIndex:l,stepInfo:i}=t;if(!e[l])return;const n=c(e[l].result),o=n[`step_${i.step}`],r=this.getInitResultList();this.setState({tagResult:o?o==null?void 0:o.result:r,valid:(n==null?void 0:n.valid)===void 0?!0:n.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return p.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var s;return c((s=this.props.stepInfo)==null?void 0:s.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var s;return(s=this.state.tagResult[0])!=null?s:{}}get valid(){return this.state.valid}singleOn(s,t){this.fns[s]=t}on(s,t){this.singleOn(s,t)}unbindAll(s){delete this.fns[s]}getTagResultByCode(s,t){var e,l,i;try{const n=(l=(e=this.config)==null?void 0:e.inputList)!=null?l:[],o=(n==null?void 0:n.length)>1,r=t!==void 0?s:0,a=t!==void 0?t:s,d=o?n[r]:n[0],u=((i=d.subSelected)!=null?i:[])[a];if(d&&u)return{value:{key:d.value,value:u.value},isMulti:d.isMulti}}catch(n){return}}setLabelBySelectedList(s,t){var e,l,i,n;const o=this.getTagResultByCode(s,t);if(o){const r=this.combineResult(o,(l=(e=this.state.tagResult[0])==null?void 0:e.result)!=null?l:{}),a=[{sourceID:m.getSourceID(),id:(n=(i=this.currentTagResult)==null?void 0:i.id)!=null?n:v(8,62),result:r}];this.setState({tagResult:a},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(s){return s.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(s),!0}render(){var s;const{imgIndex:t,imgList:e,pageForward:l,pageJump:i,pageBackward:n}=this.props,{tagResult:o,valid:r}=this.state;return h.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},h.createElement(f,{imgIndex:t,imgList:e,pageBackward:n,pageForward:l,pageJump:i,valid:r,setVideoRef:a=>{this.videoPlayer=a},dataLoaded:this.props.onVideoLoaded,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),h.createElement(y,{result:o,inputList:(s=this.config)==null?void 0:s.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}export{R as TagToolInstanceAdaptor};
1
+ import h from"react";import{TagUtils as m,CommonToolUtils as f,uuid as v}from"@labelbee/lb-annotation";import{jsonParser as g}from"../../../utils/index.js";import{VideoPlayer as y}from"../../videoPlayer/index.js";import{VideoTagLayer as L}from"../../videoPlayer/VideoTagLayer.js";import p,{cloneDeep as R}from"lodash";import{getKeyCodeNumber as b}from"../../videoPlayer/utils.js";class S extends h.Component{constructor(e){super(e);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,s)=>{const n=s?this.state.tagResult.map(i=>((i==null?void 0:i.result[s])&&delete i.result[s],i)):[];this.setState({tagResult:n},()=>this.emitEvent("render"))},this.exportData=()=>{var t,s;const n=(s=(t=this.videoPlayer)==null?void 0:t.duration)!=null?s:0;return[this.state.tagResult,{valid:this.state.valid,duration:n}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,s={})=>{var n,i;const l=R(s),{isMulti:a}=t,{key:r,value:d}=t.value;if(a){let o=(i=(n=l[r])==null?void 0:n.split(";"))!=null?i:[];o.includes(d)?o=o.filter(c=>c!==d):o.push(d);const u=new Set(o);return l[r]=Array.from(u).join(";"),p.pickBy(l,c=>c)}return l[r]=l[r]===d?void 0:d,p.pickBy(l,o=>o)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,s)=>{this.setLabelBySelectedList(t,s)},this.keydown=t=>{var s;const n=b(t.keyCode);if(n){const i=n-1;if(((s=this.config.inputList)==null?void 0:s.length)===1){this.labelSelectedList=[0,i],this.setLabel(0,i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],i],this.setLabel(this.labelSelectedList[0],i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[i],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:s,imgIndex:n,stepInfo:i}=t;if(!s[n])return;const l=g(s[n].result),a=l[`step_${i.step}`],r=this.getInitResultList();this.setState({tagResult:a?a==null?void 0:a.result:r,valid:(l==null?void 0:l.valid)===void 0?!0:l.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return m.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var e;return g((e=this.props.stepInfo)==null?void 0:e.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var e;return(e=this.state.tagResult[0])!=null?e:{}}get valid(){return this.state.valid}singleOn(e,t){this.fns[e]=t}on(e,t){this.singleOn(e,t)}unbindAll(e){delete this.fns[e]}getTagResultByCode(e,t){var s,n,i;try{const l=(n=(s=this.config)==null?void 0:s.inputList)!=null?n:[],a=(l==null?void 0:l.length)>1,r=t!==void 0?e:0,d=t!==void 0?t:e,o=a?l[r]:l[0],u=((i=o.subSelected)!=null?i:[])[d];if(o&&u)return{value:{key:o.value,value:u.value},isMulti:o.isMulti}}catch(l){return}}setLabelBySelectedList(e,t){var s,n,i,l,a,r;const d=this.getTagResultByCode(e,t);if(d){const o=this.combineResult(d,(n=(s=this.state.tagResult[0])==null?void 0:s.result)!=null?n:{}),u=[{sourceID:f.getSourceID(),id:(l=(i=this.currentTagResult)==null?void 0:i.id)!=null?l:v(8,62),result:o}];if(typeof((a=this.props)==null?void 0:a.annotationBefore)=="function"){(r=this.props)==null||r.annotationBefore(()=>this.setState({tagResult:u},()=>this.emitEvent("render")));return}this.setState({tagResult:u},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(e){return e.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(e),!0}render(){var e;const{imgIndex:t,imgList:s,pageForward:n,pageJump:i,pageBackward:l}=this.props,{tagResult:a,valid:r}=this.state;return h.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},h.createElement(y,{imgIndex:t,imgList:s,pageBackward:l,pageForward:n,pageJump:i,valid:r,setVideoRef:d=>{this.videoPlayer=d},dataLoaded:this.props.onVideoLoaded,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),h.createElement(L,{result:a,inputList:(e=this.config)==null?void 0:e.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}export{S as TagToolInstanceAdaptor};
package/es/index.css CHANGED
@@ -132,6 +132,12 @@
132
132
  .index-module_outputDisplay__5dS48 .index-module_content__Iml6l .markdown-body {
133
133
  font-size: 14px;
134
134
  }
135
+
136
+ .index-module_tip__NFru6 {
137
+ margin-bottom: 8px;
138
+ color: rgba(0, 0, 0, 0.45);
139
+ font-size: 14px;
140
+ }
135
141
  .index-module_tagList__cvWor {
136
142
  padding: 0px 16px 16px 16px;
137
143
  }
@@ -720,6 +726,16 @@
720
726
  font-family: SourceHanSansCN-Medium;
721
727
  font-size: 14px;
722
728
  }
729
+ .index-module_label__xE6hM .index-module_labelText__Zg1c4 {
730
+ display: flex;
731
+ overflow: hidden;
732
+ width: 60%;
733
+ align-items: center;
734
+ }
735
+ .index-module_label__xE6hM .index-module_labelText__Zg1c4 .index-module_titleText__BRM44 {
736
+ max-width: calc(100% - 20px);
737
+ overflow: hidden;
738
+ }
723
739
  .index-module_label__xE6hM .index-module_required__iElYl::before {
724
740
  display: inline-block;
725
741
  margin-right: 4px;
@@ -732,6 +748,7 @@
732
748
  .index-module_label__xE6hM .index-module_extra__PW5Qk {
733
749
  float: right;
734
750
  margin-right: 5px;
751
+ width: 40%;
735
752
  }
736
753
 
737
754
  .index-module_textareaContainer__dTIv4 {
@@ -862,6 +879,7 @@
862
879
  flex-wrap: wrap;
863
880
  align-items: center;
864
881
  justify-content: center;
882
+ overflow: hidden;
865
883
  }
866
884
  .index-module_placeholderHotkey__0SKPo .text {
867
885
  color: #333;
@@ -878,7 +896,10 @@
878
896
 
879
897
  .index-module_attribute__g8Vbl {
880
898
  height: 22px;
881
- padding: 2px 8px;
899
+ padding: 0px 8px;
900
+ width: max-content;
901
+ max-width: 100%;
902
+ margin-left: auto;
882
903
  }
883
904
 
884
905
  .index-module_clearIcon__ZBZqI {
@@ -1141,7 +1162,8 @@
1141
1162
  }
1142
1163
  .index-module_clipSidebar__z2E8x .index-module_attributeList__2wnCE {
1143
1164
  flex: 1;
1144
- overflow: auto;
1165
+ overflow-x: hidden;
1166
+ overflow-y: auto;
1145
1167
  }
1146
1168
  .index-module_clipSidebar__z2E8x .index-module_attributeList__2wnCE .sensebee-radio-group,
1147
1169
  .index-module_clipSidebar__z2E8x .index-module_attributeList__2wnCE .sensebee-radio-group-no-limit-height .ant-radio-group {
@@ -1870,11 +1892,14 @@
1870
1892
  -ms-user-select: none;
1871
1893
  user-select: none;
1872
1894
  }
1895
+ .generalOperation .generalOperation-col {
1896
+ display: flex;
1897
+ justify-content: center;
1898
+ }
1873
1899
  .generalOperation .item {
1874
1900
  text-align: center;
1875
- flex: 1;
1876
1901
  box-sizing: border-box;
1877
- width: 100%;
1902
+ width: 100px;
1878
1903
  height: 100%;
1879
1904
  display: flex;
1880
1905
  flex-direction: column;
@@ -3077,15 +3102,12 @@
3077
3102
  display: block;
3078
3103
  }
3079
3104
  .bee-sidebar__content__NLPList__item__text {
3080
- flex: 1 1;
3081
- padding: 16px;
3082
3105
  font-weight: 400;
3083
3106
  font-size: 12px;
3084
3107
  line-height: 20px;
3085
3108
  color: #666666;
3086
- overflow: hidden;
3087
- text-overflow: ellipsis;
3088
- white-space: nowrap;
3109
+ padding: 16px;
3110
+ width: 100%;
3089
3111
  }
3090
3112
  .bee-sidebar__content__NLPList__item__active {
3091
3113
  background-color: #eeefff;
package/es/index.js CHANGED
@@ -1 +1 @@
1
- export{default as AnnotationView}from"./components/AnnotationView/index.js";export{default as PointCloudAnnotationView}from"./components/AnnotationView/pointCloudAnnotationView.js";export{default as QuestionView}from"./components/LLMToolView/questionView/index.js";export{default as TextContent}from"./components/NLPToolView/textContent/index.js";import{i18n as l}from"@labelbee/lb-utils";export{i18n}from"@labelbee/lb-utils";import r,{useState as c,useImperativeHandle as m}from"react";import{I18nextProvider as f}from"react-i18next";import{Provider as u}from"react-redux";import x from"./App.js";import w from"./configureStore.js";import{PageBackward as P,PageForward as v,PageJump as T}from"./store/annotation/actionCreators.js";export{VideoTagTool}from"./components/videoAnnotate/videoTagTool/TagToolInstanceAdaptorI18nProvider.js";import{PointCloudProvider as g}from"./components/pointCloudView/PointCloudContext.js";import{LabelBeeContext as j}from"./store/ctx.js";export{default as PredictTracking}from"./components/predictTracking/predictTrackingIcon/index.js";export{default as LLMToolView}from"./components/LLMToolView/index.js";export{default as SwitchCuboidBoxIn2DView}from"./views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.js";export{default as MeasureCanvas}from"./components/measureCanvas/index.js";export{default as AnnotatedBox}from"./views/MainView/sidebar/PointCloudToolSidebar/components/annotatedBox/index.js";export{FindTrackIDIndexInCheckMode as FindTrackIDIndex}from"./views/MainView/sidebar/PointCloudToolSidebar/components/findTrackIDIndex/index.js";export{EDataFormatType,ELLMDataType,EStepType,ESubmitType,componentCls,prefix}from"./constant/index.js";var _=Object.defineProperty,I=Object.defineProperties,b=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,p=(o,e,t)=>e in o?_(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,A=(o,e)=>{for(var t in e||(e={}))V.call(e,t)&&p(o,t,e[t]);if(s)for(var t of s(e))C.call(e,t)&&p(o,t,e[t]);return o},O=(o,e)=>I(o,b(e));const n=w(),E=(o,e)=>{const[t,d]=c();return m(e,()=>({toolInstance:t,annotationEngine:n.getState().annotation.annotationEngine,pageBackwardActions:()=>n.dispatch(P()),pageForwardActions:()=>n.dispatch(v()),pageJump:a=>{const i=~~a-1;n.dispatch(T(i))},hello:()=>alert("hello labelBee!!!")}),[t]),r.createElement(u,{store:n,context:j},r.createElement(f,{i18n:l},r.createElement(g,null,r.createElement(x,O(A({},o),{setToolInstance:a=>{var i;d(a),(i=o.onLoad)==null||i.call(o,{toolInstance:a})}})))))};var S=r.forwardRef(E);export{S as default,n as store};
1
+ export{default as AnnotationView}from"./components/AnnotationView/index.js";export{default as PointCloudAnnotationView}from"./components/AnnotationView/pointCloudAnnotationView.js";export{default as QuestionView}from"./components/LLMToolView/questionView/index.js";export{default as TextContent}from"./components/NLPToolView/textContent/index.js";import{i18n as l}from"@labelbee/lb-utils";export{i18n}from"@labelbee/lb-utils";import r,{useState as c,useImperativeHandle as m}from"react";import{I18nextProvider as u}from"react-i18next";import{Provider as f}from"react-redux";import x from"./App.js";import w from"./configureStore.js";import{PageBackward as P,PageForward as v,PageJump as T}from"./store/annotation/actionCreators.js";export{VideoTagTool}from"./components/videoAnnotate/videoTagTool/TagToolInstanceAdaptorI18nProvider.js";import{PointCloudProvider as g}from"./components/pointCloudView/PointCloudContext.js";import{LabelBeeContext as j}from"./store/ctx.js";export{default as PredictTracking}from"./components/predictTracking/predictTrackingIcon/index.js";export{default as LLMToolView}from"./components/LLMToolView/index.js";export{default as SwitchCuboidBoxIn2DView}from"./views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.js";export{default as MeasureCanvas}from"./components/measureCanvas/index.js";export{default as AnnotatedBox}from"./views/MainView/sidebar/PointCloudToolSidebar/components/annotatedBox/index.js";export{FindTrackIDIndexInCheckMode as FindTrackIDIndex}from"./views/MainView/sidebar/PointCloudToolSidebar/components/findTrackIDIndex/index.js";export{WrapAudioPlayer as AudioPlayer}from"./components/audioPlayer/index.js";export{generatePointCloudBoxRects}from"./utils/index.js";export{default as SubAttributeList}from"./components/subAttributeList/index.js";export{EDataFormatType,ELLMDataType,EStepType,ESubmitType,componentCls,prefix}from"./constant/index.js";var b=Object.defineProperty,_=Object.defineProperties,I=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,p=(o,e,t)=>e in o?b(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,A=(o,e)=>{for(var t in e||(e={}))C.call(e,t)&&p(o,t,e[t]);if(s)for(var t of s(e))V.call(e,t)&&p(o,t,e[t]);return o},y=(o,e)=>_(o,I(e));const n=w(),L=(o,e)=>{const[t,d]=c();return m(e,()=>({toolInstance:t,annotationEngine:n.getState().annotation.annotationEngine,pageBackwardActions:()=>n.dispatch(P()),pageForwardActions:()=>n.dispatch(v()),pageJump:a=>{const i=~~a-1;n.dispatch(T(i))},hello:()=>alert("hello labelBee!!!")}),[t]),r.createElement(f,{store:n,context:j},r.createElement(u,{i18n:l},r.createElement(g,null,r.createElement(x,y(A({},o),{setToolInstance:a=>{var i;d(a),(i=o.onLoad)==null||i.call(o,{toolInstance:a})}})))))};var O=r.forwardRef(L);export{O as default,n as store};
@@ -1 +1 @@
1
- const T={INIT_ALL_STATE:"@@INIT_ALL_STATE",UPDATE_TOOL_INSTANCE:"@@UPDATE_TOOL_INSTANCE",UPDATE_IMG_LIST:"@@UPDATE_IMG_LIST",UPDATE_ANNOTATION_CONFIG:"@@UPDATE_ANNOTATION_CONFIG",LOAD_FILE_DATA:"@@LOAD_FILE_DATA",SUBMIT_FILE_DATA:"@@SUBMIT_FILE_DATA",SET_TASK_CONFIG:"@@SET_TASK_CONFIG",INIT_TOOL:"@@INIT_TOOL",SET_TOOL:"@@SET_TOOL",UPDATE_ON_SUBMIT:"@@UPDATE_ON_SUBMIT",UPDATE_ON_SAVE:"@@UPDATE_ON_SAVE",UPDATE_ON_PAGE_CHANGE:"@@UPDATE_ON_PAGE_CHANGE",UPDATE_ON_STEP_CHANGE:"@@UPDATE_ON_STEP_CHANGE",UPDATE_ROTATE:"@@UPDATE_ROTATE",UPDATE_GET_FILE_DATA:"@@UPDATE_GET_FILE_DATA",UPDATE_PAGE_SIZE:"@@UPDATE_PAGE_SIZE",UPDATE_LOAD_FILE_LIST:"@@UPDATE_LOAD_FILE_LIST",GET_FILE_DATA:"@@GET_FILE_DATA",SET_FILE_DATA:"@@SET_FILE_DATA",COPY_BACKWARD_RESULT:"@@COPY_BACKWARD_RESULT",SET_STEP:"@@SET_STEP",SUBMIT_RESULT:"@@SUBMIT_RESULT",SAVE_RESULT:"@@SAVE_RESULT",SET_BASIC_INDEX:"@@SET_BASIC_INDEX",CALC_STEP_PROGRESS:"@@CALC_STEP_PROGRESS",SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:"@@SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED",SKIP_BEFORE_PAGE_TURNING:"@@SKIP_BEFORE_PAGE_TURNING",UPDATE_BEFORE_ROTATE:"@@UPDATE_BEFORE_ROTATE",SET_LOADING:"@@SET_LOADING",SET_LOADPCDFILE_LOADING:"@@SET_LOADPCDFILE_LOADING",SET_POINT_CLOUD_LOADING:"@@SET_POINT_CLOUD_LOADING",SET_CHECK_MODE:"@@SET_CHECK_MODE",SET_TASK_STEP_LIST:"@@SET_TASK_STEP_LIST",UPDATE_ANNOTATION_VALID:"@@UPDATE_ANNOTATION_VALID",BATCH_UPDATE_TRACK_ID:"@@BATCH_UPDATE_TRACK_ID",BATCH_UPDATE_RESULT_BY_TRACK_ID:"@@BATCH_UPDATE_RESULT_BY_TRACK_ID",BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:"@@BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT",SET_PREDICT_RESULT_VISIBLE:"@@SET_PREDICT_RESULT_VISIBLE",SET_PREDICT_RESULT:"@@SET_PREDICT_RESULT",SET_HIGHLIGHT_ATTRIBUTE:"@@SET_HIGHLIGHT_ATTRIBUTE",UPDATE_PRE_DATA_PROCESS:"@@UPDATE_PRE_DATA_PROCESS"},_={UPDATE_IMG_ATTRIBUTE:"@@UPDATE_IMG_ATTRIBUTE",INIT_IMG_ATTRIBUTE:"@@INIT_IMG_ATTRIBUTE"},E={INIT_TOOL_STYLE_CONFIG:"@@INIT_TOOL_STYLE_CONFIG",UPDATE_TOOL_STYLE_CONFIG:"@@UPDATE_TOOL_STYLE_CONFIG"};export{T as ANNOTATION_ACTIONS,_ as IMAGE_ATTRIBUTE_ACTIONS,E as TOOL_STYLE_ACTIONS};
1
+ const T={INIT_ALL_STATE:"@@INIT_ALL_STATE",UPDATE_TOOL_INSTANCE:"@@UPDATE_TOOL_INSTANCE",UPDATE_IMG_LIST:"@@UPDATE_IMG_LIST",UPDATE_ANNOTATION_CONFIG:"@@UPDATE_ANNOTATION_CONFIG",LOAD_FILE_DATA:"@@LOAD_FILE_DATA",SUBMIT_FILE_DATA:"@@SUBMIT_FILE_DATA",SET_TASK_CONFIG:"@@SET_TASK_CONFIG",INIT_TOOL:"@@INIT_TOOL",SET_TOOL:"@@SET_TOOL",UPDATE_ON_SUBMIT:"@@UPDATE_ON_SUBMIT",UPDATE_ON_SAVE:"@@UPDATE_ON_SAVE",UPDATE_ON_PAGE_CHANGE:"@@UPDATE_ON_PAGE_CHANGE",UPDATE_ON_STEP_CHANGE:"@@UPDATE_ON_STEP_CHANGE",UPDATE_ROTATE:"@@UPDATE_ROTATE",UPDATE_GET_FILE_DATA:"@@UPDATE_GET_FILE_DATA",UPDATE_PAGE_SIZE:"@@UPDATE_PAGE_SIZE",UPDATE_LOAD_FILE_LIST:"@@UPDATE_LOAD_FILE_LIST",GET_FILE_DATA:"@@GET_FILE_DATA",SET_FILE_DATA:"@@SET_FILE_DATA",COPY_BACKWARD_RESULT:"@@COPY_BACKWARD_RESULT",SET_STEP:"@@SET_STEP",SUBMIT_RESULT:"@@SUBMIT_RESULT",SAVE_RESULT:"@@SAVE_RESULT",SET_BASIC_INDEX:"@@SET_BASIC_INDEX",CALC_STEP_PROGRESS:"@@CALC_STEP_PROGRESS",SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:"@@SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED",SKIP_BEFORE_PAGE_TURNING:"@@SKIP_BEFORE_PAGE_TURNING",UPDATE_BEFORE_ROTATE:"@@UPDATE_BEFORE_ROTATE",SET_LOADING:"@@SET_LOADING",SET_LOADPCDFILE_LOADING:"@@SET_LOADPCDFILE_LOADING",SET_POINT_CLOUD_LOADING:"@@SET_POINT_CLOUD_LOADING",SET_CHECK_MODE:"@@SET_CHECK_MODE",SET_TASK_STEP_LIST:"@@SET_TASK_STEP_LIST",UPDATE_ANNOTATION_VALID:"@@UPDATE_ANNOTATION_VALID",BATCH_UPDATE_TRACK_ID:"@@BATCH_UPDATE_TRACK_ID",BATCH_UPDATE_RESULT_BY_TRACK_ID:"@@BATCH_UPDATE_RESULT_BY_TRACK_ID",BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:"@@BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT",SET_PREDICT_RESULT_VISIBLE:"@@SET_PREDICT_RESULT_VISIBLE",SET_PREDICT_RESULT:"@@SET_PREDICT_RESULT",SET_HIGHLIGHT_ATTRIBUTE:"@@SET_HIGHLIGHT_ATTRIBUTE",UPDATE_PRE_DATA_PROCESS:"@@UPDATE_PRE_DATA_PROCESS",UPDATE_IMG_INDEX_BY_EXTERNAL:"@@UPDATE_IMG_INDEX_BY_EXTERNAL"},_={UPDATE_IMG_ATTRIBUTE:"@@UPDATE_IMG_ATTRIBUTE",INIT_IMG_ATTRIBUTE:"@@INIT_IMG_ATTRIBUTE"},E={INIT_TOOL_STYLE_CONFIG:"@@INIT_TOOL_STYLE_CONFIG",UPDATE_TOOL_STYLE_CONFIG:"@@UPDATE_TOOL_STYLE_CONFIG"};export{T as ANNOTATION_ACTIONS,_ as IMAGE_ATTRIBUTE_ACTIONS,E as TOOL_STYLE_ACTIONS};
@@ -1 +1 @@
1
- import{ANNOTATION_ACTIONS as a}from"../Actions.js";import{LoadFileAndFileData as O,getStepConfig as M}from"./reducer.js";import{ESubmitType as _}from"../../constant/index.js";import{EPageTurningOperation as y}from"../../data/enums/AnnotationSize.js";import j from"../../utils/PageOperator.js";import{jsonParser as K}from"../../utils/index.js";import{getBoxesByTrackID as V}from"../../components/predictTracking/previewResult/util.js";var v=(t,e,n)=>new Promise((o,r)=>{var i=u=>{try{d(n.next(u))}catch(p){r(p)}},s=u=>{try{d(n.throw(u))}catch(p){r(p)}},d=u=>u.done?o(u.value):Promise.resolve(u.value).then(i,s);d((n=n.apply(t,e)).next())});const N=(t,e)=>e.map(n=>t(n)),J=t=>t===y.Forward?_.Forward:t===y.Backward?_.Backward:t===y.Jump?_.Jump:_.Forward,Y=(t,e)=>{var n,o;const{imgList:r,imgIndex:i}=t,{dataSourceStep:s}=M(t.stepList,t.step);return((o=(n=K(r[i-1].result)[`step_${s}`])==null?void 0:n.result)==null?void 0:o.length)-1||e};function W(t){return{type:a.UPDATE_TOOL_INSTANCE,payload:{toolInstance:t}}}function x({stepList:t}){return{type:a.SET_TASK_STEP_LIST,payload:{stepList:t}}}function G({stepList:t,step:e}){return{type:a.SET_TASK_CONFIG,payload:{stepList:t,step:e}}}function P(t){return{type:a.UPDATE_ON_SUBMIT,payload:{onSubmit:t}}}function U(t){return{type:a.UPDATE_ON_SAVE,payload:{onSave:t}}}function L(t){return{type:a.UPDATE_ON_PAGE_CHANGE,payload:{onPageChange:t}}}function D(t){return{type:a.UPDATE_ON_STEP_CHANGE,payload:{onStepChange:t}}}function R(t){return{type:a.UPDATE_GET_FILE_DATA,payload:{getFileData:t}}}function C(t){return{type:a.UPDATE_PAGE_SIZE,payload:{pageSize:t}}}function m(t){return{type:a.UPDATE_LOAD_FILE_LIST,payload:{loadFileList:t}}}function X(){return{type:a.UPDATE_ROTATE}}function w(t){return{type:a.SKIP_BEFORE_PAGE_TURNING,payload:{skipBeforePageTurning:t}}}function g(t){return{type:a.UPDATE_BEFORE_ROTATE,payload:{beforeRotate:t}}}function h(t){return{type:a.UPDATE_PRE_DATA_PROCESS,payload:{preDataProcess:t}}}function q(){return{type:a.COPY_BACKWARD_RESULT}}function z({id:t,newID:e,rangeIndex:n,imgList:o}){return{type:a.BATCH_UPDATE_TRACK_ID,payload:{id:t,newID:e,rangeIndex:n,imgList:o}}}function Z(t,e,n){return{type:a.BATCH_UPDATE_RESULT_BY_TRACK_ID,payload:{id:t,newData:e,rangeIndex:n}}}function $(){return{type:a.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT,payload:{}}}const F=t=>({type:a.SET_CHECK_MODE,payload:{checkMode:t}}),B=t=>({type:a.SET_HIGHLIGHT_ATTRIBUTE,payload:{attribute:t}});function Q({onSubmit:t,onSave:e,onPageChange:n,onStepChange:o,getFileData:r,pageSize:i,loadFileList:s,step:d,stepList:u,skipBeforePageTurning:p,beforeRotate:T,checkMode:l,highlightAttribute:E,preDataProcess:A}){const c=[];return t&&c.push(P(t)),e&&c.push(U(e)),n&&c.push(L(n)),o&&c.push(D(o)),r&&c.push(R(r)),s&&c.push(m(s)),i&&c.push(C(i)),p&&c.push(w(p)),T&&c.push(g(T)),A&&c.push(h(A)),typeof l=="boolean"&&c.push(F(l)),c.push(B(E)),c.push(G({stepList:u,step:d})),c.push({type:a.CALC_STEP_PROGRESS}),c.push({type:a.INIT_TOOL}),H=>N(H,c)}function tt({onSubmit:t,onSave:e,onPageChange:n,onStepChange:o,getFileData:r,pageSize:i,loadFileList:s,stepList:d,beforeRotate:u,highlightAttribute:p,preDataProcess:T}){const l=[];return t&&l.push(P(t)),e&&l.push(U(e)),n&&l.push(L(n)),o&&l.push(D(o)),r&&l.push(R(r)),s&&l.push(m(s)),i&&l.push(C(i)),u&&l.push(g(u)),T&&l.push(h(T)),l.push(B(p)),l.push(x({stepList:d})),E=>N(E,l)}const et=(t,e)=>{var n;const o=e==null?void 0:e.findIndex(r=>(r==null?void 0:r.step)===t);return(n=e[o+1])==null?void 0:n.step},nt=t=>(e,n)=>{const{annotation:o}=n(),{step:r,stepList:i}=o,s=et(r,i);return[e(k(s,t))]},k=(t,e)=>(n,o)=>{var r,i;const{annotation:s}=o();(r=s==null?void 0:s.onStepChange)==null||r.call(s,t);const d=(i=s==null?void 0:s.imgIndex)!=null?i:0;return[n({type:a.SUBMIT_RESULT}),n({type:a.SUBMIT_FILE_DATA,payload:{submitType:_.StepChanged}}),n({type:a.SET_STEP,payload:{toStep:t}}),n({type:a.CALC_STEP_PROGRESS}),n(O(e!=null?e:d,0))]},f=t=>e=>[e({type:a.SUBMIT_RESULT}),e({type:a.SUBMIT_FILE_DATA,payload:{submitType:t}})],at=(t,e,n,o)=>[t(f(n)),t(O(e,o))],ot=(t,e)=>[t({type:a.SUBMIT_RESULT}),t({type:a.SET_BASIC_INDEX,payload:{basicIndex:e}})],rt=(t,e)=>{t({type:a.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED,payload:{triggerEventAfterIndexChanged:e}})},it=(t=!1)=>(e,n)=>S(e,n,y.Backward,t),st=(t=!1)=>(e,n)=>S(e,n,y.Forward,t),ut=(t,e=!1)=>(n,o)=>{if(t!==o().imgIndex)return S(n,o,y.Jump,e,t)},b=(t,e,n,o)=>v(void 0,null,function*(){var r;const{loadFileList:i,imgList:s,pageSize:d}=e().annotation,u=Math.floor(n/d);I(t,!0);try{const p=yield i(u,d);if(I(t,!1),!((r=p==null?void 0:p.fileList)==null?void 0:r.length)||!(p==null?void 0:p.total))throw new Error("fileList and total are required");const T=o?new Array(p.total):[...s];return T.splice(u*d,d,...p.fileList),t({type:a.UPDATE_IMG_LIST,payload:{imgList:T}}),!0}catch(p){I(t,!1),console.error(p)}}),S=(t,e,n,o=!1,r)=>v(void 0,null,function*(){var i;const s=e().annotation,{fileIndexChanged:d,fileIndex:u,basicIndexChanged:p,basicIndex:T}=j.getNextPageInfo(n,s,r),l=J(n);if(rt(t,o),d){if(s.loading||!s.imgList[u]&&!(yield b(t,e,u)))return;(i=s.onPageChange)==null||i.call(s,u);const E=l===_.Backward?Y(e().annotation,T):T;return at(t,u,l,E)}return p?ot(t,T):t(f(l))}),pt=t=>{t(f(_.Save)),t({type:a.SAVE_RESULT})},I=(t,e)=>{t({type:a.SET_LOADING,payload:{loading:e}})},lt=(t,e)=>{t({type:a.SET_LOADING,payload:{loading:e}})},dt=(t,e)=>{t({type:a.SET_LOADPCDFILE_LOADING,payload:{loadPCDFileLoading:e}})},ct=t=>{t({type:a.INIT_ALL_STATE,payload:{}})},Tt=(t,e)=>{t({type:a.SET_PREDICT_RESULT,payload:{result:e}})},_t=(t,e)=>{t({type:a.SET_PREDICT_RESULT_VISIBLE,payload:{visible:e}})},yt=(t,e)=>(n,o)=>{const{imgList:r,step:i}=o().annotation;return V(r,i,t,e)},Et=t=>(e,n)=>{var o,r;const{annotation:i}=n();return(r=(o=i==null?void 0:i.preDataProcess)==null?void 0:o.call(i,t))!=null?r:t.dataList};export{$ as BatchUpdateImgListResultByPredictResult,Z as BatchUpdateResultByTrackID,z as BatchUpdateTrackID,pt as ChangeSave,q as CopyBackWordResult,S as DispatcherTurning,yt as GetBoxesByID,ct as InitAnnotationState,Q as InitTaskData,it as PageBackward,st as PageForward,ut as PageJump,Et as PreDataProcess,I as SetAnnotationLoading,dt as SetLoadPCDFileLoading,lt as SetPointCloudLoading,Tt as SetPredictResult,_t as SetPredictResultVisible,G as SetTaskConfig,x as SetTaskStepList,nt as ToNextStep,f as ToSubmitFileData,g as UpdateBeforeRotate,F as UpdateCheckMode,R as UpdateGetFileData,m as UpdateGetFileList,B as UpdateHighlightAttribute,tt as UpdateInjectFunc,L as UpdateOnPageChange,U as UpdateOnSave,D as UpdateOnStepChange,P as UpdateOnSubmit,C as UpdatePageSize,h as UpdatePreDataProcess,k as UpdateProcessingStep,X as UpdateRotate,w as UpdateSkipBeforePageTurning,W as UpdateToolInstance,b as loadImgList};
1
+ import{ANNOTATION_ACTIONS as a}from"../Actions.js";import{LoadFileAndFileData as O,getStepConfig as K}from"./reducer.js";import{ESubmitType as E}from"../../constant/index.js";import{EPageTurningOperation as y}from"../../data/enums/AnnotationSize.js";import V from"../../utils/PageOperator.js";import{jsonParser as J}from"../../utils/index.js";import{getBoxesByTrackID as X}from"../../components/predictTracking/previewResult/util.js";var x=(t,e,n)=>new Promise((o,r)=>{var u=p=>{try{i(n.next(p))}catch(l){r(l)}},s=p=>{try{i(n.throw(p))}catch(l){r(l)}},i=p=>p.done?o(p.value):Promise.resolve(p.value).then(u,s);i((n=n.apply(t,e)).next())});const N=(t,e)=>e.map(n=>t(n)),Y=t=>t===y.Forward?E.Forward:t===y.Backward?E.Backward:t===y.Jump?E.Jump:E.Forward,W=(t,e)=>{var n,o,r;const{imgList:u,imgIndex:s}=t,{dataSourceStep:i}=K(t.stepList,t.step);return((r=(o=J((n=u[s-1])==null?void 0:n.result)[`step_${i}`])==null?void 0:o.result)==null?void 0:r.length)-1||e};function q(t){return{type:a.UPDATE_TOOL_INSTANCE,payload:{toolInstance:t}}}function G({stepList:t}){return{type:a.SET_TASK_STEP_LIST,payload:{stepList:t}}}function w({stepList:t,step:e}){return{type:a.SET_TASK_CONFIG,payload:{stepList:t,step:e}}}function U(t){return{type:a.UPDATE_ON_SUBMIT,payload:{onSubmit:t}}}function L(t){return{type:a.UPDATE_ON_SAVE,payload:{onSave:t}}}function D(t){return{type:a.UPDATE_ON_PAGE_CHANGE,payload:{onPageChange:t}}}function R(t){return{type:a.UPDATE_ON_STEP_CHANGE,payload:{onStepChange:t}}}function m(t){return{type:a.UPDATE_GET_FILE_DATA,payload:{getFileData:t}}}function g(t){return{type:a.UPDATE_PAGE_SIZE,payload:{pageSize:t}}}function C(t){return{type:a.UPDATE_LOAD_FILE_LIST,payload:{loadFileList:t}}}function z(){return{type:a.UPDATE_ROTATE}}function F(t){return{type:a.SKIP_BEFORE_PAGE_TURNING,payload:{skipBeforePageTurning:t}}}function h(t){return{type:a.UPDATE_BEFORE_ROTATE,payload:{beforeRotate:t}}}function B(t){return{type:a.UPDATE_PRE_DATA_PROCESS,payload:{preDataProcess:t}}}function Z(){return{type:a.COPY_BACKWARD_RESULT}}function k(t){return{type:a.UPDATE_IMG_INDEX_BY_EXTERNAL,payload:{getImgIndexByExternal:t}}}function $({id:t,newID:e,rangeIndex:n,imgList:o}){return{type:a.BATCH_UPDATE_TRACK_ID,payload:{id:t,newID:e,rangeIndex:n,imgList:o}}}function Q(t,e,n){return{type:a.BATCH_UPDATE_RESULT_BY_TRACK_ID,payload:{id:t,newData:e,rangeIndex:n}}}function tt(){return{type:a.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT,payload:{}}}const b=t=>({type:a.SET_CHECK_MODE,payload:{checkMode:t}}),v=t=>({type:a.SET_HIGHLIGHT_ATTRIBUTE,payload:{attribute:t}});function et({onSubmit:t,onSave:e,onPageChange:n,onStepChange:o,getFileData:r,pageSize:u,loadFileList:s,step:i,stepList:p,skipBeforePageTurning:l,beforeRotate:_,checkMode:c,highlightAttribute:T,preDataProcess:f,getImgIndexByExternal:I}){const d=[];return t&&d.push(U(t)),e&&d.push(L(e)),n&&d.push(D(n)),o&&d.push(R(o)),r&&d.push(m(r)),s&&d.push(C(s)),u&&d.push(g(u)),l&&d.push(F(l)),_&&d.push(h(_)),f&&d.push(B(f)),typeof c=="boolean"&&d.push(b(c)),I&&d.push(k(I)),d.push(v(T)),d.push(w({stepList:p,step:i})),d.push({type:a.CALC_STEP_PROGRESS}),d.push({type:a.INIT_TOOL}),j=>N(j,d)}function nt({onSubmit:t,onSave:e,onPageChange:n,onStepChange:o,getFileData:r,pageSize:u,loadFileList:s,stepList:i,beforeRotate:p,highlightAttribute:l,preDataProcess:_}){const c=[];return t&&c.push(U(t)),e&&c.push(L(e)),n&&c.push(D(n)),o&&c.push(R(o)),r&&c.push(m(r)),s&&c.push(C(s)),u&&c.push(g(u)),p&&c.push(h(p)),_&&c.push(B(_)),c.push(v(l)),c.push(G({stepList:i})),T=>N(T,c)}const at=(t,e)=>{var n;const o=e==null?void 0:e.findIndex(r=>(r==null?void 0:r.step)===t);return(n=e[o+1])==null?void 0:n.step},ot=t=>(e,n)=>{const{annotation:o}=n(),{step:r,stepList:u}=o,s=at(r,u);return[e(H(s,t))]},H=(t,e)=>(n,o)=>{var r,u;const{annotation:s}=o();(r=s==null?void 0:s.onStepChange)==null||r.call(s,t);const i=(u=s==null?void 0:s.imgIndex)!=null?u:0;return[n({type:a.SUBMIT_RESULT}),n({type:a.SUBMIT_FILE_DATA,payload:{submitType:E.StepChanged}}),n({type:a.SET_STEP,payload:{toStep:t}}),n({type:a.CALC_STEP_PROGRESS}),n(O(e!=null?e:i,0))]},S=t=>e=>[e({type:a.SUBMIT_RESULT}),e({type:a.SUBMIT_FILE_DATA,payload:{submitType:t}})],rt=(t,e,n,o)=>[t(S(n)),t(O(e,o))],it=(t,e)=>[t({type:a.SUBMIT_RESULT}),t({type:a.SET_BASIC_INDEX,payload:{basicIndex:e}})],ut=(t,e)=>{t({type:a.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED,payload:{triggerEventAfterIndexChanged:e}})},st=(t=!1)=>(e,n)=>A(e,n,y.Backward,t),pt=(t=!1)=>(e,n)=>A(e,n,y.Forward,t),lt=(t,e=!1)=>(n,o)=>{if(t!==o().imgIndex)return A(n,o,y.Jump,e,t)},M=(t,e,n,o)=>x(void 0,null,function*(){var r;const{loadFileList:u,imgList:s,pageSize:i}=e().annotation,p=Math.floor(n/i);P(t,!0);try{const l=yield u(p,i);if(P(t,!1),!((r=l==null?void 0:l.fileList)==null?void 0:r.length)||!(l==null?void 0:l.total))throw new Error("fileList and total are required");const _=o?new Array(l.total):[...s];return _.splice(p*i,i,...l.fileList),t({type:a.UPDATE_IMG_LIST,payload:{imgList:_}}),!0}catch(l){P(t,!1),console.error(l)}}),A=(t,e,n,o=!1,r)=>x(void 0,null,function*(){var u,s;const i=e().annotation,p=Y(n);let{fileIndexChanged:l,fileIndex:_,basicIndexChanged:c,basicIndex:T}=V.getNextPageInfo(n,i,r);const f=(u=i==null?void 0:i.getImgIndexByExternal)==null?void 0:u.call(i,i.imgIndex,p);if(f!==void 0&&(l=!0,_=f),ut(t,o),l){if(i.loading||!i.imgList[_]&&!(yield M(t,e,_)))return;(s=i.onPageChange)==null||s.call(i,_);const I=p===E.Backward?W(e().annotation,T):T;return rt(t,_,p,I)}return c?it(t,T):t(S(p))}),dt=t=>{t(S(E.Save)),t({type:a.SAVE_RESULT})},P=(t,e)=>{t({type:a.SET_LOADING,payload:{loading:e}})},ct=(t,e)=>{t({type:a.SET_LOADING,payload:{loading:e}})},_t=(t,e)=>{t({type:a.SET_LOADPCDFILE_LOADING,payload:{loadPCDFileLoading:e}})},Tt=t=>{t({type:a.INIT_ALL_STATE,payload:{}})},Et=(t,e)=>{t({type:a.SET_PREDICT_RESULT,payload:{result:e}})},yt=(t,e)=>{t({type:a.SET_PREDICT_RESULT_VISIBLE,payload:{visible:e}})},ft=(t,e)=>(n,o)=>{const{imgList:r,step:u}=o().annotation;return X(r,u,t,e)},It=t=>(e,n)=>{var o,r;const{annotation:u}=n();return(r=(o=u==null?void 0:u.preDataProcess)==null?void 0:o.call(u,t))!=null?r:t.dataList};export{tt as BatchUpdateImgListResultByPredictResult,Q as BatchUpdateResultByTrackID,$ as BatchUpdateTrackID,dt as ChangeSave,Z as CopyBackWordResult,A as DispatcherTurning,ft as GetBoxesByID,Tt as InitAnnotationState,et as InitTaskData,st as PageBackward,pt as PageForward,lt as PageJump,It as PreDataProcess,P as SetAnnotationLoading,_t as SetLoadPCDFileLoading,ct as SetPointCloudLoading,Et as SetPredictResult,yt as SetPredictResultVisible,w as SetTaskConfig,G as SetTaskStepList,ot as ToNextStep,S as ToSubmitFileData,h as UpdateBeforeRotate,b as UpdateCheckMode,m as UpdateGetFileData,C as UpdateGetFileList,v as UpdateHighlightAttribute,k as UpdateImgIndexByExternal,nt as UpdateInjectFunc,D as UpdateOnPageChange,L as UpdateOnSave,R as UpdateOnStepChange,U as UpdateOnSubmit,g as UpdatePageSize,B as UpdatePreDataProcess,H as UpdateProcessingStep,z as UpdateRotate,F as UpdateSkipBeforePageTurning,q as UpdateToolInstance,M as loadImgList};
@@ -1 +1 @@
1
- import{getFormatSize as At}from"../../components/customResizeHook/index.js";import{ESubmitType as K}from"../../constant/index.js";import Dt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as l}from"../Actions.js";import{jsonParser as w}from"../../utils/index.js";import Y from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as vt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as ut,composeResult as J}from"../../utils/data.js";import O from"../../utils/StepUtils.js";import X from"../../utils/ToolUtils.js";import{MathUtils as at,CommonToolUtils as yt,AnnotationEngine as Pt,ImgUtils as Rt}from"@labelbee/lb-annotation";import{PointCloudUtils as ct,i18n as G}from"@labelbee/lb-utils";import{Modal as dt}from"antd";import{message as pt}from"antd/es";import _t from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as W}from"../../data/enums/ToolType.js";var Ct=Object.defineProperty,Ot=Object.defineProperties,ht=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable,It=(t,e,r)=>e in t?Ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,n=(t,e)=>{for(var r in e||(e={}))bt.call(e,r)&&It(t,r,e[r]);if(gt)for(var r of gt(e))Nt.call(e,r)&&It(t,r,e[r]);return t},i=(t,e)=>Ot(t,ht(e)),mt=(t,e,r)=>new Promise((S,d)=>{var A=m=>{try{T(r.next(m))}catch(y){d(y)}},f=m=>{try{T(r.throw(m))}catch(y){d(y)}},T=m=>m.done?S(m.value):Promise.resolve(m.value).then(A,f);T((r=r.apply(t,e)).next())});const x=(t,e)=>t.find(r=>r.step===e),ft={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:""},Ut=t=>{const{imgList:e,imgPageSize:r}=t;return Math.ceil(e.length/r)},Tt=(t,e)=>t.reduce((r,S)=>{if(S){const d=S.result;if(w(d)[`step_${e}`])return r+1}return r},0)/t.length,Bt=(t,e)=>{const{step:r,stepList:S}=t,d=O.getCurrentStepInfo(r,S),A=vt.jsonParser(d.config);if(X.isVideoTool(d==null?void 0:d.tool)||X.isAudioTool(d==null?void 0:d.tool)||X.isPointCloudTool(d==null?void 0:d.tool)||[W.LLM,W.NLP].includes(d==null?void 0:d.tool))return;const f=document.getElementById("toolContainer");if(!f)throw"Not exist dom named id-toolContainer";const T=At({width:window.innerWidth,height:window.innerHeight}),m=new Pt({container:f,toolName:d.tool,size:T,imgNode:e,config:A,style:JSON.parse(Dt)});return{toolInstance:m==null?void 0:m.toolInstance,annotationEngine:m}},wt=(t,e)=>(r,S)=>mt(void 0,null,function*(){var d,A;const{stepList:f,step:T}=S().annotation,m=O.currentToolIsVideo(T,f),y=O.currentToolIsPointCloud(T,f),h=((d=O.getCurrentStepInfo(T,f))==null?void 0:d.tool)===W.LLM,b=((A=O.getCurrentStepInfo(T,f))==null?void 0:A.tool)===W.NLP,N=O.currentToolIsAudio(T,f);if($(r,!0),yield r(xt(t)),m){r(Ft(t));return}if(y||h||N||b){r(jt(t));return}r(Gt(t,e))}),xt=t=>(e,r)=>mt(void 0,null,function*(){const{getFileData:S,imgList:d}=r().annotation;if(S){const A=yield S(d[t],t);e({type:l.SET_FILE_DATA,payload:{fileData:A,index:t}})}}),Ft=t=>e=>{e({type:l.LOAD_FILE_DATA,payload:{nextIndex:t}})},jt=t=>e=>{$(e,!1),e({type:l.LOAD_FILE_DATA,payload:{nextIndex:t}})},Gt=(t,e)=>(r,S)=>{var d;const{toolInstance:A,imgList:f}=S().annotation,T=(d=f==null?void 0:f[t])==null?void 0:d.url;Rt.load(T).then(m=>{$(r,!1),r({type:l.LOAD_FILE_DATA,payload:{imgNode:m,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(r,!1),A==null||A.setErrorImg(),r({type:l.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},Vt=({toolInstance:t,imgList:e,imgIndex:r,stepList:S,step:d=1})=>{var A,f,T,m;const y=((A=e[r])==null?void 0:A.result)||"",[h,b,N]=(f=t==null?void 0:t.exportData())!=null?f:[],V=(m=(T=t==null?void 0:t.exportCustomData)==null?void 0:T.call(t))!=null?m:{},M=ut(y,b),k=J(M,{step:d,stepList:S},{rect:h},V);return e.map((F,H)=>H===r?n(i(n({},F),{result:k}),N):n({},F))},Mt=(t=n({},ft),e)=>{var r,S,d,A,f,T,m,y,h,b,N,V,M,k,F,H,q,Z,Q,tt,et,ot,nt,st,lt;switch(e.type){case l.INIT_ALL_STATE:return n(n({},t),ft);case l.UPDATE_TOOL_INSTANCE:return i(n({},t),{toolInstance:e.payload.toolInstance});case l.UPDATE_IMG_LIST:return i(n({},t),{imgList:e.payload.imgList});case l.CALC_STEP_PROGRESS:{const{imgList:o,step:s}=t,u=Tt(o,s);return i(n({},t),{stepProgress:u})}case l.SUBMIT_FILE_DATA:{const{imgList:o,imgIndex:s,step:u,stepList:a,toolInstance:p,onSubmit:c,resultList:L}=t;if(!p||!o[s])return t;const g=((r=o[s])==null?void 0:r.result)||"",[,_,I]=(S=p==null?void 0:p.exportData())!=null?S:[],E=(A=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?A:{},D=ut(g,_),P=J(D,{step:u,stepList:a},{rect:L},E),v=t.imgList.map((C,R)=>{if(R===s){const j=Y.dataCorrection(P,g,u,a);return n(i(n({},C),{result:j}),I)}return C});if(((f=e.payload)==null?void 0:f.submitType)===K.SyncImgList)return i(n({},t),{imgList:v});c&&c([v[s]],(T=e.payload)==null?void 0:T.submitType,s,v);const U=Tt(v,u);return i(n({},t),{stepProgress:U,imgList:v})}case l.SAVE_RESULT:{const{imgList:o,imgIndex:s,onSave:u}=t;return u==null||u(o[s],s,o),n({},t)}case l.SUBMIT_RESULT:{const{imgList:o,basicIndex:s,resultList:u,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(m=a==null?void 0:a.exportData())!=null?m:[];let L=c;if((p==null?void 0:p.length)>0){const g=(y=p[s])==null?void 0:y.id,_=c.map(I=>i(n({},I),{sourceID:g}));L=_t.cloneDeep(u).filter(I=>I.sourceID!==g),L.push(..._)}return i(n({},t),{resultList:L,imgList:o})}case l.SET_BASIC_INDEX:{const{toolInstance:o,step:s,imgList:u,imgIndex:a,stepList:p,annotationEngine:c,resultList:L,basicResultList:g}=t;if(!o||!c)return t;const _=e.payload.basicIndex,I=(h=g[_])==null?void 0:h.id,E=w((b=u[a])==null?void 0:b.result),D=(L||[]).filter(j=>j.sourceID===I),P=x(p,s),{dataSourceStep:v,tool:U}=P,C=x(p,v);let R=[];return v&&U&&(R=(N=E[`step_${v}`])==null?void 0:N.result,(R==null?void 0:R.length)>0?(c==null||c.setBasicInfo(C.tool,R[_]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),pt.info(G.t("NoDependency")))),o==null||o.setResult(D),o==null||o.history.initRecord(D,!0),i(n({},t),{basicIndex:_})}case l.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:o}=e.payload;return i(n({},t),{triggerEventAfterIndexChanged:!!o})}case l.LOAD_FILE_DATA:{const{imgList:o,step:s,toolInstance:u,annotationEngine:a,stepList:p}=t;if(!u)return i(n({},t),{imgIndex:e.payload.nextIndex});const c=O.getCurrentStepInfo(s,p),{nextIndex:L,imgNode:g,nextBasicIndex:_,imgError:I}=e.payload,E=_!=null?_:0,D=w((V=o[L])==null?void 0:V.result),P=D[`step_${c.step}`],v=!P,U={rotate:(M=D.rotate)!=null?M:0,valid:(k=D.valid)!=null?k:!0};g&&I!==!0?a==null||a.setImgNode(g,U):u==null||u.setValid(U.valid);const C=x(p,c.step),{dataSourceStep:R,tool:j}=C,it=x(p,R),rt=R&&j,B=(H=(F=D[`step_${R}`])==null?void 0:F.result)!=null?H:[],z=Y.getInitialResultList(P==null?void 0:P.result,u,C,B,v);if(a==null||a.launchOperation(),rt&&((B==null?void 0:B.length)>0?a==null||a.setBasicInfo(it.tool,B[E]):(a==null||a.setBasicInfo(it.tool),a==null||a.forbidOperation(),pt.info(G.t("NoDependency")))),c.tool!=="check"){const Lt=(Z=(q=B[E])==null?void 0:q.id)!=null?Z:"",Et=rt?z.filter(St=>yt.isSameSourceID(St.sourceID,Lt)):z;(Q=u==null?void 0:u.history)==null||Q.initRecord(z,!0),u==null||u.setResult(Et)}return i(n({},t),{imgIndex:L,basicIndex:E,basicResultList:B,resultList:z})}case l.UPDATE_ANNOTATION_CONFIG:return i(n({},t),{config:(tt=e.payload.config)!=null?tt:"{}"});case l.SET_TASK_STEP_LIST:{const{stepList:o}=e.payload;return i(n({},t),{stepList:o})}case l.SET_TASK_CONFIG:{const{stepList:o,step:s}=e.payload;return i(n({},t),{stepList:o,step:s})}case l.INIT_TOOL:{const{imgNode:o}=t,s=Bt(t,o);if(s){const{toolInstance:u,annotationEngine:a}=s;return i(n({},t),{toolInstance:u,annotationEngine:a})}return n({},t)}case l.SET_TOOL:{const o=(et=e.payload)==null?void 0:et.instance;return o?i(n({},t),{toolInstance:o}):n({},t)}case l.UPDATE_ON_SUBMIT:return i(n({},t),{onSubmit:e.payload.onSubmit});case l.UPDATE_ON_SAVE:return i(n({},t),{onSave:e.payload.onSave});case l.UPDATE_ON_PAGE_CHANGE:return i(n({},t),{onPageChange:e.payload.onPageChange});case l.SET_PREDICT_RESULT:return i(n({},t),{predictionResult:e.payload.result});case l.SET_PREDICT_RESULT_VISIBLE:return i(n({},t),{predictionResultVisible:e.payload.visible});case l.UPDATE_ON_STEP_CHANGE:return i(n({},t),{onStepChange:e.payload.onStepChange});case l.UPDATE_GET_FILE_DATA:return i(n({},t),{getFileData:e.payload.getFileData});case l.UPDATE_PAGE_SIZE:return i(n({},t),{pageSize:e.payload.pageSize});case l.UPDATE_LOAD_FILE_LIST:return i(n({},t),{loadFileList:e.payload.loadFileList});case l.UPDATE_BEFORE_ROTATE:return i(n({},t),{beforeRotate:e.payload.beforeRotate});case l.UPDATE_PRE_DATA_PROCESS:return i(n({},t),{preDataProcess:e.payload.preDataProcess});case l.SKIP_BEFORE_PAGE_TURNING:return i(n({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case l.SET_FILE_DATA:{const{fileData:o,index:s}=e.payload,{imgList:u}=t,a=[...u];return a[s]=n(n({},a[s]),o),i(n({},t),{imgList:a})}case l.UPDATE_ROTATE:{const{toolInstance:o,beforeRotate:s}=t;return s&&s()===!1||(ot=o==null?void 0:o.updateRotate)==null||ot.call(o),t}case l.UPDATE_ANNOTATION_VALID:{const{toolInstance:o}=t,s=(nt=o==null?void 0:o.valid)!=null?nt:!0;return dt.destroyAll(),dt.confirm({content:G.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{o==null||o.setValid(!s)},okText:G.t("Confirm"),cancelText:G.t("Cancel")}),t}case l.COPY_BACKWARD_RESULT:{const{toolInstance:o,imgIndex:s,imgList:u,step:a}=t;if(!o)return t;if(s===0||s>=u.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const p=u[s-1].result;if(!p)return t;const c=Y.copyResultChange(p,a,(st=u[s].result)!=null?st:"");u[s]=i(n({},u[s]),{result:c});const g=w(c)[`step_${a}`],_=(g==null?void 0:g.result)||[];return o==null||o.setResult(_),o==null||o.history.pushHistory(_),(lt=o==null?void 0:o.asyncData)==null||lt.call(o,u[s]),i(n({},t),{imgList:[...u]})}case l.SET_STEP:{const{stepList:o,annotationEngine:s}=t,{toStep:u}=e.payload;if(!s)return t;const a=x(o,u);return s==null||s.setToolName(a.tool,a.config),i(n({},t),{step:u,toolInstance:s==null?void 0:s.toolInstance})}case l.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:o}=e.payload;return i(n({},t),{loadPCDFileLoading:!!o})}case l.SET_LOADING:{const{loading:o}=e.payload;return i(n({},t),{loading:!!o})}case l.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:o}=e.payload;return i(n({},t),{pointCloudLoading:!!o})}case l.SET_CHECK_MODE:{const{checkMode:o}=e.payload;return i(n({},t),{checkMode:!!o})}case l.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:o}=e.payload;return i(n({},t),{highlightAttribute:o})}case l.BATCH_UPDATE_TRACK_ID:{const{id:o,newID:s,rangeIndex:u,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,L=[],g=a.map((_,I)=>{if(at.isInRange(I,u)){const E=i(n({},_),{result:ct.batchUpdateTrackID({id:o,newID:s,result:_.result})});return L.push({imgIndex:I,newInfo:E}),E}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:L}),i(n({},t),{imgList:g})}case l.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:o,newData:s,rangeIndex:u}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,L=[],g=a.map((_,I)=>{if(at.isInRange(I,u)){const E=i(n({},_),{result:ct.batchUpdateResultByTrackID({id:o,newData:s,result:_.result})});return L.push({imgIndex:I,newInfo:E}),E}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:L}),i(n({},t),{imgList:g})}case l.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:o,imgList:s,stepList:u,step:a,predictionResult:p}=t,c={};p.forEach(I=>{const{index:E}=I;c[E]=_t.pick(I,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const L=`step_${a}`,g=[],_=s.map((I,E)=>{if(c[E]){const D=I.result==="{}"?w(J("",{step:a,stepList:u},{rect:[]},{})):w(I.result);D[L].result.push(c[E]);const P=i(n({},I),{result:JSON.stringify(D)});return g.push({imgIndex:E,newInfo:P}),P}return I});return o==null||o(_,K.BatchUpdateImgList,-1,_,{updateImgList:g}),i(n({},t),{imgList:_})}default:return t}};export{wt as LoadFileAndFileData,Mt as annotationReducer,Vt as composeResultByToolInstance,x as getStepConfig,Ut as getTotalPage};
1
+ import{getFormatSize as yt}from"../../components/customResizeHook/index.js";import{ESubmitType as K}from"../../constant/index.js";import Rt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as i}from"../Actions.js";import{jsonParser as x}from"../../utils/index.js";import X from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as Pt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as dt,composeResult as Y}from"../../utils/data.js";import O from"../../utils/StepUtils.js";import J from"../../utils/ToolUtils.js";import{MathUtils as pt,CommonToolUtils as Ct,AnnotationEngine as Ot,ImgUtils as ht}from"@labelbee/lb-annotation";import{PointCloudUtils as gt,i18n as G}from"@labelbee/lb-utils";import{Modal as _t}from"antd";import{message as It}from"antd/es";import mt from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as W}from"../../data/enums/ToolType.js";var bt=Object.defineProperty,Nt=Object.defineProperties,Ut=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,Tt=(t,e,u)=>e in t?bt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,o=(t,e)=>{for(var u in e||(e={}))Bt.call(e,u)&&Tt(t,u,e[u]);if(ft)for(var u of ft(e))xt.call(e,u)&&Tt(t,u,e[u]);return t},l=(t,e)=>Nt(t,Ut(e)),Lt=(t,e,u)=>new Promise((S,d)=>{var A=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?S(f.value):Promise.resolve(f.value).then(A,L);E((u=u.apply(t,e)).next())});const w=(t,e)=>t.find(u=>u.step===e),Et={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:""},wt=t=>{const{imgList:e,imgPageSize:u}=t;return Math.ceil(e.length/u)},St=(t,e)=>t.reduce((u,S)=>{if(S){const d=S.result;if(x(d)[`step_${e}`])return u+1}return u},0)/t.length,Ft=(t,e)=>{const{step:u,stepList:S}=t,d=O.getCurrentStepInfo(u,S),A=Pt.jsonParser(d.config);if(J.isVideoTool(d==null?void 0:d.tool)||J.isAudioTool(d==null?void 0:d.tool)||J.isPointCloudTool(d==null?void 0:d.tool)||[W.LLM,W.NLP].includes(d==null?void 0:d.tool))return;const L=document.getElementById("toolContainer");if(!L)throw"Not exist dom named id-toolContainer";const E=yt({width:window.innerWidth,height:window.innerHeight}),f=new Ot({container:L,toolName:d.tool,size:E,imgNode:e,config:A,style:JSON.parse(Rt)});return{toolInstance:f==null?void 0:f.toolInstance,annotationEngine:f}},jt=(t,e)=>(u,S)=>Lt(void 0,null,function*(){var d,A;const{stepList:L,step:E}=S().annotation,f=O.currentToolIsVideo(E,L),y=O.currentToolIsPointCloud(E,L),h=((d=O.getCurrentStepInfo(E,L))==null?void 0:d.tool)===W.LLM,b=((A=O.getCurrentStepInfo(E,L))==null?void 0:A.tool)===W.NLP,N=O.currentToolIsAudio(E,L);if($(u,!0),yield u(Gt(t)),f){u(Vt(t));return}if(y||h||N||b){u(Mt(t));return}u(kt(t,e))}),Gt=t=>(e,u)=>Lt(void 0,null,function*(){const{getFileData:S,imgList:d}=u().annotation;if(S){const A=yield S(d[t],t);e({type:i.SET_FILE_DATA,payload:{fileData:A,index:t}})}}),Vt=t=>e=>{e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},Mt=t=>e=>{$(e,!1),e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},kt=(t,e)=>(u,S)=>{var d;const{toolInstance:A,imgList:L}=S().annotation,E=(d=L==null?void 0:L[t])==null?void 0:d.url;ht.load(E).then(f=>{$(u,!1),u({type:i.LOAD_FILE_DATA,payload:{imgNode:f,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(u,!1),A==null||A.setErrorImg(),u({type:i.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},Ht=({toolInstance:t,imgList:e,imgIndex:u,stepList:S,step:d=1})=>{var A,L,E,f;const y=((A=e[u])==null?void 0:A.result)||"",[h,b,N]=(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:{},M=dt(y,b),k=Y(M,{step:d,stepList:S},{rect:h},V);return e.map((F,H)=>H===u?o(l(o({},F),{result:k}),N):o({},F))},zt=(t=o({},Et),e)=>{var u,S,d,A,L,E,f,y,h,b,N,V,M,k,F,H,q,Z,Q,tt,et,nt,ot,st,lt,it,rt,ut;switch(e.type){case i.INIT_ALL_STATE:return o(o({},t),Et);case i.UPDATE_TOOL_INSTANCE:return l(o({},t),{toolInstance:e.payload.toolInstance});case i.UPDATE_IMG_LIST:return l(o({},t),{imgList:e.payload.imgList});case i.CALC_STEP_PROGRESS:{const{imgList:n,step:s}=t,r=St(n,s);return l(o({},t),{stepProgress:r})}case i.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:s,step:r,stepList:a,toolInstance:p,onSubmit:c,resultList:T}=t;if(!p||!n[s])return t;const I=((u=n[s])==null?void 0:u.result)||"",[,g,_]=(S=p==null?void 0:p.exportData())!=null?S:[],m=(A=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?A:{},D=dt(I,g),R=Y(D,{step:r,stepList:a},{rect:T},m),v=t.imgList.map((C,P)=>{if(P===s){const j=X.dataCorrection(R,I,r,a);return o(l(o({},C),{result:j}),_)}return C});if(((L=e.payload)==null?void 0:L.submitType)===K.SyncImgList)return l(o({},t),{imgList:v});c&&c([v[s]],(E=e.payload)==null?void 0:E.submitType,s,v);const U=St(v,r);return l(o({},t),{stepProgress:U,imgList:v})}case i.SAVE_RESULT:{const{imgList:n,imgIndex:s,onSave:r}=t;return r==null||r(n[s],s,n),o({},t)}case i.SUBMIT_RESULT:{const{imgList:n,basicIndex:s,resultList:r,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(f=a==null?void 0:a.exportData())!=null?f:[];let T=c;if((p==null?void 0:p.length)>0){const I=(y=p[s])==null?void 0:y.id,g=c.map(_=>l(o({},_),{sourceID:I}));T=mt.cloneDeep(r).filter(_=>_.sourceID!==I),T.push(...g)}return l(o({},t),{resultList:T,imgList:n})}case i.SET_BASIC_INDEX:{const{toolInstance:n,step:s,imgList:r,imgIndex:a,stepList:p,annotationEngine:c,resultList:T,basicResultList:I}=t;if(!n||!c)return t;const g=e.payload.basicIndex,_=(h=I[g])==null?void 0:h.id,m=x((b=r[a])==null?void 0:b.result),D=(T||[]).filter(j=>j.sourceID===_),R=w(p,s),{dataSourceStep:v,tool:U}=R,C=w(p,v);let P=[];return v&&U&&(P=(N=m[`step_${v}`])==null?void 0:N.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[g]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),It.info(G.t("NoDependency")))),n==null||n.setResult(D),n==null||n.history.initRecord(D,!0),l(o({},t),{basicIndex:g})}case i.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=e.payload;return l(o({},t),{triggerEventAfterIndexChanged:!!n})}case i.LOAD_FILE_DATA:{const{imgList:n,step:s,toolInstance:r,annotationEngine:a,stepList:p}=t;if(!r)return l(o({},t),{imgIndex:e.payload.nextIndex});const c=O.getCurrentStepInfo(s,p),{nextIndex:T,imgNode:I,nextBasicIndex:g,imgError:_}=e.payload,m=g!=null?g:0,D=x((V=n[T])==null?void 0:V.result),R=D[`step_${c.step}`],v=!R,U={rotate:(M=D.rotate)!=null?M:0,valid:(k=D.valid)!=null?k:!0};I&&_!==!0?a==null||a.setImgNode(I,U):r==null||r.setValid(U.valid);const C=w(p,c.step),{dataSourceStep:P,tool:j}=C,at=w(p,P),ct=P&&j,B=(H=(F=D[`step_${P}`])==null?void 0:F.result)!=null?H:[],z=X.getInitialResultList(R==null?void 0:R.result,r,C,B,v);if(a==null||a.launchOperation(),ct&&((B==null?void 0:B.length)>0?a==null||a.setBasicInfo(at.tool,B[m]):(a==null||a.setBasicInfo(at.tool),a==null||a.forbidOperation(),It.info(G.t("NoDependency")))),c.tool!=="check"){const At=(Z=(q=B[m])==null?void 0:q.id)!=null?Z:"",Dt=ct?z.filter(vt=>Ct.isSameSourceID(vt.sourceID,At)):z;(Q=r==null?void 0:r.history)==null||Q.initRecord(z,!0),r==null||r.setResult(Dt)}return l(o({},t),{imgIndex:T,basicIndex:m,basicResultList:B,resultList:z})}case i.UPDATE_ANNOTATION_CONFIG:return l(o({},t),{config:(tt=e.payload.config)!=null?tt:"{}"});case i.SET_TASK_STEP_LIST:{const{stepList:n}=e.payload;return l(o({},t),{stepList:n})}case i.SET_TASK_CONFIG:{const{stepList:n,step:s}=e.payload;return l(o({},t),{stepList:n,step:s})}case i.INIT_TOOL:{const{imgNode:n}=t,s=Ft(t,n);if(s){const{toolInstance:r,annotationEngine:a}=s;return l(o({},t),{toolInstance:r,annotationEngine:a})}return o({},t)}case i.SET_TOOL:{const n=(et=e.payload)==null?void 0:et.instance;return n?l(o({},t),{toolInstance:n}):o({},t)}case i.UPDATE_ON_SUBMIT:return l(o({},t),{onSubmit:e.payload.onSubmit});case i.UPDATE_ON_SAVE:return l(o({},t),{onSave:e.payload.onSave});case i.UPDATE_ON_PAGE_CHANGE:return l(o({},t),{onPageChange:e.payload.onPageChange});case i.SET_PREDICT_RESULT:return l(o({},t),{predictionResult:e.payload.result});case i.SET_PREDICT_RESULT_VISIBLE:return l(o({},t),{predictionResultVisible:e.payload.visible});case i.UPDATE_ON_STEP_CHANGE:return l(o({},t),{onStepChange:e.payload.onStepChange});case i.UPDATE_GET_FILE_DATA:return l(o({},t),{getFileData:e.payload.getFileData});case i.UPDATE_PAGE_SIZE:return l(o({},t),{pageSize:e.payload.pageSize});case i.UPDATE_LOAD_FILE_LIST:return l(o({},t),{loadFileList:e.payload.loadFileList});case i.UPDATE_BEFORE_ROTATE:return l(o({},t),{beforeRotate:e.payload.beforeRotate});case i.UPDATE_PRE_DATA_PROCESS:return l(o({},t),{preDataProcess:e.payload.preDataProcess});case i.UPDATE_IMG_INDEX_BY_EXTERNAL:return l(o({},t),{getImgIndexByExternal:e.payload.getImgIndexByExternal});case i.SKIP_BEFORE_PAGE_TURNING:return l(o({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case i.SET_FILE_DATA:{const{fileData:n,index:s}=e.payload,{imgList:r}=t,a=[...r];return a[s]=o(o({},a[s]),n),l(o({},t),{imgList:a})}case i.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 i.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=t,s=(ot=n==null?void 0:n.valid)!=null?ot:!0;return _t.destroyAll(),_t.confirm({content:G.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!s)},okText:G.t("Confirm"),cancelText:G.t("Cancel")}),t}case i.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:s,imgList:r,step:a,stepList:p}=t;if(!n)return t;if(s===0||s>=r.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const c=r[s-1].result;if(!c)return t;const T=O.getCurrentStepInfo(a,p),I=(st=T==null?void 0:T.step)!=null?st:a,g=X.copyResultChange({copyResult:c,step:I,currentResult:(lt=r[s].result)!=null?lt:"",preMappingImgList:(it=r[s-1].mappingImgList)!=null?it:[],mappingImgList:(rt=r[s].mappingImgList)!=null?rt:[]});r[s]=l(o({},r[s]),{result:g});const m=x(g)[`step_${a}`],D=(m==null?void 0:m.result)||[];return n==null||n.setResult(D),n==null||n.history.pushHistory(D),(ut=n==null?void 0:n.asyncData)==null||ut.call(n,r[s]),l(o({},t),{imgList:[...r]})}case i.SET_STEP:{const{stepList:n,annotationEngine:s}=t,{toStep:r}=e.payload;if(s){const a=w(n,r);return s==null||s.setToolName(a.tool,a.config),l(o({},t),{step:r,toolInstance:s==null?void 0:s.toolInstance})}return l(o({},t),{step:r})}case i.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=e.payload;return l(o({},t),{loadPCDFileLoading:!!n})}case i.SET_LOADING:{const{loading:n}=e.payload;return l(o({},t),{loading:!!n})}case i.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=e.payload;return l(o({},t),{pointCloudLoading:!!n})}case i.SET_CHECK_MODE:{const{checkMode:n}=e.payload;return l(o({},t),{checkMode:!!n})}case i.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=e.payload;return l(o({},t),{highlightAttribute:n})}case i.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:s,rangeIndex:r,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,T=[],I=a.map((g,_)=>{if(pt.isInRange(_,r)){const m=l(o({},g),{result:gt.batchUpdateTrackID({id:n,newID:s,result:g.result})});return T.push({imgIndex:_,newInfo:m}),m}return g});return c&&c([I[p]],K.BatchUpdateTrackID,p,I,{updateImgList:T}),l(o({},t),{imgList:I})}case i.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:s,rangeIndex:r}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,T=[],I=a.map((g,_)=>{if(pt.isInRange(_,r)){const m=l(o({},g),{result:gt.batchUpdateResultByTrackID({id:n,newData:s,result:g.result})});return T.push({imgIndex:_,newInfo:m}),m}return g});return c&&c([I[p]],K.BatchUpdateTrackID,p,I,{updateImgList:T}),l(o({},t),{imgList:I})}case i.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:s,stepList:r,step:a,predictionResult:p}=t,c={};p.forEach(_=>{const{index:m}=_;c[m]=mt.pick(_,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const T=`step_${a}`,I=[],g=s.map((_,m)=>{if(c[m]){const D=_.result==="{}"?x(Y("",{step:a,stepList:r},{rect:[]},{})):x(_.result);D[T].result.push(c[m]);const R=l(o({},_),{result:JSON.stringify(D)});return I.push({imgIndex:m,newInfo:R}),R}return _});return n==null||n(g,K.BatchUpdateImgList,-1,g,{updateImgList:I}),l(o({},t),{imgList:g})}default:return t}};export{jt as LoadFileAndFileData,zt as annotationReducer,Ht as composeResultByToolInstance,w as getStepConfig,wt as getTotalPage};
@@ -1 +1 @@
1
- import{uuid as v}from"@labelbee/lb-annotation";import{jsonParser as l}from"./index.js";import{EToolName as d}from"../data/enums/ToolType.js";import _ from"lodash";import y from"./StepUtils.js";var O=Object.defineProperty,P=Object.defineProperties,j=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,S=(a,t,e)=>t in a?O(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,E=(a,t)=>{for(var e in t||(t={}))w.call(t,e)&&S(a,e,t[e]);if(h)for(var e of h(t))x.call(t,e)&&S(a,e,t[e]);return a},N=(a,t)=>P(a,j(t));class R{static copyResultChange(t,e,r){try{const s=l(t),i=l(r),o=`step_${e}`;if(s[o]){const n=s[o];if(n.result)return n.result=n.result.map(u=>N(E({},u),{id:v(8,62)})),i[o]=n,JSON.stringify(i)}return t}catch(s){return t}}static isResultSourceMatchedDependence(t,e){const r=t==null?void 0:t.map(i=>i.sourceID).sort(),s=e==null?void 0:e.map(i=>i.id).sort();return _.isEqual(r,s)}static deltaUpdateBasicResultList(t,e){const r=t==null?void 0:t.map(s=>s.sourceID).sort();return e.filter(s=>!r.includes(s.id))}static getInitialResultList(t,e,r,s,i){const o=t!=null?t:[];switch(r.tool){case d.Tag:case d.Text:{if(r.dataSourceStep>0){const n=this.deltaUpdateBasicResultList(o,s);if(n.length>0)return o.concat(e.getInitResultList(r.dataSourceStep,n))}return i!==!0?o:e.getInitResultList(r.dataSourceStep,s)}default:return o}}static dataCorrection(t,e,r,s){var i,o;try{const u=`step_${y.getStepInfo(r,s).step}`,c=l(t),I=l(e),f=(i=c[u])==null?void 0:i.result,p=(o=I[u])==null?void 0:o.result;if(!p||_.isEqual(f.sort(this.idCmp),p.sort(this.idCmp)))return t;const m=this.findDeletedIds(f,p);if(m.length===0)return t;const D=r,g=this.getStepKeys(c).sort();return this.deleteRes(c,D,m,g),JSON.stringify(c)}catch(n){return console.error(n),t}}static idCmp(t,e){const r=t.id,s=e.id;return r<s?-1:r>s?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(r=>r.id)}static findDeletedItems(t,e){const r=[];return t.forEach(s=>{e.some(o=>o.id===s.id)||r.push(s)}),r}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,r,s){s.forEach(i=>{if(i>e){const o=t[`step_${i}`];if([d.FolderTag,d.Segmentation].includes(o.tool))return;if(o.dataSourceStep===e){const n=[];o.result=o.result.filter(u=>r.includes(u.sourceID)?(n.push(u.id),!1):!0),this.deleteRes(t,i,n,s)}else o.result=o.result.filter(n=>!r.includes(n.sourceID))}})}}export{R as default};
1
+ import{uuid as E}from"@labelbee/lb-annotation";import{jsonParser as v}from"./index.js";import{EToolName as I}from"../data/enums/ToolType.js";import S from"lodash";import L from"./StepUtils.js";import{message as N}from"antd";import{i18n as F}from"@labelbee/lb-utils";class _{static traverseDF(t,s,e,i){s(t,e,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((n,r)=>{this.traverseDF(n,s,r,t)}):Object.keys(t).forEach(n=>{this.traverseDF(t[n],s,n,t)}))}static getNextPath(t){var s,e,i;const{prePath:n,preMappingImgList:r,nextMappingImgList:a}=t,o=(e=(s=r==null?void 0:r.find(c=>c.path===n))==null?void 0:s.calib)==null?void 0:e.calName;return(i=a.find(c=>{var f;return((f=c.calib)==null?void 0:f.calName)===o}))==null?void 0:i.path}static copyResultItemHandler(t){const{item:s,key:e,parent:i,mappingImgList:n,preMappingImgList:r}=t,a=e===void 0?void 0:i[e];return e==="id"&&(i.id=E(8,62)),e==="imageName"&&(i.imageName=this.getNextPath({prePath:s,preMappingImgList:r,nextMappingImgList:n})),{value:e===void 0?void 0:i[e],oldValue:a}}static copyResultChange(t){const{copyResult:s,step:e,currentResult:i,mappingImgList:n,preMappingImgList:r}=t;try{const a=v(s),o=v(i),d=`step_${e}`;if(a[d]){const c=a[d],f=["result","resultRect"],p=new Map,R=(l,u)=>{if(l===void 0||u===void 0){console.warn("invalid id");return}p.set(u,l)};if(f.forEach(l=>{c[l]&&this.traverseDF(c[l],(u,m,h)=>{const{value:y,oldValue:x}=this.copyResultItemHandler({item:u,key:m,parent:h,mappingImgList:n,preMappingImgList:r});l==="result"&&m==="id"&&y!==void 0&&x!==void 0&&p.set(x,y)})}),p.size){const l=c.resultRect;Array.isArray(l)&&l.forEach(u=>{const m=u.extId,h=p.get(m);m!==void 0&&h!==void 0&&(u.extId=h)})}const D=["resultRect","rects"],g=[];return this.traverseDF(c,(l,u,m)=>{S.isString(u)&&D.includes(u)&&Array.isArray(l)&&(m[u]=l.filter(h=>h.imageName?!0:(g.push(h),!1)))}),g.length&&(console.warn(g),N.info(F.t("PartialResultsReplicationFailure"))),o[d]=c,JSON.stringify(o)}return s}catch(a){N.info(F.t("FailedToCopyResults"))}}static isResultSourceMatchedDependence(t,s){const e=t==null?void 0:t.map(n=>n.sourceID).sort(),i=s==null?void 0:s.map(n=>n.id).sort();return S.isEqual(e,i)}static deltaUpdateBasicResultList(t,s){const e=t==null?void 0:t.map(i=>i.sourceID).sort();return s.filter(i=>!e.includes(i.id))}static getInitialResultList(t,s,e,i,n){const r=t!=null?t:[];switch(e.tool){case I.Tag:case I.Text:{if(e.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(r,i);if(a.length>0)return r.concat(s.getInitResultList(e.dataSourceStep,a))}return n!==!0?r:s.getInitResultList(e.dataSourceStep,i)}default:return r}}static dataCorrection(t,s,e,i){var n,r;try{const o=`step_${L.getStepInfo(e,i).step}`,d=v(t),c=v(s),f=(n=d[o])==null?void 0:n.result,p=(r=c[o])==null?void 0:r.result;if(!p||S.isEqual(f.sort(this.idCmp),p.sort(this.idCmp)))return t;const R=this.findDeletedIds(f,p);if(R.length===0)return t;const D=e,g=this.getStepKeys(d).sort();return this.deleteRes(d,D,R,g),JSON.stringify(d)}catch(a){return console.error(a),t}}static idCmp(t,s){const e=t.id,i=s.id;return e<i?-1:e>i?1:0}static findDeletedIds(t,s){return this.findDeletedItems(s,t).map(e=>e.id)}static findDeletedItems(t,s){const e=[];return t.forEach(i=>{s.some(r=>r.id===i.id)||e.push(i)}),e}static getStepKeys(t){return Object.keys(t).map(s=>parseInt(s.replace("step_",""),10)).filter(s=>!isNaN(s))}static deleteRes(t,s,e,i){i.forEach(n=>{if(n>s){const r=t[`step_${n}`];if([I.FolderTag,I.Segmentation].includes(r.tool))return;if(r.dataSourceStep===s){const a=[];r.result=r.result.filter(o=>e.includes(o.sourceID)?(a.push(o.id),!1):!0),this.deleteRes(t,n,a,i)}else r.result=r.result.filter(a=>!e.includes(a.sourceID))}})}}export{_ as default};
package/es/utils/index.js CHANGED
@@ -1 +1 @@
1
- import f from"lodash";import{pointCloudLidar2image as l}from"@labelbee/lb-annotation";var y=Object.defineProperty,d=Object.defineProperties,_=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,m=(r,t,n)=>t in r?y(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,P=(r,t)=>{for(var n in t||(t={}))x.call(t,n)&&m(r,n,t[n]);if(u)for(var n of u(t))O.call(t,n)&&m(r,n,t[n]);return r},w=(r,t)=>d(r,_(t));const b=(r,t={})=>{try{return typeof r=="string"?JSON.parse(r):f.isObject(r)?r:t}catch(n){return t}},I=r=>{if(Array.isArray(r))return r.filter(t=>t).join(" ");if(f.isObject(r)){const t=[];return Object.keys(r).forEach(n=>{r[n]&&t.push(n)}),t.join(" ")}return""},g=r=>{let t=Infinity,n=Infinity,e=-Infinity,o=-Infinity;for(const i of r)t=Math.min(t,i.x),n=Math.min(n,i.y),e=Math.max(e,i.x),o=Math.max(o,i.y);return{x:t,y:n,width:e-t,height:o-n}},v=(()=>{const r=(t,n)=>{const e=Math.max(t.x,n.x),o=Math.max(t.y,n.y),i=Math.min(t.x+t.width,n.x+n.width),a=Math.min(t.y+t.height,n.y+n.height),s=i-e,c=a-o;return s>=0&&c>=0?{x:e,y:o,width:s,height:c}:null};return(t,n,e)=>{if(e[n]){const o=e[n].width,i=e[n].height;return r(t,{x:0,y:0,width:o,height:i})!==null}return!1}})(),j=r=>{var t;const{pointCloudBox:n,mappingData:e,imageSizes:o}=r,{transferViewData:i}=(t=l(n,e.calib))!=null?t:{};if(!i)return;const a=i.reduce((p,h)=>h.type==="line"?[...p,...h.pointList]:p,[]),s=w(P({},g(a)),{imageName:e.path});if(v(s,e.path,o))return s};export{I as classnames,g as getBoundingRect,j as getRectPointCloudBox,b as jsonParser};
1
+ import g from"lodash";import{pointCloudLidar2image as y}from"@labelbee/lb-annotation";var x=Object.defineProperty,_=Object.defineProperties,O=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))P.call(t,n)&&m(e,n,t[n]);if(h)for(var n of h(t))w.call(t,n)&&m(e,n,t[n]);return e},I=(e,t)=>_(e,O(t));const v=(e,t={})=>{try{return typeof e=="string"?JSON.parse(e):g.isObject(e)?e:t}catch(n){return t}},j=e=>{if(Array.isArray(e))return e.filter(t=>t).join(" ");if(g.isObject(e)){const t=[];return Object.keys(e).forEach(n=>{e[n]&&t.push(n)}),t.join(" ")}return""},l=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),s=Math.min(t.y+t.height,n.y+n.height),a=i-r,c=s-o;return a>=0&&c>=0?{x:r,y:o,width:a,height:c}: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 s=i.reduce((p,f)=>f.type==="line"?[...p,...f.pointList]:p,[]),a=I(b({},l(s)),{imageName:r.path});if(u(a,r.path,o))return a},R=e=>{const{pointCloudBox:t,mappingImgList:n,imageSizes:r}=e,i=n.map(s=>d({pointCloudBox:t,mappingData:s,imageSizes:r})).filter(s=>s!==void 0);i.length>0&&Object.assign(t,{rects:i})};export{j as classnames,R as generatePointCloudBoxRects,l as getBoundingRect,d as getRectPointCloudBox,u as isBoundingRectInImage,v as jsonParser};