@labelbee/lb-components 1.23.0-alpha.5 → 1.23.0-alpha.50

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 (167) 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/assets/annotation/pointCloudTool/rotate90_black.svg.js +1 -0
  7. package/dist/assets/icons/ad33251.svg +26 -0
  8. package/dist/components/AnnotationView/index.js +1 -1
  9. package/dist/components/LLMToolView/index.js +1 -1
  10. package/dist/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
  11. package/dist/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
  12. package/dist/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
  13. package/dist/components/LLMToolView/sidebar/index.js +1 -1
  14. package/dist/components/LLMToolView/utils/data.js +1 -1
  15. package/dist/components/NLPToolView/index.js +1 -1
  16. package/dist/components/NLPToolView/textContent/index.js +1 -1
  17. package/dist/components/audioAnnotate/audioContext/index.js +1 -1
  18. package/dist/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  19. package/dist/components/audioAnnotate/index.js +1 -1
  20. package/dist/components/audioAnnotate/textInput/index.js +1 -1
  21. package/dist/components/audioAnnotate/textInput/index.module.scss.js +1 -1
  22. package/dist/components/audioAnnotate/utils/dataTransform.js +1 -0
  23. package/dist/components/audioPlayer/clipRegion/index.js +1 -1
  24. package/dist/components/audioPlayer/index.js +1 -1
  25. package/dist/components/audioPlayer/useAudioCombine/index.js +3 -2
  26. package/dist/components/audioPlayer/useAudioSegment/index.js +1 -1
  27. package/dist/components/longText/index.js +1 -1
  28. package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
  29. package/dist/components/pointCloudView/PointCloud2DSingleView.js +1 -1
  30. package/dist/components/pointCloudView/PointCloud2DView.js +1 -1
  31. package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
  32. package/dist/components/pointCloudView/PointCloudContext.js +1 -1
  33. package/dist/components/pointCloudView/PointCloudListener.js +1 -1
  34. package/dist/components/pointCloudView/PointCloudSegment2DView.js +1 -1
  35. package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
  36. package/dist/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -0
  37. package/dist/components/pointCloudView/hooks/useHighlight.js +1 -1
  38. package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  39. package/dist/components/pointCloudView/hooks/useRotateEdge.js +1 -0
  40. package/dist/components/pointCloudView/hooks/useSingleBox.js +1 -1
  41. package/dist/components/pointCloudView/hooks/useStatus.js +1 -1
  42. package/dist/components/pointCloudView/index.js +1 -1
  43. package/dist/components/pointCloudView/utils/map.js +1 -0
  44. package/dist/components/subAttributeList/index.js +1 -0
  45. package/dist/components/videoAnnotate/videoClipTool/index.js +1 -1
  46. package/dist/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
  47. package/dist/index.css +64 -19
  48. package/dist/index.js +1 -1
  49. package/dist/store/Actions.js +1 -1
  50. package/dist/store/annotatedBox/index.js +1 -1
  51. package/dist/store/annotation/actionCreators.js +1 -1
  52. package/dist/store/annotation/reducer.js +1 -1
  53. package/dist/types/App.d.ts +3 -1
  54. package/dist/types/components/AnnotationView/index.d.ts +1 -0
  55. package/dist/types/components/LLMToolView/utils/data.d.ts +1 -1
  56. package/dist/types/components/audioAnnotate/audioContext/index.d.ts +10 -2
  57. package/dist/types/components/audioAnnotate/textInput/index.d.ts +1 -0
  58. package/dist/types/components/audioAnnotate/utils/dataTransform.d.ts +9 -0
  59. package/dist/types/components/audioPlayer/index.d.ts +28 -21
  60. package/dist/types/components/longText/index.d.ts +1 -0
  61. package/dist/types/components/pointCloud2DRectOperationView/index.d.ts +1 -0
  62. package/dist/types/components/pointCloudView/PointCloud2DView.d.ts +2 -1
  63. package/dist/types/components/pointCloudView/PointCloudContext.d.ts +19 -3
  64. package/dist/types/components/pointCloudView/hooks/useDataLinkSwitch.d.ts +21 -0
  65. package/dist/types/components/pointCloudView/hooks/useHighlight.d.ts +1 -1
  66. package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +5 -0
  67. package/dist/types/components/pointCloudView/hooks/useRotateEdge.d.ts +9 -0
  68. package/dist/types/components/pointCloudView/hooks/useSingleBox.d.ts +2 -1
  69. package/dist/types/components/pointCloudView/utils/map.d.ts +11 -0
  70. package/dist/types/components/subAttributeList/index.d.ts +10 -0
  71. package/dist/types/components/videoAnnotate/index.d.ts +2 -1
  72. package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +2 -1
  73. package/dist/types/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.d.ts +1 -1
  74. package/dist/types/index.d.ts +6 -1
  75. package/dist/types/store/Actions.d.ts +1 -0
  76. package/dist/types/store/annotatedBox/index.d.ts +2 -0
  77. package/dist/types/store/annotation/actionCreators.d.ts +3 -2
  78. package/dist/types/store/annotation/reducer.d.ts +1 -0
  79. package/dist/types/store/annotation/types.d.ts +9 -2
  80. package/dist/types/utils/AnnotationDataUtils.d.ts +57 -1
  81. package/dist/types/utils/index.d.ts +25 -1
  82. package/dist/types/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.d.ts +3 -0
  83. package/dist/types/views/MainView/sidebar/TextToolSidebar/index.d.ts +1 -1
  84. package/dist/types/views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.d.ts +9 -0
  85. package/dist/types/views/MainView/toolFooter/BatchSwitchConnectIn2DView/index.d.ts +1 -0
  86. package/dist/types/views/MainView/toolFooter/index.d.ts +1 -1
  87. package/dist/types/views/MainView/toolHeader/StepSwitch/index.d.ts +1 -1
  88. package/dist/types/views/MainView/toolHeader/index.d.ts +1 -1
  89. package/dist/utils/AnnotationDataUtils.js +1 -1
  90. package/dist/utils/index.js +1 -1
  91. package/dist/views/MainView/index.js +1 -1
  92. package/dist/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
  93. package/dist/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
  94. package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.js +1 -0
  95. package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.module.scss.js +1 -0
  96. package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  97. package/dist/views/MainView/sidebar/TagSidebar/index.js +1 -1
  98. package/dist/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
  99. package/dist/views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js +1 -0
  100. package/dist/views/MainView/toolFooter/FooterTips/ToolHotKey/pointCloud/index.js +1 -1
  101. package/es/App.js +1 -1
  102. package/es/assets/annotation/icon_link.svg.js +1 -0
  103. package/es/assets/annotation/icon_unlink.svg.js +1 -0
  104. package/es/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
  105. package/es/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
  106. package/es/assets/annotation/pointCloudTool/rotate90_black.svg.js +1 -0
  107. package/es/components/AnnotationView/index.js +1 -1
  108. package/es/components/LLMToolView/index.js +1 -1
  109. package/es/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
  110. package/es/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
  111. package/es/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
  112. package/es/components/LLMToolView/sidebar/index.js +1 -1
  113. package/es/components/LLMToolView/utils/data.js +1 -1
  114. package/es/components/NLPToolView/index.js +1 -1
  115. package/es/components/NLPToolView/textContent/index.js +1 -1
  116. package/es/components/audioAnnotate/audioContext/index.js +1 -1
  117. package/es/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  118. package/es/components/audioAnnotate/index.js +1 -1
  119. package/es/components/audioAnnotate/textInput/index.js +1 -1
  120. package/es/components/audioAnnotate/textInput/index.module.scss.js +1 -1
  121. package/es/components/audioAnnotate/utils/dataTransform.js +1 -0
  122. package/es/components/audioPlayer/clipRegion/index.js +1 -1
  123. package/es/components/audioPlayer/index.js +1 -1
  124. package/es/components/audioPlayer/useAudioCombine/index.js +3 -2
  125. package/es/components/audioPlayer/useAudioSegment/index.js +1 -1
  126. package/es/components/longText/index.js +1 -1
  127. package/es/components/pointCloud2DRectOperationView/index.js +1 -1
  128. package/es/components/pointCloudView/PointCloud2DSingleView.js +1 -1
  129. package/es/components/pointCloudView/PointCloud2DView.js +1 -1
  130. package/es/components/pointCloudView/PointCloud3DView.js +1 -1
  131. package/es/components/pointCloudView/PointCloudContext.js +1 -1
  132. package/es/components/pointCloudView/PointCloudListener.js +1 -1
  133. package/es/components/pointCloudView/PointCloudSegment2DView.js +1 -1
  134. package/es/components/pointCloudView/PointCloudTopView.js +1 -1
  135. package/es/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -0
  136. package/es/components/pointCloudView/hooks/useHighlight.js +1 -1
  137. package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  138. package/es/components/pointCloudView/hooks/useRotateEdge.js +1 -0
  139. package/es/components/pointCloudView/hooks/useSingleBox.js +1 -1
  140. package/es/components/pointCloudView/hooks/useStatus.js +1 -1
  141. package/es/components/pointCloudView/index.js +1 -1
  142. package/es/components/pointCloudView/utils/map.js +1 -0
  143. package/es/components/subAttributeList/index.js +1 -0
  144. package/es/components/videoAnnotate/videoClipTool/index.js +1 -1
  145. package/es/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
  146. package/es/index.css +64 -19
  147. package/es/index.js +1 -1
  148. package/es/store/Actions.js +1 -1
  149. package/es/store/annotatedBox/index.js +1 -1
  150. package/es/store/annotation/actionCreators.js +1 -1
  151. package/es/store/annotation/reducer.js +1 -1
  152. package/es/utils/AnnotationDataUtils.js +1 -1
  153. package/es/utils/index.js +1 -1
  154. package/es/views/MainView/index.js +1 -1
  155. package/es/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
  156. package/es/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
  157. package/es/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.js +1 -0
  158. package/es/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.module.scss.js +1 -0
  159. package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  160. package/es/views/MainView/sidebar/TagSidebar/index.js +1 -1
  161. package/es/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
  162. package/es/views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js +1 -0
  163. package/es/views/MainView/toolFooter/FooterTips/ToolHotKey/pointCloud/index.js +1 -1
  164. package/package.json +3 -3
  165. package/dist/assets/annotation/pointCloudTool/rotate180_black.svg.js +0 -1
  166. package/dist/assets/icons/9d70807.svg +0 -5
  167. package/es/assets/annotation/pointCloudTool/rotate180_black.svg.js +0 -1
@@ -1 +1 @@
1
- import{useLatest as B}from"ahooks";import{Spin as M}from"antd/es";import d,{useContext as N,useRef as w,useState as U,useEffect as u}from"react";import{connect as F}from"react-redux";import{usePointCloudViews as T}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as $}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as q}from"../../store/annotation/map.js";import{LabelBeeContext as A}from"../../store/ctx.js";import{PointCloud2DRectOperation as G,ImgUtils as H}from"@labelbee/lb-annotation";var J=Object.defineProperty,K=Object.defineProperties,Q=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,O=(o,e,t)=>e in o?J(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,f=(o,e)=>{for(var t in e||(e={}))W.call(e,t)&&O(o,t,e[t]);if(C)for(var t of C(e))X.call(e,t)&&O(o,t,e[t]);return o},R=(o,e)=>K(o,Q(e));const Y=o=>{var e;const{mappingData:t,size:l,config:b,checkMode:D,afterImgOnLoad:h}=o,s=(e=t==null?void 0:t.url)!=null?e:"",{pointCloudBoxList:c,setPointCloudResult:x}=N($),{update2DViewRect:y}=T(),p=d.useRef(null),n=w(null),m=B(y),_=w(null),[I,V]=U(!0),v=r=>{var a;const i=(a=m.current)==null?void 0:a.call(m,r);_.current=i,x(i)},j=()=>{var r;let a=[];c.forEach(i=>{const{rects:S=[],id:P,attribute:E,trackID:L}=i,g=S.find(z=>z.imageName===(t==null?void 0:t.path)),k=P+"_"+(t==null?void 0:t.path);g&&(a=[...a,R(f({},g),{boxID:P,id:k,attribute:E,order:L})])}),(r=n.current)==null||r.setResult(a)};return u(()=>{if(p.current){const r=new G({container:p.current,size:l,config:R(f({},b),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:D});return n.current=r,n.current.init(),n.current.on("updateDragResult",v),()=>{var a,i;(a=n.current)==null||a.unbind("updateDragResult",v),(i=n.current)==null||i.destroy()}}},[]),u(()=>{n.current&&s&&H.load(s).then(r=>{n.current.setImgNode(r),h(r),V(!1)})},[s]),u(()=>{var r;(r=n.current)==null||r.setSize(l)},[l]),u(()=>{c!==_.current&&j()},[c,s]),d.createElement(M,{spinning:I},d.createElement("div",{ref:p,style:f({position:"relative"},l)}))};var Z=F(q,null,null,{context:A})(Y);export{Z as default};
1
+ import{useMemoizedFn as P,useLatest as Y}from"ahooks";import{Spin as Z}from"antd/es";import N,{useContext as ee,useRef as z,useState as te,useMemo as ne,useEffect as d}from"react";import{connect as re}from"react-redux";import{usePointCloudViews as oe}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as ie}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as le}from"../../store/annotation/map.js";import{LabelBeeContext as ce}from"../../store/ctx.js";import{PointCloud2DRectOperation as ue,ImgUtils as ae}from"@labelbee/lb-annotation";var se=Object.defineProperty,de=Object.defineProperties,fe=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,J=(u,i,l)=>i in u?se(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,m=(u,i)=>{for(var l in i||(i={}))pe.call(i,l)&&J(u,l,i[l]);if(F)for(var l of F(i))me.call(i,l)&&J(u,l,i[l]);return u},R=(u,i)=>de(u,fe(i)),T=(u,i,l)=>new Promise((a,f)=>{var v=s=>{try{_(l.next(s))}catch(p){f(p)}},h=s=>{try{_(l.throw(s))}catch(p){f(p)}},_=s=>s.done?a(s.value):Promise.resolve(s.value).then(v,h);_((l=l.apply(u,i)).next())});const ve=u=>{var i,l;const{mappingData:a,size:f,config:v,checkMode:h,afterImgOnLoad:_,shouldExcludePointCloudBoxListUpdate:s}=u,p=(i=a==null?void 0:a.url)!=null?i:"",D=(l=a==null?void 0:a.fallbackUrl)!=null?l:"",{pointCloudBoxList:x,setPointCloudResult:C,defaultAttribute:y,rectList:O,addRectIn2DView:$,updateRectIn2DView:E,removeRectIn2DView:q}=ee(ie),{update2DViewRect:G,remove2DViewRect:H}=oe(),L=N.useRef(null),r=z(null),j=P(G),b=P(H),w=z(null),[K,B]=te(!0),V=ne(()=>O==null?void 0:O.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,O]),I=Y(a==null?void 0:a.path),U=e=>{const{boxID:o}=e;if(!s&&o){const t=j==null?void 0:j(e);w.current=t,C(t);return}E(e,!0)},A=e=>{I.current&&$(R(m({},e),{imageName:I.current}))},k=e=>{if(e.length===0)return;if(!s){const t=e.find(n=>n.boxID);if(t){const n=b==null?void 0:b(t);w.current=n,C(n),g();return}}const o=e.find(t=>t.extId);if(o){const{imageName:t,extId:n}=o,c=b==null?void 0:b({boxID:n,imageName:t});w.current=c,C(c)}q(e)},Q=P(()=>{let e=[];return x.forEach(o=>{const{rects:t=[],id:n,attribute:c,trackID:S}=o,M=t.find(X=>X.imageName===I.current),W=n+"_"+I.current;M&&(e=[...e,R(m({},M),{boxID:n,id:W,attribute:c,order:S})])}),e}),g=P(()=>{var e,o,t;const n=s?[]:Q(),c=(e=r.current)==null?void 0:e.selectedRectID;(o=r.current)==null||o.setResult([...n,...V]),c&&((t=r.current)==null||t.setSelectedRectID(c))});return d(()=>{if(L.current){const e=new ue({container:L.current,size:f,config:R(m({},v),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:h});return r.current=e,r.current.init(),r.current.on("updateDragResult",U),r.current.on("afterAddingDrawingRect",A),r.current.on("deleteSelectedRects",k),()=>{var o,t,n,c;(o=r.current)==null||o.unbind("updateDragResult",U),(t=r.current)==null||t.unbind("afterAddingDrawingRect",A),(n=r.current)==null||n.unbind("deleteSelectedRects",k),(c=r.current)==null||c.destroy()}}},[]),d(()=>{const e=t=>T(void 0,null,function*(){try{return yield ae.load(t)}catch(n){return console.error("Error loading image:",n),null}}),o=()=>T(void 0,null,function*(){var t;B(!0);let n=yield e(p);!n&&D&&(n=yield e(D)),n&&((t=r.current)==null||t.setImgNode(n),_(n)),B(!1)});r.current&&(p||D)&&o()},[p,D]),d(()=>{var e;(e=r.current)==null||e.setSize(f)},[f]),d(()=>{x!==w.current&&g()},[x]),d(()=>{var e,o,t;const n=V.find(c=>c.id===r.current.selectedRectID);(o=(e=r.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,y),n&&E(R(m({},(t=r.current)==null?void 0:t.selectedRect),{attribute:y})),g()},[y]),d(()=>{g()},[V]),d(()=>{g()},[s]),d(()=>{var e,o,t,n;const c=(o=(e=r.current)==null?void 0:e.config)!=null?o:{},S=R(m({},c),{attributeList:(t=v.attributeList)!=null?t:[]});(n=r.current)==null||n.setConfig(JSON.stringify(S))},[v.attributeList]),N.createElement(Z,{spinning:K},N.createElement("div",{ref:L,style:m({position:"relative"},f)}))};var _e=re(le,null,null,{context:ce})(ve);export{_e as default};
@@ -1 +1 @@
1
- import{getClassName as H}from"../../utils/dom.js";import u,{useRef as y,useState as L,useContext as R,useCallback as O,useEffect as N}from"react";import w from"../AnnotationView/index.js";import A from"../../hooks/useSize.js";import{useSingleBox as q}from"./hooks/useSingleBox.js";import{useHighlight as F}from"./hooks/useHighlight.js";import G from"./components/HighlightVisible/index.js";import{PointCloudContext as J}from"./PointCloudContext.js";import K from"../pointCloud2DRectOperationView/index.js";var M=(t,s,e)=>new Promise((d,a)=>{var m=o=>{try{i(e.next(o))}catch(n){a(n)}},r=o=>{try{i(e.throw(o))}catch(n){a(n)}},i=o=>o.done?d(o.value):Promise.resolve(o.value).then(m,r);i((e=e.apply(t,s)).next())});const Q=({view2dData:t,setSelectedID:s,currentData:e,showEnlarge:d,checkMode:a=!1,measureVisible:m})=>{var r;const i=y(null),o=y(),{selectedBox:n}=q(),p=A(i),{url:h,calib:g,path:j}=t,{toggle2dVisible:P,isHighlightVisible:S}=F({currentData:e}),[k,x]=L(!1),{cuboidBoxIn2DView:_,cacheImageNodeSize:z}=R(J),B=!t,b=c=>{f(),z({path:j,imgNode:c})},f=O(()=>{var c,C;const v=(c=o.current)==null?void 0:c.toolInstance;if(s(""),!n||!v)return;const l=t.annotations.find(E=>E.annotation.id===n.info.id);let V="";l&&((C=l==null?void 0:l.annotation.pointList)==null?void 0:C.length)>0&&(v.focusPositionByPointList(l==null?void 0:l.annotation.pointList),V=n.info.id,s(V))},[n,o.current,t.annotations]);N(()=>{f()},[f]);const I=()=>M(void 0,null,function*(){x(!0),yield P(h,g),x(!1)});return u.createElement("div",{className:H("point-cloud-2d-image"),ref:i},_?u.createElement(w,{src:(r=t==null?void 0:t.url)!=null?r:"",annotations:t.annotations,size:p,ref:o,globalStyle:{display:B?"none":"block"},afterImgOnLoad:b,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:m}):u.createElement(K,{mappingData:t,size:p,checkMode:a,afterImgOnLoad:b}),g&&u.createElement(G,{visible:S(h),onClick:I,loading:k,style:{position:"absolute",right:16,top:16,zIndex:d?-1:101}}))};export{Q as default};
1
+ import{getClassName as U}from"../../utils/dom.js";import l,{useRef as j,useState as A,useContext as F,useMemo as T,useCallback as q,useEffect as w}from"react";import G from"../AnnotationView/index.js";import J from"../../hooks/useSize.js";import{useSingleBox as K}from"./hooks/useSingleBox.js";import{useHighlight as M}from"./hooks/useHighlight.js";import Q from"./components/HighlightVisible/index.js";import{PointCloudContext as W}from"./PointCloudContext.js";import X from"./hooks/useDataLinkSwitch.js";import Y from"../pointCloud2DRectOperationView/index.js";var Z=(t,c,e)=>new Promise((s,a)=>{var f=o=>{try{i(e.next(o))}catch(n){a(n)}},u=o=>{try{i(e.throw(o))}catch(n){a(n)}},i=o=>o.done?s(o.value):Promise.resolve(o.value).then(f,u);i((e=e.apply(t,c)).next())});const $=({view2dData:t,setSelectedID:c,currentData:e,showEnlarge:s,checkMode:a=!1,measureVisible:f})=>{var u,i;const o=j(null),n=j(),{selectedBox:d}=K(),g=J(o),{url:x,fallbackUrl:b,calib:k,path:y}=t,{toggle2dVisible:_,isHighlightVisible:v}=M({currentData:e}),[z,C]=A(!1),{cuboidBoxIn2DView:p,cacheImageNodeSize:B}=F(W),I=!t,O=T(()=>({zIndex:s?-1:101,is2DView:!p,imageName:t.path}),[s,p,t.path]),{rendered:R,isLinking:E}=X(O),L=m=>{h(),B({path:y,imgNode:m})},h=q(()=>{var m,S;const V=(m=n.current)==null?void 0:m.toolInstance;if(c(""),!d||!V)return;const r=t.annotations.find(N=>N.annotation.id===d.info.id);let P="";r&&((S=r==null?void 0:r.annotation.pointList)==null?void 0:S.length)>0&&(V.focusPositionByPointList(r==null?void 0:r.annotation.pointList),P=d.info.id,c(P))},[d,n.current,t.annotations]);w(()=>{h()},[h]);const H=()=>Z(void 0,null,function*(){C(!0),yield _(x,b!=null?b:"",k),C(!1)});return l.createElement("div",{className:U("point-cloud-2d-image"),ref:o},p?l.createElement(G,{src:(u=t==null?void 0:t.url)!=null?u:"",fallbackSrc:(i=t==null?void 0:t.fallbackUrl)!=null?i:"",annotations:t.annotations,size:g,ref:n,globalStyle:{display:I?"none":"block"},afterImgOnLoad:L,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):l.createElement(l.Fragment,null,l.createElement(Y,{shouldExcludePointCloudBoxListUpdate:!E,mappingData:t,size:g,checkMode:a,afterImgOnLoad:L}),!a&&R),k&&l.createElement(Q,{visible:v(x),onClick:H,loading:z,style:{position:"absolute",right:16,top:16,zIndex:s?-1:101}}))};export{$ as default};
@@ -1 +1 @@
1
- import{getClassName as J}from"../../utils/dom.js";import i,{useState as L,useContext as ie,useEffect as Q}from"react";import{PointCloudContainer as le}from"./PointCloudLayout.js";import{PointCloudContext as re}from"./PointCloudContext.js";import{connect as se}from"react-redux";import{cKeyCode as ae,pointCloudLidar2image as ue,pointListLidar2Img as ce}from"@labelbee/lb-annotation";import{LabelBeeContext as de}from"../../store/ctx.js";import{a2MapStateToProps as me}from"../../store/annotation/map.js";import{toolStyleConverter as U}from"@labelbee/lb-utils";import fe from"./PointCloud2DSingleView.js";import W from"./components/TitleButton/index.js";import{LeftOutlined as pe}from"@ant-design/icons";import ge from"classnames";import ve from"../../assets/annotation/common/icon_esc.svg.js";import be from"../../assets/annotation/common/icon_left_squareOutlined.svg.js";import ye from"../../assets/annotation/common/icon_right_squareOutlined.svg.js";import{isNumber as Ee}from"lodash";var _e=Object.defineProperty,he=Object.defineProperties,we=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,Y=(e,n,t)=>n in e?_e(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,f=(e,n)=>{for(var t in n||(n={}))Ce.call(n,t)&&Y(e,t,n[t]);if(X)for(var t of X(n))Pe.call(n,t)&&Y(e,t,n[t]);return e},p=(e,n)=>he(e,we(n));const I=ae.default,Le=({showEnlarge:e,isEnlargeTopView:n,data:t,setIsEnlarge:y,setCurIndex:g,curIndex:E=0,index:x,annotations2d:_})=>n?i.createElement(W,{title:t==null?void 0:t.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?i.createElement("div",{style:{display:"flex",alignItems:"center"}},i.createElement(pe,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{y(!1),g(void 0)}}),i.createElement("span",null,t==null?void 0:t.calName),i.createElement("span",{style:{marginLeft:"8px"}},E+1,"/",_==null?void 0:_.length)):i.createElement(W,{title:t==null?void 0:t.calName,onClick:()=>{y(!0),g(x)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),xe=({currentData:e,config:n,thumbnailWidth:t,isEnlargeTopView:y,highlightAttribute:g,loadPCDFileLoading:E,checkMode:x,measureVisible:_})=>{var O;const[d,Z]=L([]),{topViewInstance:B,displayPointCloudList:j,polygonList:S,imageSizes:N,selectedIDs:V}=ie(re),[F,D]=L(""),[h,k]=L(!1),[a,w]=L(void 0);Q(()=>{var l;if(!E&&B&&(e==null?void 0:e.mappingImgList)&&((l=e==null?void 0:e.mappingImgList)==null?void 0:l.length)>0){const r={fill:"transparent",color:"green"};let s=[];e==null||e.mappingImgList.forEach(o=>{var v,T,K;const $=j.reduce((m,c)=>{var b,u;const C=c.id===F||g===c.attribute,{transferViewData:H,viewRangePointList:P}=(b=ue(c,o.calib,{createRange:C}))!=null?b:{};if(!H||!P)return[];const M=(u=U.getColorFromConfig({attribute:c.attribute},p(f({},n),{attributeConfigurable:!0}),{}))==null?void 0:u.stroke,ne=ee({viewDataPointList:H,pointCloudBox:c,defaultViewStyle:r,stroke:M}),G=[...m,...ne];return(P==null?void 0:P.length)>0&&G.unshift({type:"polygon",annotation:p(f({id:F,pointList:P},r),{stroke:M,fill:"rgba(255, 255, 255, 0.6)"})}),G},[]),q=N[(v=o==null?void 0:o.path)!=null?v:""];q&&Ee((T=o==null?void 0:o.calib)==null?void 0:T.groundHeight)&&S.forEach(m=>{const c=m.pointList.map(u=>{var C;return p(f({},u),{z:(C=o==null?void 0:o.calib)==null?void 0:C.groundHeight})}),b=ce(c,o==null?void 0:o.calib,q);if(b){const u=U.getColorFromConfig({attribute:m.attribute},p(f({},n),{attributeConfigurable:!0}),{});$.push({type:"polygon",annotation:p(f({id:m.id,pointList:b},r),{stroke:u==null?void 0:u.stroke,fill:V.includes(m.id)?u==null?void 0:u.fill:"rgba(255, 255, 255, 0.6)"})})}}),s.push({annotations:$,url:o==null?void 0:o.url,calName:(K=o==null?void 0:o.calib)==null?void 0:K.calName,calib:o==null?void 0:o.calib,path:o==null?void 0:o.path})}),Z(s)}},[j,e==null?void 0:e.mappingImgList,F,g,E,S,N,V]),Q(()=>(window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R)}),[a]);const R=l=>{const{keyCode:r}=l;switch(r){case I.Esc:h&&k(!1);break;case I.Left:A();break;case I.Right:z();break}},A=()=>{a===void 0||!h||Number(a)>0&&w(a-1)},z=()=>{a===void 0||!h||Number(a)<(d==null?void 0:d.length)-1&&w(a+1)},ee=({viewDataPointList:l,pointCloudBox:r,defaultViewStyle:s,stroke:o})=>l?l.map(v=>({type:v.type,annotation:p(f({id:r.id,pointList:v.pointList},s),{stroke:o})})):[],te=!e||!(e==null?void 0:e.mappingImgList)||!(((O=e==null?void 0:e.mappingImgList)==null?void 0:O.length)>0),oe=i.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},i.createElement("img",{src:be,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>A()}),i.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),i.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),i.createElement("img",{src:ye,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>z()}),i.createElement("img",{src:ve,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{k(!1),w(void 0)}}),i.createElement("span",null,"\u952E\u9000\u51FA"));return(d==null?void 0:d.length)>0?i.createElement(i.Fragment,null,d.map((l,r)=>{const s=h&&r===a;return i.createElement(le,{className:ge({[J("point-cloud-2d-container")]:!0,[J("point-cloud-container","zoom")]:s}),title:i.createElement(Le,{showEnlarge:s,isEnlargeTopView:y,data:l,setIsEnlarge:k,setCurIndex:w,curIndex:a,index:r,annotations2d:d}),titleOnSurface:!s,style:{display:te?"none":"flex",width:s?"100%":t},key:r,toolbar:oe},(l==null?void 0:l.annotations)&&(l==null?void 0:l.url)&&i.createElement(fe,{currentData:e,view2dData:l,setSelectedID:D,showEnlarge:s,checkMode:x,measureVisible:_}))})):null};var Fe=se(me,null,null,{context:de})(xe);export{Fe as default};
1
+ import{getClassName as Q}from"../../utils/dom.js";import i,{useState as L,useContext as ae,useEffect as W}from"react";import{PointCloudContainer as ce}from"./PointCloudLayout.js";import{PointCloudContext as de}from"./PointCloudContext.js";import{connect as me}from"react-redux";import{cKeyCode as fe,pointCloudLidar2image as pe,pointListLidar2Img as ge}from"@labelbee/lb-annotation";import{LabelBeeContext as ve}from"../../store/ctx.js";import{a2MapStateToProps as be}from"../../store/annotation/map.js";import{toolStyleConverter as X}from"@labelbee/lb-utils";import ye from"./PointCloud2DSingleView.js";import Y from"./components/TitleButton/index.js";import{LeftOutlined as Ee}from"@ant-design/icons";import he from"classnames";import _e from"../../assets/annotation/common/icon_esc.svg.js";import we from"../../assets/annotation/common/icon_left_squareOutlined.svg.js";import Ce from"../../assets/annotation/common/icon_right_squareOutlined.svg.js";import{isNumber as Pe}from"lodash";import{getBoundingRect as Le,isBoundingRectInImage as xe}from"../../utils/index.js";var Ie=Object.defineProperty,ke=Object.defineProperties,Fe=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,D=(e,n,o)=>n in e?Ie(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,m=(e,n)=>{for(var o in n||(n={}))Oe.call(n,o)&&D(e,o,n[o]);if(Z)for(var o of Z(n))je.call(n,o)&&D(e,o,n[o]);return e},f=(e,n)=>ke(e,Fe(n));const j=fe.default,Ne=({showEnlarge:e,isEnlargeTopView:n,data:o,setIsEnlarge:y,setCurIndex:g,curIndex:E=0,index:x,annotations2d:h})=>n?i.createElement(Y,{title:o==null?void 0:o.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?i.createElement("div",{style:{display:"flex",alignItems:"center"}},i.createElement(Ee,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{y(!1),g(void 0)}}),i.createElement("span",null,o==null?void 0:o.calName),i.createElement("span",{style:{marginLeft:"8px"}},E+1,"/",h==null?void 0:h.length)):i.createElement(Y,{title:o==null?void 0:o.calName,onClick:()=>{y(!0),g(x)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),Re=({currentData:e,config:n,thumbnailWidth:o,isEnlargeTopView:y,highlightAttribute:g,loadPCDFileLoading:E,checkMode:x,measureVisible:h})=>{var N;const[p,ee]=L([]),{topViewInstance:te,displayPointCloudList:R,polygonList:S,imageSizes:I,selectedIDs:V}=ae(de),[k,oe]=L(""),[_,F]=L(!1),[u,w]=L(void 0);W(()=>{var l;if(!E&&te&&(e==null?void 0:e.mappingImgList)&&((l=e==null?void 0:e.mappingImgList)==null?void 0:l.length)>0){const r={fill:"transparent",color:"green"};let s=[];e==null||e.mappingImgList.forEach(t=>{var v,K,$,q;const H=R.reduce((c,d)=>{var b,a;const C=d.id===k||g===d.attribute,{transferViewData:O,viewRangePointList:P}=(b=pe(d,t.calib,{createRange:C}))!=null?b:{};if(!O||!P)return[];const re=O.reduce((G,J)=>J.type==="line"?[...G,...J.pointList]:G,[]),se=f(m({},Le(re)),{imageName:t.path});if(!xe(se,t.path,I))return c;const B=(a=X.getColorFromConfig({attribute:d.attribute},f(m({},n),{attributeConfigurable:!0}),{}))==null?void 0:a.stroke,ue=ne({viewDataPointList:O,pointCloudBox:d,defaultViewStyle:r,stroke:B}),M=[...c,...ue];return(P==null?void 0:P.length)>0&&M.unshift({type:"polygon",annotation:f(m({id:k,pointList:P},r),{stroke:B,fill:"rgba(255, 255, 255, 0.6)"})}),M},[]),U=I[(v=t==null?void 0:t.path)!=null?v:""];U&&Pe((K=t==null?void 0:t.calib)==null?void 0:K.groundHeight)&&S.forEach(c=>{const d=c.pointList.map(a=>{var C;return f(m({},a),{z:(C=t==null?void 0:t.calib)==null?void 0:C.groundHeight})}),b=ge(d,t==null?void 0:t.calib,U);if(b){const a=X.getColorFromConfig({attribute:c.attribute},f(m({},n),{attributeConfigurable:!0}),{});H.push({type:"polygon",annotation:f(m({id:c.id,pointList:b},r),{stroke:a==null?void 0:a.stroke,fill:V.includes(c.id)?a==null?void 0:a.fill:"rgba(255, 255, 255, 0.6)"})})}}),s.push({annotations:H,url:t==null?void 0:t.url,fallbackUrl:($=t==null?void 0:t.fallbackUrl)!=null?$:"",calName:(q=t==null?void 0:t.calib)==null?void 0:q.calName,calib:t==null?void 0:t.calib,path:t==null?void 0:t.path})}),ee(s)}},[R,e==null?void 0:e.mappingImgList,k,g,E,S,I,V]),W(()=>(window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}),[u]);const A=l=>{const{keyCode:r}=l;switch(r){case j.Esc:_&&F(!1);break;case j.Left:z();break;case j.Right:T();break}},z=()=>{u===void 0||!_||Number(u)>0&&w(u-1)},T=()=>{u===void 0||!_||Number(u)<(p==null?void 0:p.length)-1&&w(u+1)},ne=({viewDataPointList:l,pointCloudBox:r,defaultViewStyle:s,stroke:t})=>l?l.map(v=>({type:v.type,annotation:f(m({id:r.id,pointList:v.pointList},s),{stroke:t})})):[],ie=!e||!(e==null?void 0:e.mappingImgList)||!(((N=e==null?void 0:e.mappingImgList)==null?void 0:N.length)>0),le=i.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},i.createElement("img",{src:we,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>z()}),i.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),i.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),i.createElement("img",{src:Ce,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>T()}),i.createElement("img",{src:_e,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{F(!1),w(void 0)}}),i.createElement("span",null,"\u952E\u9000\u51FA"));return(p==null?void 0:p.length)>0?i.createElement(i.Fragment,null,p.map((l,r)=>{const s=_&&r===u;return i.createElement(ce,{className:he({[Q("point-cloud-2d-container")]:!0,[Q("point-cloud-container","zoom")]:s}),title:i.createElement(Ne,{showEnlarge:s,isEnlargeTopView:y,data:l,setIsEnlarge:F,setCurIndex:w,curIndex:u,index:r,annotations2d:p}),titleOnSurface:!s,style:{display:ie?"none":"flex",width:s?"100%":o},key:r,toolbar:le},(l==null?void 0:l.annotations)&&(l==null?void 0:l.url)&&i.createElement(ye,{key:l.url,currentData:e,view2dData:l,setSelectedID:oe,showEnlarge:s,checkMode:x,measureVisible:h}))})):null};var Se=me(be,null,null,{context:ve})(Re);export{Se as default};
@@ -1 +1 @@
1
- import{getClassName as m}from"../../utils/dom.js";import{cKeyCode as K,PointCloud as M}from"@labelbee/lb-annotation";import{PointCloudUtils as B,toolStyleConverter as Z,EPerspectiveView as E}from"@labelbee/lb-utils";import j from"classnames";import e,{useContext as b,useState as O,useRef as H,useEffect as u,useMemo as U}from"react";import{PointCloudContainer as q}from"./PointCloudLayout.js";import{PointCloudContext as G}from"./PointCloudContext.js";import{a2MapStateToProps as J}from"../../store/annotation/map.js";import{connect as Q}from"react-redux";import{jsonParser as W}from"../../utils/index.js";import{useSingleBox as X}from"./hooks/useSingleBox.js";import{useSphere as Y}from"./hooks/useSphere.js";import{Switch as $,Tooltip as ee}from"antd";import te from"../../hooks/useSize.js";import{usePointCloudViews as oe}from"./hooks/usePointCloudViews.js";import{useTranslation as L}from"react-i18next";import{LabelBeeContext as ne}from"../../store/ctx.js";import ie from"./components/PointCloudSizeSlider/index.js";import re from"./components/TitleButton/index.js";import{LeftOutlined as ae}from"@ant-design/icons";var le=Object.defineProperty,se=Object.defineProperties,ce=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,D=(n,r,a)=>r in n?le(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,N=(n,r)=>{for(var a in r||(r={}))me.call(r,a)&&D(n,a,r[a]);if(z)for(var a of z(r))ue.call(r,a)&&D(n,a,r[a]);return n},de=(n,r)=>se(n,ce(r));const pe=K.default,we="LABELBEE-POINTCLOUD",P=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),d=({perspectiveView:n})=>{const{isActive:r,setTarget3DView:a}=b(P),o=p=>j({[m("point-cloud-3d-view",p)]:!0,active:r});return e.createElement("span",{onClick:()=>{a(E[n])},className:o(n.toLocaleLowerCase())})},k=({isEnlarge:n})=>{const{reset3DView:r,followTopView:a}=b(P),{t:o}=L(),p=e.createElement(e.Fragment,null,e.createElement(d,{perspectiveView:"Top"}),e.createElement(d,{perspectiveView:"Front"}),e.createElement(d,{perspectiveView:"Left"}),e.createElement(d,{perspectiveView:"Back"}),e.createElement(d,{perspectiveView:"Right"}),e.createElement(d,{perspectiveView:"LFT"}),e.createElement(d,{perspectiveView:"RBT"})),V=e.createElement(e.Fragment,null,e.createElement(ee,{title:o("CameraFollowTopView")},e.createElement("span",{onClick:()=>{a()},className:m("point-cloud-3d-view","followTop")})),e.createElement("span",{onClick:()=>{r()},className:m("point-cloud-3d-view","reset")}));return n?e.createElement("div",{className:m("point-cloud-3d-sidebarZoom")},V,p):e.createElement("div",{className:m("point-cloud-3d-sidebar")},p,V)},ve=({currentData:n,config:r,highlightAttribute:a})=>{const o=b(G),[p,V]=O(!0),[v,_]=O(!1),f=H(null),{initPointCloud3d:S}=oe(),C=te(f),{t:h}=L();u(()=>{!o.mainViewInstance||S==null||S(C)},[C]);const{selectedBox:w}=X(),{selectedSphere:g}=Y(),x=t=>{var i,l;const s=w==null?void 0:w.info;if(s){const c=N({},s.center);c.x=c.x-.01,c.z=1e3;const I=t===E.Top;(i=o.mainViewInstance)==null||i.updateCameraByBox(s,t,I?c:void 0)}g&&((l=o.mainViewInstance)==null||l.updateCameraBySphere(g,t))},R=()=>{var t;(t=o.mainViewInstance)==null||t.resetCamera()},F=()=>{var t,i;const l=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((i=o.mainViewInstance)==null||i.applyCameraTarget(l))};u(()=>{if(f.current&&(n==null?void 0:n.url)){let t=o.mainViewInstance;!t&&C.width&&(t=new M({container:f.current,isOrthographicCamera:!0,orthographicParams:B.getDefaultOrthographicParams(C),config:r}),o.setMainViewInstance(t))}},[C,n]),u(()=>{var t;if(f.current&&(n==null?void 0:n.url)&&n.result&&o.mainViewInstance){let i=o.mainViewInstance;const l=B.getBoxParamsFromResultList(n.result);l.forEach(s=>{var c;const I=(c=Z.getColorFromConfig({attribute:s.attribute},de(N({},r),{attributeConfigurable:!0}),{}))==null?void 0:c.hex;i==null||i.addBoxToSense(s,I)}),i.render(),o.setPointCloudResult(l),o.setPointCloudValid((t=W(n.result))==null?void 0:t.valid)}},[n,o.mainViewInstance]),u(()=>{var t,i,l,s;if(w){x(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[w]),u(()=>{var t,i,l,s;if(g){x(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[g]),u(()=>(window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}),[]);const T=t=>{if(t.keyCode===pe.Esc){_(!1);return}},y=U(()=>({reset3DView:R,setTarget3DView:x,isActive:!!w,followTopView:F}),[w,o.mainViewInstance]);u(()=>{var t,i,l;const s=o.pointCloudBoxList.filter(c=>c.attribute===a);(s==null?void 0:s.length)>0&&((t=o.mainViewInstance)==null||t.clearHighlightBoxes(),(i=o.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((l=o.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,o.mainViewInstance]);const A=e.createElement(e.Fragment,null,e.createElement(ie,{onChange:t=>{var i;(i=o.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),e.createElement("span",{style:{marginRight:8}},h("ShowArrows")),e.createElement($,{size:"small",checked:p,onChange:t=>{var i;V(t),(i=o.mainViewInstance)==null||i.setShowDirection(t)}}),v&&e.createElement(P.Provider,{value:y},e.createElement(k,{isEnlarge:v})));return e.createElement(q,{className:j({[m("point-cloud-3d-container")]:!0,[m("point-cloud-container","zoom")]:v}),title:v?e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement(ae,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{_(!1)}}),h("3DView")):e.createElement(re,{title:h("3DView"),onClick:()=>{_(!0)}}),toolbar:A},e.createElement("div",{className:m("point-cloud-3d-content")},!v&&e.createElement(P.Provider,{value:y},e.createElement(k,null)),e.createElement("div",{className:m("point-cloud-3d-view"),id:we,ref:f})))};var fe=Q(J,null,null,{context:ne})(ve);export{fe as default};
1
+ import{getClassName as m}from"../../utils/dom.js";import{cKeyCode as M,PointCloud as Z}from"@labelbee/lb-annotation";import{PointCloudUtils as b,toolStyleConverter as H,EPerspectiveView as E}from"@labelbee/lb-utils";import L from"classnames";import e,{useContext as S,useState as j,useRef as U,useEffect as u,useMemo as q}from"react";import{PointCloudContainer as G}from"./PointCloudLayout.js";import{PointCloudContext as J}from"./PointCloudContext.js";import{a2MapStateToProps as Q}from"../../store/annotation/map.js";import{connect as W}from"react-redux";import{jsonParser as X}from"../../utils/index.js";import{useSingleBox as Y}from"./hooks/useSingleBox.js";import{useSphere as $}from"./hooks/useSphere.js";import{Switch as ee,Tooltip as te}from"antd";import oe from"../../hooks/useSize.js";import{usePointCloudViews as ne}from"./hooks/usePointCloudViews.js";import{useTranslation as O}from"react-i18next";import{LabelBeeContext as ie}from"../../store/ctx.js";import re from"./components/PointCloudSizeSlider/index.js";import ae from"./components/TitleButton/index.js";import{LeftOutlined as le}from"@ant-design/icons";var se=Object.defineProperty,ce=Object.defineProperties,me=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,D=(n,r,a)=>r in n?se(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,N=(n,r)=>{for(var a in r||(r={}))ue.call(r,a)&&D(n,a,r[a]);if(z)for(var a of z(r))de.call(r,a)&&D(n,a,r[a]);return n},pe=(n,r)=>ce(n,me(r));const we=M.default,ve="LABELBEE-POINTCLOUD",_=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),d=({perspectiveView:n})=>{const{isActive:r,setTarget3DView:a}=S(_),o=p=>L({[m("point-cloud-3d-view",p)]:!0,active:r});return e.createElement("span",{onClick:()=>{a(E[n])},className:o(n.toLocaleLowerCase())})},k=({isEnlarge:n})=>{const{reset3DView:r,followTopView:a}=S(_),{t:o}=O(),p=e.createElement(e.Fragment,null,e.createElement(d,{perspectiveView:"Top"}),e.createElement(d,{perspectiveView:"Front"}),e.createElement(d,{perspectiveView:"Left"}),e.createElement(d,{perspectiveView:"Back"}),e.createElement(d,{perspectiveView:"Right"}),e.createElement(d,{perspectiveView:"LFT"}),e.createElement(d,{perspectiveView:"RBT"})),V=e.createElement(e.Fragment,null,e.createElement(te,{title:o("CameraFollowTopView")},e.createElement("span",{onClick:()=>{a()},className:m("point-cloud-3d-view","followTop")})),e.createElement("span",{onClick:()=>{r()},className:m("point-cloud-3d-view","reset")}));return n?e.createElement("div",{className:m("point-cloud-3d-sidebarZoom")},V,p):e.createElement("div",{className:m("point-cloud-3d-sidebar")},p,V)},fe=({currentData:n,config:r,highlightAttribute:a})=>{const o=S(J),[p,V]=j(!0),[v,h]=j(!1),f=U(null),{initPointCloud3d:T}=ne(),C=oe(f),{t:x}=O();u(()=>{!o.mainViewInstance||T==null||T(C)},[C]);const{selectedBox:w}=Y(),{selectedSphere:g}=$(),I=t=>{var i,l;const s=w==null?void 0:w.info;if(s){const c=N({},s.center);c.x=c.x-.01,c.z=1e3;const P=t===E.Top;(i=o.mainViewInstance)==null||i.updateCameraByBox(s,t,P?c:void 0)}g&&((l=o.mainViewInstance)==null||l.updateCameraBySphere(g,t))},R=()=>{var t;(t=o.mainViewInstance)==null||t.resetCamera()},F=()=>{var t,i;const l=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((i=o.mainViewInstance)==null||i.applyCameraTarget(l))};u(()=>{if(f.current&&(n==null?void 0:n.url)){let t=o.mainViewInstance;!t&&C.width&&(t=new Z({container:f.current,isOrthographicCamera:!0,orthographicParams:b.getDefaultOrthographicParams(C),config:r}),o.setMainViewInstance(t))}},[C,n]),u(()=>{var t;if(f.current&&(n==null?void 0:n.url)&&n.result&&o.mainViewInstance){let i=o.mainViewInstance;const l=b.getBoxParamsFromResultList(n.result);l.forEach(c=>{var P;const K=(P=H.getColorFromConfig({attribute:c.attribute},pe(N({},r),{attributeConfigurable:!0}),{}))==null?void 0:P.hex;i==null||i.addBoxToSense(c,K)}),i.render(),o.setPointCloudResult(l);const s=b.getRectParamsFromResultList(n.result);o.setRectList(s),o.setPointCloudValid((t=X(n.result))==null?void 0:t.valid)}},[n,o.mainViewInstance]),u(()=>{var t,i,l,s;if(w){I(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[w]),u(()=>{var t,i,l,s;if(g){I(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[g]),u(()=>(window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}),[]);const y=t=>{if(t.keyCode===we.Esc){h(!1);return}},B=q(()=>({reset3DView:R,setTarget3DView:I,isActive:!!w,followTopView:F}),[w,o.mainViewInstance]);u(()=>{var t,i,l;const s=o.pointCloudBoxList.filter(c=>c.attribute===a);(s==null?void 0:s.length)>0&&((t=o.mainViewInstance)==null||t.clearHighlightBoxes(),(i=o.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((l=o.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,o.mainViewInstance]);const A=e.createElement(e.Fragment,null,e.createElement(re,{onChange:t=>{var i;(i=o.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),e.createElement("span",{style:{marginRight:8}},x("ShowArrows")),e.createElement(ee,{size:"small",checked:p,onChange:t=>{var i;V(t),(i=o.mainViewInstance)==null||i.setShowDirection(t)}}),v&&e.createElement(_.Provider,{value:B},e.createElement(k,{isEnlarge:v})));return e.createElement(G,{className:L({[m("point-cloud-3d-container")]:!0,[m("point-cloud-container","zoom")]:v}),title:v?e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement(le,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{h(!1)}}),x("3DView")):e.createElement(ae,{title:x("3DView"),onClick:()=>{h(!0)}}),toolbar:A},e.createElement("div",{className:m("point-cloud-3d-content")},!v&&e.createElement(_.Provider,{value:B},e.createElement(k,null)),e.createElement("div",{className:m("point-cloud-3d-view"),id:ve,ref:f})))};var Ce=W(Q,null,null,{context:ie})(fe);export{Ce as default};
@@ -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 q}from"@labelbee/lb-utils";import Pt,{useState as r,useRef as Kt,useMemo as H,useCallback as J,useEffect as K}from"react";import{ActionsHistory as yt,EToolName as Q,uuid as Qt}from"@labelbee/lb-annotation";import{useDispatch as Ut}from"../../store/ctx.js";import{ChangeSave as Xt}from"../../store/annotation/actionCreators.js";import Yt from"../../store/annotatedBox/index.js";import wt from"lodash";import{addMapIndirectWeakSetItem as bt}from"./utils/map.js";var $t=Object.defineProperty,te=Object.defineProperties,ee=Object.getOwnPropertyDescriptors,Ct=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable,St=(a,n,c)=>n in a?$t(a,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[n]=c,M=(a,n)=>{for(var c in n||(n={}))ne.call(n,c)&&St(a,c,n[c]);if(Ct)for(var c of Ct(n))ie.call(n,c)&&St(a,c,n[c]);return a},Lt=(a,n)=>te(a,ee(n)),oe=(a,n,c)=>new Promise((L,R)=>{var A=m=>{try{P(c.next(m))}catch(b){R(b)}},j=m=>{try{P(c.throw(m))}catch(b){R(b)}},P=m=>m.done?L(m.value):Promise.resolve(m.value).then(A,j);P((c=c.apply(a,n)).next())});const Dt=a=>wt.pick(a,["id","attribute","width","height","x","y","imageName"]),xt=Pt.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 yt,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:Q.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:q.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:a=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:a=>!1,removeRectBySpecifyId:(a,n,c)=>!1,removeRectByPointCloudBoxId:a=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map}),se=({children:a})=>{const[n,c]=r([]),[L,R]=r([]),[A,j]=r([]),[P,m]=r([]),[b,Rt]=r([]),[I,k]=r([]),[_,F]=r([]),[U,At]=r(!0),[X,_t]=r(2),[Y,Bt]=r(!0),[$,Vt]=r(1),[f,tt]=r(),[et,nt]=r(),[it,ot]=r(),[u,st]=r(),[rt,Nt]=r(""),[z,Ot]=r(Q.Rect),Ht=Kt(new yt).current,[g,E]=r([]),[lt,Mt]=r(""),[G,jt]=r(q.Detection),[D,at]=r(void 0),[T,kt]=r([]),[Z,Ft]=r([]),h=Yt(),[ct,zt]=r({}),Et=Ut(),Gt=i=>{const{imgNode:o,path:e}=i;e&&o&&zt(d=>Lt(M({},d),{[e]:{width:o.width,height:o.height}}))},dt=H(()=>I.length===1?I[0]:"",[I]),B=J((i,o,e="extId")=>{const d=e||"id",l=new Set(o);return m(p=>{let C=!1;const S=p.filter(N=>{const W=N[d],O=l.has(W)?N.imageName!==i:!0;return O||(C=!0),O});return C?S:p}),!0},[]),ut=J(i=>{const o=n.map(e=>e.id);return B(i,o,"extId")},[n,B]),pt=J(i=>{if(!i)return!1;const o=n.filter(e=>Array.isArray(e.rects)).map(e=>{const{id:d,attribute:l,trackID:p}=e,C=e.rects.find(S=>S.imageName===i);if(C){const S=wt.pick(C,["width","height","x","y","imageName"]);return Lt(M({},S),{id:Qt(),attribute:l,order:p,extId:d,lineDash:[]})}return null}).filter(e=>e!==null);return o.length?(m(e=>{const d=new Set(e.filter(p=>i===p.imageName).map(p=>p.extId)),l=o.filter(p=>d.has(p.extId)===!1);return l.length?[...e,...l]:e}),!0):!1},[n]),mt=H(()=>n.filter(o=>Array.isArray(o.rects)&&o.rects.length>0).reduce((o,e)=>{var d;return(d=e.rects)==null||d.forEach(l=>{const{imageName:p}=l;if(!p){console.warn("Missing image name"),console.trace(l,e);return}bt(o,p,e.id,e)}),o},new Map),[n]),ft=H(()=>P.filter(i=>i.extId!==void 0&&i.id!==void 0).reduce((i,o)=>{const e=o.imageName;return e?(bt(i,e,o.extId,o),i):(console.warn("missing image name"),console.log(o,P),i)},new Map),[P]),V=H(()=>{const i=n.find(t=>t.id===dt),o=t=>{const s=n.concat(t);return c(s),s},e=t=>{const s=L.concat(t);return R(s),s},d=t=>{At(t!==!1)},l=t=>{t===void 0&&k([]),typeof t=="string"&&k([t]),Array.isArray(t)&&k(Array.from(new Set(t)))},p=t=>{I.includes(t)?l(I.filter(s=>s!==t)):l([...I,t])},C=t=>{const s=Dt(t);m(v=>[...v,s])},S=(t,s=!1)=>{const v=Dt(t);m(w=>w.map(y=>y.id===t.id?s?M(M({},y),v):v:y))},N=t=>{m(s=>s.filter(v=>!t.find(w=>w.id===v.id)))},W=t=>{_.includes(t)?F([]):F([t])},O=()=>{if(z===Q.Rect){const t=n.map(s=>s.id);l(t),f==null||f.pointCloud2dOperation.setSelectedIDs(t)}},Zt=t=>{l(n.filter(s=>s.attribute===t).map(s=>s.id))},gt=n.filter(t=>!g.includes(t.attribute)),ht=L.filter(t=>!g.includes(t.attribute)),vt=b.filter(t=>t.attribute&&!g.includes(t.attribute)),Wt=t=>{if(g.includes(t))E(g.filter(s=>s!==t));else{const s=g.concat(t);E(s)}},qt=(t=gt,s=A,v=ht,w=vt,y=T)=>{var x;u==null||u.clearAllBox(),u==null||u.clearAllSphere(),f==null||f.updatePolygonList(t,s),f==null||f.updatePointList(v),f==null||f.updateLineList(w),u==null||u.generateBoxes(t),u==null||u.generateSpheres(v),(x=D==null?void 0:D.store)==null||x.updateCurrentSegment(y),It(t)},Jt=()=>{tt(void 0),nt(void 0),ot(void 0),st(void 0)},It=(t,s)=>oe(void 0,null,function*(){var v;if(!u)return;const w=u.pointCloudObject;if(!!w)try{const y=yield u.getHighlightIndexByMappingImgList({mappingImgList:s!=null?s:Z,points:w.geometry.attributes.position.array}),x=yield u==null?void 0:u.highlightOriginPointCloud(t,y);return x&&((v=f==null?void 0:f.pointCloudInstance)==null||v.updateColor(x)),x}catch(y){console.error(y)}});return{selectedID:dt,pointCloudBoxList:n,pointCloudSphereList:L,displayPointCloudList:gt,displaySphereList:ht,displayLineList:vt,selectedIDs:I,setPointCloudResult:c,setSelectedIDs:l,addPointCloudBox:o,addPointCloudSphere:e,setPointCloudSphereList:R,valid:U,selectedPointCloudBox:i,setPointCloudValid:d,addSelectedID:p,addHighlightID:W,selectedAllBoxes:O,topViewInstance:f,setTopViewInstance:tt,sideViewInstance:et,setSideViewInstance:nt,backViewInstance:it,setBackViewInstance:ot,mainViewInstance:u,setMainViewInstance:st,polygonList:A,setPolygonList:j,rectList:P,setRectList:m,addRectIn2DView:C,removeRectIn2DView:N,updateRectIn2DView:S,lineList:b,setLineList:Rt,zoom:$,setZoom:Vt,history:Ht,toggleAttributesVisible:Wt,hideAttributes:g,setHideAttributes:E,reRender:qt,attrPanelLayout:lt,setAttrPanelLayout:Mt,syncAllViewPointCloudColor:It,defaultAttribute:rt,setDefaultAttribute:Nt,pointCloudPattern:z,setPointCloudPattern:Ot,selectSpecAttr:Zt,globalPattern:G,setGlobalPattern:t=>{G!==t&&(Et(Xt),jt(t),t===q.Detection&&at(void 0))},ptSegmentInstance:D,setPtSegmentInstance:at,segmentation:T,setSegmentation:kt,clearAllDetectionInstance:Jt,highlight2DDataList:Z,setHighlight2DDataList:Ft,cuboidBoxIn2DView:Y,setCuboidBoxIn2DView:Bt,imageSizes:ct,cacheImageNodeSize:Gt,highlightIDs:_,setHighlightIDs:F,removeRectByPointCloudBoxId:ut,removeRectBySpecifyId:B,addRectFromPointCloudBoxByImageName:pt,rectRotateSensitivity:X,setRectRotateSensitivity:_t,imageNamePointCloudBoxMap:mt,linkageImageNameRectMap:ft}},[U,I,n,L,A,b,P,f,et,it,u,$,g,lt,rt,z,G,D,T,Z,Y,ct,_,ut,B,pt,X,mt,ft]);K(()=>{var i,o,e;(i=h==null?void 0:h.setPointCloudBoxList)==null||i.call(h,n),(o=h==null?void 0:h.setHighlightIDs)==null||o.call(h,_),(e=h==null?void 0:h.setSelectedIDs)==null||e.call(h,I)},[n,I,_]),K(()=>{var i;(i=h==null?void 0:h.setPtCtx)==null||i.call(h,V)},[V]);const Tt=()=>{const i=n.filter(l=>g.includes(l.attribute)),{setSelectedIDs:o,reRender:e}=V,d=i.map(l=>l.id);d.length>0&&o(I.filter(l=>!d.includes(l))),e()};return K(()=>{var i,o,e,d;Tt(),(o=(i=f==null?void 0:f.toolInstance)==null?void 0:i.setHiddenAttributes)==null||o.call(i,g),(d=(e=D==null?void 0:D.store)==null?void 0:e.setHiddenAttributes)==null||d.call(e,g)},[g]),Pt.createElement(xt.Provider,{value:V},a)};export{xt as PointCloudContext,se as PointCloudProvider};
@@ -1 +1 @@
1
- import{PointCloudContext as ee}from"./PointCloudContext.js";import{useRotate as te}from"./hooks/useRotate.js";import{useBoxes as oe}from"./hooks/useBoxes.js";import{useSingleBox as re}from"./hooks/useSingleBox.js";import{useSphere as ne}from"./hooks/useSphere.js";import{useContext as se,useEffect as c}from"react";import{EPointCloudName as ie,CommonToolUtils as ae,AttributeUtils as ue,EToolName as P,cTool as le}from"@labelbee/lb-annotation";import{message as S}from"antd";import{connect as de}from"react-redux";import{a2MapStateToProps as ce}from"../../store/annotation/map.js";import{useStatus as pe}from"./hooks/useStatus.js";import{usePointCloudViews as me}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as ve,useDispatch as be}from"../../store/ctx.js";import{useHistory as Pe}from"./hooks/useHistory.js";import{useAttribute as fe}from"./hooks/useAttribute.js";import{useConfig as ye}from"./hooks/useConfig.js";import{usePolygon as we}from"./hooks/usePolygon.js";import{useLine as Ce}from"./hooks/useLine.js";import{useTranslation as he}from"react-i18next";import{PreDataProcess as ge}from"../../store/annotation/actionCreators.js";var Se=Object.defineProperty,xe=Object.defineProperties,ke=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,I=(l,r,u)=>r in l?Se(l,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[r]=u,f=(l,r)=>{for(var u in r||(r={}))_e.call(r,u)&&I(l,u,r[u]);if(D)for(var u of D(r))Ve.call(r,u)&&I(l,u,r[u]);return l},y=(l,r)=>xe(l,ke(r));const{EPolygonPattern:Le}=le,Be=({currentData:l,config:r,checkMode:u,configString:E,imgIndex:x,toolInstanceRef:i})=>{const t=se(ee),{changeSelectedBoxValid:T,selectNextBox:N,selectPrevBox:H,updateSelectedBox:k,deleteSelectedPointCloudBoxAndPolygon:K}=re(),{selectedSphere:w,updatePointCloudSphere:U}=ne(),{clearAllResult:C,updatePointCloudPattern:z}=pe(),{copySelectedBoxes:F,pasteSelectedBoxes:q,copiedBoxes:G}=oe({config:r}),{updateRotate:h}=te({currentData:l}),{updatePointCloudData:v,topViewSelectedChanged:_}=me(),{redo:V,undo:L,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:R,pushHistoryUnderUpdateLine:W}=Pe(),Y=be(),{syncThreeViewsAttribute:B}=fe(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=ye(),{selectedPolygon:O}=we(),{selectedLine:j}=Ce(),{t:g}=he(),b=e=>{var o;const{topViewInstance:n}=t;!n||(o=n.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(e)},Q=(e,o)=>{var n,a;const{topViewInstance:d,mainViewInstance:s}=t;if(!d)return;const{pointCloud2dOperation:p}=d;switch(e){case"q":{h(2);break}case"e":h(-2);break;case"g":h(180);break;case"u":{const m=p.pattern===Le.Normal?P.Rect:P.Polygon;z(m);const Z={[P.Polygon]:g("PolygonPattern"),[P.Rect]:g("RectPattern")};S.success(g("ChangePatternMsg",{pattern:Z[m]})),p.clearActiveStatus(),p.clearDrawingStatus()}break;case"+":s==null||s.updatePointSize({zoomIn:!0});break;case"-":s==null||s.updatePointSize({zoomIn:!1});break;case"v":t.setPointCloudValid(!t.valid);break;case"tab":if(o.shiftKey){H();break}N(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":K();break;default:{if(((n=r.attributeList)==null?void 0:n.length)>0){const m=ue.getAttributeByKeycode(o.keyCode,r.attributeList);m!==void 0&&((a=i.current)==null||a.setDefaultAttribute(m))}return}}},X=(e,o)=>{switch(e){case"c":F();break;case"v":q();break;case"a":o.preventDefault(),t.selectedAllBoxes();break;case"z":{o.shiftKey?V():L();break}}},A=e=>{if(!ae.hotkeyFilter(e)||u===!0)return;const o=e.key.toLocaleLowerCase();if(e.ctrlKey){X(o,e);return}Q(o,e)};return c(()=>{const{topViewInstance:e}=t;if(!!e)return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}},[t,G,r,t.pointCloudBoxList,t.polygonList]),c(()=>{$(r)},[E]),c(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{v==null||v()},[x,t.mainViewInstance]),c(()=>{t.setHideAttributes([])},[x]),c(()=>{i.current.setDefaultAttribute=e=>{var o,n,a,d;B(e);const s=t.selectedPointCloudBox;if(s){s.attribute=e;const p=Y(ge({tool:ie.PointCloud,dataList:[s],stepConfig:r,action:"viewUpdateBox"}));s.valid=p[0].valid;const m=k(s);(a=(n=(o=t==null?void 0:t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:n.setPolygonValidAndRender)==null||a.call(n,s.id,!0,s.valid),t.mainViewInstance&&_({newSelectedBox:s,newPointCloudList:m})}if(O&&R(y(f({},O),{attribute:e})),j&&W(y(f({},j),{attribute:e})),w){const p=U(y(f({},w),{attribute:e}));t.mainViewInstance&&((d=t.mainViewInstance)==null||d.generateSpheres(p),_({newSelectedSphere:w,newSphereList:p}))}},i.current.setSubAttribute=(e,o)=>{var n;const a=t.selectedPointCloudBox;if(a){const d=(n=a==null?void 0:a.subAttribute)!=null?n:{};a.subAttribute=y(f({},d),{[e]:o}),k(a)}},i.current.clearResult=()=>{C==null||C()},i.current.redo=()=>{V()},i.current.undo=()=>{L()},i.current.setValid=e=>{i.current.valid=e,setTimeout(()=>{t.setPointCloudValid(e),e===!1&&C()})},i.current.setForbidOperation=e=>{var o,n;(n=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||n.setForbidOperation(e),e===!0&&t.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=e=>{var o,n;(n=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||n.setShowDefaultCursor(e)},i.current.asyncData=e=>{setTimeout(()=>{v==null||v(e)})}},[t.pointCloudBoxList,t.pointCloudSphereList,t.selectedID,t.valid,t.polygonList,t.lineList,t.mainViewInstance,t.ptSegmentInstance]),c(()=>{i.current.updateSegmentTool=e=>{var o;(o=t.ptSegmentInstance)==null||o.emit(e)},i.current.segmentInstance=t.ptSegmentInstance},[t.ptSegmentInstance]),c(()=>{i.current.history={pushHistory:e=>{M({pointCloudBoxList:e})},initRecord:()=>{}}},[]),c(()=>{var e;const o=(e=t.topViewInstance)==null?void 0:e.toolInstance;if(!o||u)return;const n=s=>{B(s)},a=s=>{S.error(s)},d=s=>{S.info(s)};return o.on("syncAttribute",n),o.on("messageError",a),o.on("messageInfo",d),()=>{o.unbind("syncAttribute",n),o.unbind("messageError",a),o.unbind("messageInfo",d)}},[t.topViewInstance]),null};var Oe=de(ce,null,null,{context:ve})(Be);export{Oe as default};
1
+ import{PointCloudContext as oe}from"./PointCloudContext.js";import{useRotate as re}from"./hooks/useRotate.js";import{useRotateEdge as se}from"./hooks/useRotateEdge.js";import{useBoxes as ne}from"./hooks/useBoxes.js";import{useSingleBox as ie}from"./hooks/useSingleBox.js";import{useSphere as ae}from"./hooks/useSphere.js";import{useContext as ue,useEffect as c}from"react";import{EPointCloudName as le,CommonToolUtils as de,AttributeUtils as ce,EToolName as P,cTool as pe}from"@labelbee/lb-annotation";import{message as g}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as ve}from"../../store/annotation/map.js";import{useStatus as be}from"./hooks/useStatus.js";import{usePointCloudViews as Pe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as fe,useDispatch as ye}from"../../store/ctx.js";import{useHistory as we}from"./hooks/useHistory.js";import{useAttribute as Ce}from"./hooks/useAttribute.js";import{useConfig as he}from"./hooks/useConfig.js";import{usePolygon as ge}from"./hooks/usePolygon.js";import{useLine as Se}from"./hooks/useLine.js";import{useTranslation as ke}from"react-i18next";import{PreDataProcess as xe}from"../../store/annotation/actionCreators.js";import{useLatest as _e}from"ahooks";var Le=Object.defineProperty,Ve=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,I=(u,r,l)=>r in u?Le(u,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[r]=l,f=(u,r)=>{for(var l in r||(r={}))Oe.call(r,l)&&I(u,l,r[l]);if(E)for(var l of E(r))je.call(r,l)&&I(u,l,r[l]);return u},y=(u,r)=>Ve(u,Be(r));const{EPolygonPattern:Ae}=pe,Ee=({currentData:u,config:r,checkMode:l,configString:D,imgIndex:S,toolInstanceRef:i})=>{const t=ue(oe),{changeSelectedBoxValid:T,selectNextBox:N,selectPrevBox:H,updateSelectedBox:k,deleteSelectedPointCloudBoxAndPolygon:K}=ie(),{selectedSphere:w,updatePointCloudSphere:R}=ae(),{clearAllResult:C,updatePointCloudPattern:U}=be(),{copySelectedBoxes:z,pasteSelectedBoxes:F,copiedBoxes:q}=ne({config:r}),{updateRotate:x}=re({currentData:u}),{updateRotateEdge:G}=se({currentData:u}),{updatePointCloudData:v,topViewSelectedChanged:_}=Pe(),{redo:L,undo:V,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:W,pushHistoryUnderUpdateLine:Y}=we(),$=ye(),{syncThreeViewsAttribute:B}=Ce(),{syncAllViewsConfig:J,reRenderTopViewRange:Q}=he(),{selectedPolygon:O}=ge(),{selectedLine:j}=Se(),{t:h}=ke(),X=_e(u),b=e=>{var o;const{topViewInstance:s}=t;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(e)},Z=(e,o)=>{var s,a;const{topViewInstance:d,mainViewInstance:n}=t;if(!d)return;const{pointCloud2dOperation:p}=d;switch(e){case"q":{x(t.rectRotateSensitivity);break}case"e":x(-Number(t.rectRotateSensitivity));break;case"g":G(-90);break;case"u":{const m=p.pattern===Ae.Normal?P.Rect:P.Polygon;U(m);const te={[P.Polygon]:h("PolygonPattern"),[P.Rect]:h("RectPattern")};g.success(h("ChangePatternMsg",{pattern:te[m]})),p.clearActiveStatus(),p.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":t.setPointCloudValid(!t.valid);break;case"tab":if(o.shiftKey){H();break}N(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":K(X.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const m=ce.getAttributeByKeycode(o.keyCode,r.attributeList);m!==void 0&&((a=i.current)==null||a.setDefaultAttribute(m))}return}}},ee=(e,o)=>{switch(e){case"c":z();break;case"v":F();break;case"a":o.preventDefault(),t.selectedAllBoxes();break;case"z":{o.shiftKey?L():V();break}}},A=e=>{if(!de.hotkeyFilter(e)||l===!0)return;const o=e.key.toLocaleLowerCase();if(e.ctrlKey){ee(o,e);return}Z(o,e)};return c(()=>{const{topViewInstance:e}=t;if(!!e)return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}},[t,q,r,t.pointCloudBoxList,t.polygonList]),c(()=>{J(r)},[D]),c(()=>{(r==null?void 0:r.radius)&&Q(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{v==null||v()},[S,t.mainViewInstance]),c(()=>{t.setHideAttributes([])},[S]),c(()=>{i.current.setDefaultAttribute=e=>{var o,s,a,d;B(e);const n=t.selectedPointCloudBox;if(n){n.attribute=e;const p=$(xe({tool:le.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=p[0].valid;const m=k(n);(a=(s=(o=t==null?void 0:t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||a.call(s,n.id,!0,n.valid),t.mainViewInstance&&_({newSelectedBox:n,newPointCloudList:m})}if(O&&W(y(f({},O),{attribute:e})),j&&Y(y(f({},j),{attribute:e})),w){const p=R(y(f({},w),{attribute:e}));t.mainViewInstance&&((d=t.mainViewInstance)==null||d.generateSpheres(p),_({newSelectedSphere:w,newSphereList:p}))}},i.current.setSubAttribute=(e,o)=>{var s;const a=t.selectedPointCloudBox;if(a){const d=(s=a==null?void 0:a.subAttribute)!=null?s:{};a.subAttribute=y(f({},d),{[e]:o}),k(a)}},i.current.clearResult=()=>{C==null||C()},i.current.redo=()=>{L()},i.current.undo=()=>{V()},i.current.setValid=e=>{i.current.valid=e,setTimeout(()=>{t.setPointCloudValid(e),e===!1&&C()})},i.current.setForbidOperation=e=>{var o,s;(s=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(e),e===!0&&t.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=e=>{var o,s;(s=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(e)},i.current.asyncData=e=>{setTimeout(()=>{v==null||v(e)})}},[t.pointCloudBoxList,t.pointCloudSphereList,t.selectedID,t.valid,t.polygonList,t.lineList,t.mainViewInstance,t.ptSegmentInstance]),c(()=>{i.current.updateSegmentTool=e=>{var o;(o=t.ptSegmentInstance)==null||o.emit(e)},i.current.segmentInstance=t.ptSegmentInstance},[t.ptSegmentInstance]),c(()=>{i.current.history={pushHistory:e=>{M({pointCloudBoxList:e})},initRecord:()=>{}}},[]),c(()=>{var e;const o=(e=t.topViewInstance)==null?void 0:e.toolInstance;if(!o||l)return;const s=n=>{B(n)},a=n=>{g.error(n)},d=n=>{g.info(n)};return o.on("syncAttribute",s),o.on("messageError",a),o.on("messageInfo",d),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",a),o.unbind("messageInfo",d)}},[t.topViewInstance]),null};var Ie=me(ve,null,null,{context:fe})(Ee);export{Ie as default};
@@ -1 +1 @@
1
- import{a2MapStateToProps as L}from"../../store/annotation/map.js";import{LabelBeeContext as z}from"../../store/ctx.js";import d,{useContext as R,useRef as f,useState as w,useEffect as g,useCallback as V,useMemo as B}from"react";import A from"../AnnotationView/index.js";import{connect as W}from"react-redux";import{PointCloudContext as T}from"./PointCloudContext.js";import G from"./components/TitleButton/index.js";import{Spin as H}from"antd";import N from"../../_virtual/highlightSegmentWorker.js";import{pointMappingLidar2image as Y}from"@labelbee/lb-annotation";import{debounce as $}from"lodash";var q=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,D=(t,o,n)=>o in t?q(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,X=(t,o)=>{for(var n in o||(o={}))Q.call(o,n)&&D(t,n,o[n]);if(x)for(var n of x(o))U.call(o,n)&&D(t,n,o[n]);return t},Z=(t,o)=>J(t,K(o));const ee=({path:t,url:o,calib:n,pcdUrl:c,highlightAttribute:a})=>{const{ptSegmentInstance:e,cacheImageNodeSize:O,imageSizes:E}=R(T),F=f(null),m=f(0),v=f({}),u=f(),[h,P]=w([]),[I,C]=w(!1),b=f(void 0);g(()=>()=>{m.current=0,v.current={},u.current=void 0},[c]);const _=V(()=>{var r,l,i;if(m.current=m.current+1,m.current===2){const s=(r=e==null?void 0:e.store)==null?void 0:r.originPoints;if(!s||!u.current){console.error("cacheMappingPCD2Img Error",{path:t,points:s,filterSize:u.current});return}v.current=(i=(l=Y(s,n,u.current))==null?void 0:l.pcdMapping)!=null?i:{}}},[e]),S=B(()=>$((l,i)=>{var s,y;if(l&&u.current){b.current&&((y=(s=b.current)==null?void 0:s.terminate)==null||y.call(s));const k=v.current,p=new N;p.current=p,C(!0),p.postMessage({cacheMap:k,indexes:l,defaultRGBA:i}),p.onmessage=M=>{P(M.data.annotations),p.terminate(),C(!1),p.current=void 0}}},100),[]);g(()=>{if(!(e==null?void 0:e.store))return;const r=e.store.getHighlightAttribute(a!=null?a:""),l=e==null?void 0:e.getColorFromConfig(a!=null?a:"");S(r.flat(),l.stroke)},[a,e]),g(()=>{if(e){const r=({newAttribute:l})=>{const i=e==null?void 0:e.getColorFromConfig(l);i&&P(h.map(s=>Z(X({},s),{defaultRGBA:i.stroke})))};return e.on("updateDefaultAttribute",r),()=>{e.unbind("updateDefaultAttribute",r)}}},[e,h]),g(()=>{if(e){const r=l=>{if(l.cacheSegData){const{cacheSegData:i}=l;if(i==null?void 0:i.indexes){const s=e.getColorFromConfig(i.attribute);S(i==null?void 0:i.indexes,s.stroke)}}else P([])};return e.on("syncPointCloudStatus",r),e.on("loadPCDFileEnd",_),()=>{e.unbind("syncPointCloudStatus",r),e.unbind("loadPCDFileEnd",_)}}},[e,c,E]);const j=r=>{O({path:t,imgNode:r}),u.current={width:r.width,height:r.height},_()};return d.createElement("div",{key:t,style:{position:"relative"},ref:F},d.createElement(G,{title:n.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF",position:"absolute",top:10,left:10,zIndex:1}}),d.createElement(H,{spinning:I,delay:1e3},d.createElement(A,{size:{width:300,height:200},key:t,src:o,annotations:h,afterImgOnLoad:j})))},te=({currentData:t,highlightAttribute:o})=>{var n;const c=(n=t.mappingImgList)!=null?n:[];return(c==null?void 0:c.length)>0?d.createElement("div",{style:{position:"absolute",height:"100%",overflowY:"scroll",zIndex:100,width:300}},c==null?void 0:c.map((a,e)=>a.calib&&d.createElement(ee,{key:a.path+e,path:a.path,url:a.url,calib:a.calib,pcdUrl:t.url,highlightAttribute:o}))):null};var oe=W(L,null,null,{context:z})(te);export{oe as default};
1
+ import{a2MapStateToProps as z}from"../../store/annotation/map.js";import{LabelBeeContext as R}from"../../store/ctx.js";import f,{useContext as V,useRef as m,useState as x,useEffect as v,useCallback as B,useMemo as A}from"react";import W from"../AnnotationView/index.js";import{connect as T}from"react-redux";import{PointCloudContext as U}from"./PointCloudContext.js";import G from"./components/TitleButton/index.js";import{Spin as H}from"antd";import N from"../../_virtual/highlightSegmentWorker.js";import{pointMappingLidar2image as Y}from"@labelbee/lb-annotation";import{debounce as $}from"lodash";var q=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,k=(t,o,n)=>o in t?q(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,Z=(t,o)=>{for(var n in o||(o={}))Q.call(o,n)&&k(t,n,o[n]);if(D)for(var n of D(o))X.call(o,n)&&k(t,n,o[n]);return t},ee=(t,o)=>J(t,K(o));const te=({path:t,url:o,fallbackUrl:n,calib:c,pcdUrl:s,highlightAttribute:u})=>{const{ptSegmentInstance:e,cacheImageNodeSize:O,imageSizes:E}=V(U),F=m(null),g=m(0),h=m({}),p=m(),[P,_]=x([]),[I,C]=x(!1),S=m(void 0);v(()=>()=>{g.current=0,h.current={},p.current=void 0},[s]);const b=B(()=>{var r,l,i;if(g.current=g.current+1,g.current===2){const a=(r=e==null?void 0:e.store)==null?void 0:r.originPoints;if(!a||!p.current){console.error("cacheMappingPCD2Img Error",{path:t,points:a,filterSize:p.current});return}h.current=(i=(l=Y(a,c,p.current))==null?void 0:l.pcdMapping)!=null?i:{}}},[e]),y=A(()=>$((l,i)=>{var a,w;if(l&&p.current){S.current&&((w=(a=S.current)==null?void 0:a.terminate)==null||w.call(a));const M=h.current,d=new N;d.current=d,C(!0),d.postMessage({cacheMap:M,indexes:l,defaultRGBA:i}),d.onmessage=L=>{_(L.data.annotations),d.terminate(),C(!1),d.current=void 0}}},100),[]);v(()=>{if(!(e==null?void 0:e.store))return;const r=e.store.getHighlightAttribute(u!=null?u:""),l=e==null?void 0:e.getColorFromConfig(u!=null?u:"");y(r.flat(),l.stroke)},[u,e]),v(()=>{if(e){const r=({newAttribute:l})=>{const i=e==null?void 0:e.getColorFromConfig(l);i&&_(P.map(a=>ee(Z({},a),{defaultRGBA:i.stroke})))};return e.on("updateDefaultAttribute",r),()=>{e.unbind("updateDefaultAttribute",r)}}},[e,P]),v(()=>{if(e){const r=l=>{if(l.cacheSegData){const{cacheSegData:i}=l;if(i==null?void 0:i.indexes){const a=e.getColorFromConfig(i.attribute);y(i==null?void 0:i.indexes,a.stroke)}}else _([])};return e.on("syncPointCloudStatus",r),e.on("loadPCDFileEnd",b),()=>{e.unbind("syncPointCloudStatus",r),e.unbind("loadPCDFileEnd",b)}}},[e,s,E]);const j=r=>{O({path:t,imgNode:r}),p.current={width:r.width,height:r.height},b()};return f.createElement("div",{key:t,style:{position:"relative"},ref:F},f.createElement(G,{title:c.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF",position:"absolute",top:10,left:10,zIndex:1}}),f.createElement(H,{spinning:I,delay:1e3},f.createElement(W,{size:{width:300,height:200},key:t,src:o,fallbackSrc:n,annotations:P,afterImgOnLoad:j})))},oe=({currentData:t,highlightAttribute:o})=>{var n;const c=(n=t.mappingImgList)!=null?n:[];return(c==null?void 0:c.length)>0?f.createElement("div",{style:{position:"absolute",height:"100%",overflowY:"scroll",zIndex:100,width:300}},c==null?void 0:c.map((s,u)=>{var e;return s.calib&&f.createElement(te,{key:s.path+u,path:s.path,url:s.url,fallbackUrl:(e=s.fallbackUrl)!=null?e:"",calib:s.calib,pcdUrl:t.url,highlightAttribute:o})})):null};var ne=T(z,null,null,{context:R})(oe);export{ne as default};
@@ -1 +1 @@
1
- import{getClassName as x}from"../../utils/dom.js";import{FooterDivider as z}from"../../views/MainView/toolFooter/index.js";import{ZoomController as ae}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as ce,UpSquareOutlined as de,DownSquareOutlined as pe}from"@ant-design/icons";import{cKeyCode as ue,PointCloudAnnotation as me,cTool as fe,cAnnotation as ve}from"@labelbee/lb-annotation";import{PointCloudUtils as H}from"@labelbee/lb-utils";import i,{useState as W,useRef as we,useLayoutEffect as Ce,useEffect as h}from"react";import{PointCloudContext as F}from"./PointCloudContext.js";import{useRotate as Pe}from"./hooks/useRotate.js";import{useSingleBox as K}from"./hooks/useSingleBox.js";import{PointCloudContainer as ge}from"./PointCloudLayout.js";import{BoxInfos as X,PointCloudValidity as ye}from"./PointCloudInfos.js";import{usePolygon as Ie}from"./hooks/usePolygon.js";import{useSphere as Y}from"./hooks/useSphere.js";import{useZoom as q}from"./hooks/useZoom.js";import{Slider as xe}from"antd";import{a2MapStateToProps as he}from"../../store/annotation/map.js";import{connect as Ve}from"react-redux";import{usePointCloudViews as _e}from"./hooks/usePointCloudViews.js";import Se from"../../hooks/useSize.js";import{useTranslation as Ee}from"react-i18next";import{LabelBeeContext as Le}from"../../store/ctx.js";import{jsonParser as Oe}from"../../utils/index.js";import be from"../../utils/ToolUtils.js";import je from"lodash";import Te from"./components/PointCloudSizeSlider/index.js";import{useHistory as ke}from"./hooks/useHistory.js";import Ae from"./components/TitleButton/index.js";var De=Object.defineProperty,Ne=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,$=(n,s,r)=>s in n?De(n,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[s]=r,B=(n,s)=>{for(var r in s||(s={}))Re.call(s,r)&&$(n,r,s[r]);if(M)for(var r of M(s))Ue.call(s,r)&&$(n,r,s[r]);return n},R=(n,s)=>Ne(n,Be(s));const{EPolygonPattern:Ze,EToolName:G}=fe,{ESortDirection:J}=ve,ze=ue.default,Q=(n,s,r=1)=>{const{width:w,height:u}=s,P={x:n.x+w*r/2,y:n.y+u*r/2},g={x:s.width/2,y:s.height/2};return{offsetX:(g.x-P.x)/r,offsetY:-(g.y-P.y)/r}},He=({currentData:n})=>{var s,r;const{zoom:w,zoomIn:u,zoomOut:P,initialPosition:g}=q(),{selectNextBox:E,selectPrevBox:L}=K(),{switchToNextSphere:V}=Y(),{updateRotate:y}=Pe({currentData:n}),I=i.useContext(F),{topViewInstance:O}=I,_=(r=(s=I==null?void 0:I.topViewInstance)==null?void 0:s.toolScheduler)==null?void 0:r.getCurrentToolName(),m=2,e=()=>{y(-m)},c=()=>{y(m)},f=()=>{y(180)};return i.createElement(i.Fragment,null,i.createElement(Te,{onChange:b=>{var S;(S=O==null?void 0:O.pointCloudInstance)==null||S.updatePointSize({customSize:b})}}),i.createElement("span",{onClick:c,className:x("point-cloud","rotate-reserve")}),i.createElement("span",{onClick:e,className:x("point-cloud","rotate")}),i.createElement("span",{onClick:f,className:x("point-cloud","rotate-180")}),i.createElement(z,null),i.createElement(de,{onClick:()=>{if(_===G.Point){V(J.descend);return}L(!0)},className:x("point-cloud","prev")}),i.createElement(pe,{onClick:()=>{if(_===G.Point){V(J.ascend);return}E(!0)},className:x("point-cloud","next")}),i.createElement(z,null),i.createElement(ae,{initialPosition:g,zoomIn:u,zoomOut:P,zoom:w}))},We=({setZAxisLimit:n,zAxisLimit:s,checkMode:r})=>r?null:i.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},i.createElement(xe,{vertical:!0,step:.5,max:10,min:.5,defaultValue:s,onAfterChange:w=>{n(w)}})),Fe=({currentData:n,imgList:s,stepInfo:r,drawLayerSlot:w,checkMode:u,intelligentFit:P,setIsEnlargeTopView:g,isEnlargeTopView:E,onExitZoom:L,highlightAttribute:V})=>{var y,I;const[O,_]=W({zoom:1,currentPos:{x:0,y:0}}),m=we(null),e=i.useContext(F),c=Se(m),f=Oe(r.config),{setZoom:b,syncTopviewToolZoom:S}=q(),{hideAttributes:ee}=e,{addPolygon:te,deletePolygon:oe}=Ie(),{deletePointCloudSphere:ne}=Y(),{deletePointCloudBox:ie,changeValidByID:le}=K(),[j,se]=W(10),{t:U}=Ee(),C=_e(),{pushHistoryWithList:re}=ke();Ce(()=>{if(!e.topViewInstance&&m.current&&(n==null?void 0:n.url)&&(n==null?void 0:n.result)){const o={width:m.current.clientWidth,height:m.current.clientHeight},a=new me({container:m.current,size:o,pcdPath:n.url,config:R(B({},f),{pointCloudPattern:e.pointCloudPattern}),checkMode:u,toolName:be.getPointCloudToolList(),proxyMode:u});e.setTopViewInstance(a)}},[n]),h(()=>{if(!c||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:o}=e.topViewInstance;o.singleOn("dataUpdated",(t,l)=>{const p=je.cloneDeep(t).map(d=>R(B({},d),{pointList:H.pointListTransferCanvas2World(d.pointList,c)}));e.setSelectedIDs(l),e.setLineList(p),re({lineList:p})}),o.singleOn("pointCreated",(t,l)=>{C.topViewAddSphere({newPoint:t,size:c,trackConfigurable:f.trackConfigurable,zoom:l})}),o.singleOn("pointDeleted",t=>{ne(t)}),o.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),o.singleOn("updatePointByDrag",(t,l)=>{var p;(p=C.topViewUpdatePoint)==null||p.call(C,t,c)}),o.singleOn("polygonCreated",(t,l)=>{if(o.pattern===Ze.Normal||!(n==null?void 0:n.url)){const p=R(B({},t),{pointList:t.pointList.map(d=>H.transferCanvas2World(d,c))});te(p),e.setSelectedIDs(ee.includes(t.attribute)?"":t.id);return}C.topViewAddBox({polygon:t,size:c,imgList:s,trackConfigurable:f.trackConfigurable,zoom:l,intelligentFit:P})}),o.singleOn("deletedObject",({id:t})=>{ie(t),oe(t)}),o.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),o.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),o.singleOn("setSelectedIDs",t=>{e.setSelectedIDs(t)}),o.singleOn("updatePolygonByDrag",t=>{var l;(l=C.topViewUpdateBox)==null||l.call(C,t,c)});const a=t=>{var l;const p=le(t);p&&e.syncAllViewPointCloudColor(p),e.polygonList.find(d=>d.id===t)&&((l=e.topViewInstance)==null||l.toolInstance.setPolygonValidAndRender(t,!0))};return o.on("validUpdate",a),()=>{o.unbind("validUpdate",a)}},[e,c,n,C,e.polygonList,e.lineList,(y=e.topViewInstance)==null?void 0:y.toolInstance]),h(()=>{var o,a;if(!(c==null?void 0:c.width)||!e.topViewInstance)return;const t=(a=(o=f==null?void 0:f.attributeList)==null?void 0:o[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(c),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:l,toolInstance:p}}=e;p.singleOn("renderZoom",(d,v)=>{const{offsetX:T,offsetY:k}=Q(v,c,d);if(l.camera.zoom=d,v){const{x:A,y:D,z:N}=l.initCameraPosition;l.camera.position.set(A+k,D-T,N)}l.camera.updateProjectionMatrix(),l.render(),b(d),S(v,d,c),_({zoom:d,currentPos:v})}),p.singleOn("dragMove",({currentPos:d,zoom:v})=>{const{offsetX:T,offsetY:k}=Q(d,c,v);l.camera.zoom=v;const{x:A,y:D,z:N}=l.initCameraPosition;l.camera.position.set(A+k,D-T,N),l.render(),S(d,v,c),_({zoom:v,currentPos:d})})},[c,e.topViewInstance,(I=e.topViewInstance)==null?void 0:I.toolInstance]),h(()=>{var o,a;(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null||a.applyZAxisPoints(j)},[j]),h(()=>{var o,a,t,l;C.topViewSelectedChanged({}),(l=(t=(a=(o=e.topViewInstance)==null?void 0:o.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||l.call(t,e.selectedIDs)},[e.selectedIDs]),h(()=>(window.addEventListener("keydown",Z),()=>{window.removeEventListener("keydown",Z)}),[]);const Z=o=>{const{keyCode:a}=o;a===ze.Esc&&L()};return h(()=>{var o,a,t;(t=(a=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,V)},[e.topViewInstance,V]),i.createElement(ge,{className:x("point-cloud-container","top-view"),title:E?i.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},i.createElement(ce,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{L()}}),i.createElement("span",null,U("TopView")),i.createElement(X,{checkMode:u,config:f,style:{display:"flex",position:"initial",margin:"0px 20px"}})):i.createElement(Ae,{title:U("TopView"),onClick:()=>{g(!0)}}),toolbar:i.createElement(He,{currentData:n})},i.createElement("div",{style:{position:"relative",flex:1}},i.createElement("div",{style:{width:"100%",height:"100%"},ref:m},w==null?void 0:w(O)),!E&&i.createElement(X,{checkMode:u,config:f}),i.createElement(We,{checkMode:u,zAxisLimit:j,setZAxisLimit:se}),i.createElement(ye,null)))};var Ke=Ve(he,null,null,{context:Le})(Fe);export{Ke as default};
1
+ import{getClassName as I}from"../../utils/dom.js";import{FooterDivider as z}from"../../views/MainView/toolFooter/index.js";import{ZoomController as ae}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as ce,UpSquareOutlined as de,DownSquareOutlined as pe}from"@ant-design/icons";import{cKeyCode as ue,PointCloudAnnotation as me,cTool as fe,cAnnotation as ve}from"@labelbee/lb-annotation";import{PointCloudUtils as H}from"@labelbee/lb-utils";import i,{useState as W,useRef as we,useLayoutEffect as Ce,useEffect as x}from"react";import{PointCloudContext as F}from"./PointCloudContext.js";import{useRotate as ge}from"./hooks/useRotate.js";import{useRotateEdge as Pe}from"./hooks/useRotateEdge.js";import{useSingleBox as K}from"./hooks/useSingleBox.js";import{PointCloudContainer as ye}from"./PointCloudLayout.js";import{BoxInfos as X,PointCloudValidity as Ie}from"./PointCloudInfos.js";import{usePolygon as xe}from"./hooks/usePolygon.js";import{useSphere as Y}from"./hooks/useSphere.js";import{useZoom as q}from"./hooks/useZoom.js";import{Slider as he}from"antd";import{a2MapStateToProps as Ve}from"../../store/annotation/map.js";import{connect as Se}from"react-redux";import{usePointCloudViews as _e}from"./hooks/usePointCloudViews.js";import Ee from"../../hooks/useSize.js";import{useTranslation as Le}from"react-i18next";import{LabelBeeContext as Oe}from"../../store/ctx.js";import{jsonParser as be}from"../../utils/index.js";import je from"../../utils/ToolUtils.js";import Te from"lodash";import ke from"./components/PointCloudSizeSlider/index.js";import{useHistory as Ae}from"./hooks/useHistory.js";import Ne from"./components/TitleButton/index.js";var Re=Object.defineProperty,Be=Object.defineProperties,De=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable,$=(n,l,r)=>l in n?Re(n,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[l]=r,B=(n,l)=>{for(var r in l||(l={}))Ue.call(l,r)&&$(n,r,l[r]);if(M)for(var r of M(l))Ze.call(l,r)&&$(n,r,l[r]);return n},D=(n,l)=>Be(n,De(l));const{EPolygonPattern:ze,EToolName:G}=fe,{ESortDirection:J}=ve,He=ue.default,Q=(n,l,r=1)=>{const{width:w,height:u}=l,P={x:n.x+w*r/2,y:n.y+u*r/2},y={x:l.width/2,y:l.height/2};return{offsetX:(y.x-P.x)/r,offsetY:-(y.y-P.y)/r}},We=({currentData:n})=>{var l,r;const{zoom:w,zoomIn:u,zoomOut:P,initialPosition:y}=q(),{selectNextBox:E,selectPrevBox:L}=K(),{switchToNextSphere:h}=Y(),{updateRotate:V}=ge({currentData:n}),{updateRotateEdge:O}=Pe({currentData:n}),g=i.useContext(F),{topViewInstance:S}=g,m=(r=(l=g==null?void 0:g.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:r.getCurrentToolName(),e=()=>{V(-Number(g.rectRotateSensitivity))},c=()=>{V(g.rectRotateSensitivity)},f=()=>{O(-90)};return i.createElement(i.Fragment,null,i.createElement(ke,{onChange:b=>{var _;(_=S==null?void 0:S.pointCloudInstance)==null||_.updatePointSize({customSize:b})}}),i.createElement("span",{onClick:c,className:I("point-cloud","rotate-reserve")}),i.createElement("span",{onClick:e,className:I("point-cloud","rotate")}),i.createElement("span",{onClick:f,className:I("point-cloud","rotate-90")}),i.createElement(z,null),i.createElement(de,{onClick:()=>{if(m===G.Point){h(J.descend);return}L(!0)},className:I("point-cloud","prev")}),i.createElement(pe,{onClick:()=>{if(m===G.Point){h(J.ascend);return}E(!0)},className:I("point-cloud","next")}),i.createElement(z,null),i.createElement(ae,{initialPosition:y,zoomIn:u,zoomOut:P,zoom:w}))},Fe=({setZAxisLimit:n,zAxisLimit:l,checkMode:r})=>r?null:i.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},i.createElement(he,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:w=>{n(w)}})),Ke=({currentData:n,imgList:l,stepInfo:r,drawLayerSlot:w,checkMode:u,intelligentFit:P,setIsEnlargeTopView:y,isEnlargeTopView:E,onExitZoom:L,highlightAttribute:h})=>{var V,O;const[g,S]=W({zoom:1,currentPos:{x:0,y:0}}),m=we(null),e=i.useContext(F),c=Ee(m),f=be(r.config),{setZoom:b,syncTopviewToolZoom:_}=q(),{hideAttributes:ee}=e,{addPolygon:te,deletePolygon:oe}=xe(),{deletePointCloudSphere:ne}=Y(),{deletePointCloudBox:ie,changeValidByID:se}=K(),[j,le]=W(10),{t:U}=Le(),C=_e(),{pushHistoryWithList:re}=Ae();Ce(()=>{if(!e.topViewInstance&&m.current&&(n==null?void 0:n.url)&&(n==null?void 0:n.result)){const o={width:m.current.clientWidth,height:m.current.clientHeight},a=new me({container:m.current,size:o,pcdPath:n.url,config:D(B({},f),{pointCloudPattern:e.pointCloudPattern}),checkMode:u,toolName:je.getPointCloudToolList(),proxyMode:u});e.setTopViewInstance(a)}},[n]),x(()=>{if(!c||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:o}=e.topViewInstance;o.singleOn("dataUpdated",(t,s)=>{const p=Te.cloneDeep(t).map(d=>D(B({},d),{pointList:H.pointListTransferCanvas2World(d.pointList,c)}));e.setSelectedIDs(s),e.setLineList(p),re({lineList:p})}),o.singleOn("pointCreated",(t,s)=>{C.topViewAddSphere({newPoint:t,size:c,trackConfigurable:f.trackConfigurable,zoom:s})}),o.singleOn("pointDeleted",t=>{ne(t)}),o.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),o.singleOn("updatePointByDrag",(t,s)=>{var p;(p=C.topViewUpdatePoint)==null||p.call(C,t,c)}),o.singleOn("polygonCreated",(t,s)=>{if(o.pattern===ze.Normal||!(n==null?void 0:n.url)){const p=D(B({},t),{pointList:t.pointList.map(d=>H.transferCanvas2World(d,c))});te(p),e.setSelectedIDs(ee.includes(t.attribute)?"":t.id);return}C.topViewAddBox({polygon:t,size:c,imgList:l,trackConfigurable:f.trackConfigurable,zoom:s,intelligentFit:P})}),o.singleOn("deletedObject",({id:t})=>{ie(t),oe(t)}),o.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),o.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),o.singleOn("setSelectedIDs",t=>{e.setSelectedIDs(t)}),o.singleOn("updatePolygonByDrag",t=>{var s;(s=C.topViewUpdateBox)==null||s.call(C,t,c)});const a=t=>{var s;const p=se(t);p&&e.syncAllViewPointCloudColor(p),e.polygonList.find(d=>d.id===t)&&((s=e.topViewInstance)==null||s.toolInstance.setPolygonValidAndRender(t,!0))};return o.on("validUpdate",a),()=>{o.unbind("validUpdate",a)}},[e,c,n,C,e.polygonList,e.lineList,(V=e.topViewInstance)==null?void 0:V.toolInstance]),x(()=>{var o,a;if(!(c==null?void 0:c.width)||!e.topViewInstance)return;const t=(a=(o=f==null?void 0:f.attributeList)==null?void 0:o[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(c),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:s,toolInstance:p}}=e;p.singleOn("renderZoom",(d,v)=>{const{offsetX:T,offsetY:k}=Q(v,c,d);if(s.camera.zoom=d,v){const{x:A,y:N,z:R}=s.initCameraPosition;s.camera.position.set(A+k,N-T,R)}s.camera.updateProjectionMatrix(),s.render(),b(d),_(v,d,c),S({zoom:d,currentPos:v})}),p.singleOn("dragMove",({currentPos:d,zoom:v})=>{const{offsetX:T,offsetY:k}=Q(d,c,v);s.camera.zoom=v;const{x:A,y:N,z:R}=s.initCameraPosition;s.camera.position.set(A+k,N-T,R),s.render(),_(d,v,c),S({zoom:v,currentPos:d})})},[c,e.topViewInstance,(O=e.topViewInstance)==null?void 0:O.toolInstance]),x(()=>{var o,a;(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null||a.applyZAxisPoints(j)},[j]),x(()=>{var o,a,t,s;C.topViewSelectedChanged({}),(s=(t=(a=(o=e.topViewInstance)==null?void 0:o.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||s.call(t,e.selectedIDs)},[e.selectedIDs]),x(()=>(window.addEventListener("keydown",Z),()=>{window.removeEventListener("keydown",Z)}),[]);const Z=o=>{const{keyCode:a}=o;a===He.Esc&&L()};return x(()=>{var o,a,t;(t=(a=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,h)},[e.topViewInstance,h]),i.createElement(ye,{className:I("point-cloud-container","top-view"),title:E?i.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},i.createElement(ce,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{L()}}),i.createElement("span",null,U("TopView")),i.createElement(X,{checkMode:u,config:f,style:{display:"flex",position:"initial",margin:"0px 20px"}})):i.createElement(Ne,{title:U("TopView"),onClick:()=>{y(!0)}}),toolbar:i.createElement(We,{currentData:n})},i.createElement("div",{style:{position:"relative",flex:1}},i.createElement("div",{style:{width:"100%",height:"100%"},ref:m},w==null?void 0:w(g)),!E&&i.createElement(X,{checkMode:u,config:f}),i.createElement(Fe,{checkMode:u,zAxisLimit:j,setZAxisLimit:le}),i.createElement(Ie,null)))};var Xe=Se(Ve,null,null,{context:Oe})(Ke);export{Xe as default};
@@ -0,0 +1 @@
1
+ import u,{useState as V,useContext as j,useMemo as C,useCallback as d,useEffect as N}from"react";import{useLatest as s}from"ahooks";import{PointCloudContext as p}from"../PointCloudContext.js";import z from"../../../assets/annotation/icon_link.svg.js";import L from"../../../assets/annotation/icon_unlink.svg.js";import{EventBusEvent as v}from"../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js";import{EventBus as x}from"@labelbee/lb-annotation";const k={width:16,height:16},F=e=>{e.imageName||console.warn("missing imageName");const[a,B]=V(!0),g=s(e.imageName),{addRectFromPointCloudBoxByImageName:b,removeRectByPointCloudBoxId:y,imageNamePointCloudBoxMap:o,linkageImageNameRectMap:f}=j(p),c=C(()=>e.imageName?o.has(e.imageName):(console.error("Missing image name"),!1),[e.imageName,o]),S=s(c),R=s(b),_=s(y),i=d(n=>{if(!S.current)return;const t=g.current;if(!t){console.warn("invalid image name");return}B(n),n?_.current(t):R.current(t)},[]),E=d(()=>{i(!a)},[i,a]),P=C(()=>{var n;if(!e.is2DView||!c)return null;const r={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};return u.createElement("div",{style:r},a&&u.createElement("img",{src:z,style:k}),!a&&u.createElement("img",{src:L,style:k}))},[a,e.is2DView,e.zIndex,E,c]),m=d(()=>{var n,t,r,h;if(!e.is2DView)return;const l=g.current;if(!l){console.warn("invalid image name");return}const D=new Set([...(t=(n=o.get(l))==null?void 0:n.keys())!=null?t:[]]),w=[...(h=(r=f.get(l))==null?void 0:r.keys())!=null?h:[]];let I=!0;w.length&&(I=Boolean(w.find(M=>D.has(M)))===!1),i(I)},[e.is2DView,f,o,i]);return N(()=>{m()},[m]),N(()=>{const n=t=>{i(t)};return x.on(v.switchConnect,n),()=>x.unbind(v.switchConnect,n)},[i]),{rendered:P,isLinking:a,swapSwitch:i,syncIsLinking:m}};export{F as default};
@@ -1 +1 @@
1
- import{useContext as C,useCallback as I}from"react";import{PointCloudContext as y}from"../PointCloudContext.js";var x=(s,r,t)=>new Promise((a,u)=>{var n=i=>{try{e(t.next(i))}catch(l){u(l)}},h=i=>{try{e(t.throw(i))}catch(l){u(l)}},e=i=>i.done?a(i.value):Promise.resolve(i.value).then(n,h);e((t=t.apply(s,r)).next())});const L=({currentData:s})=>{var r;const{mainViewInstance:t,topViewInstance:a,pointCloudBoxList:u,highlight2DDataList:n,setHighlight2DDataList:h}=C(y),e=(r=s==null?void 0:s.mappingImgList)!=null?r:[],i=(o,d)=>x(void 0,null,function*(){var c;let g=[...n];if(n.find(p=>p.url===o)?g=n.filter(p=>p.url!==o):g.push({url:o,calib:d}),h(g),!t||(e==null?void 0:e.length)===0)return;const m=t.pointCloudObject;if(!m)return;const f=yield t.getHighlightIndexByMappingImgList({mappingImgList:g,points:m.geometry.attributes.position.array}),v=yield t.highlightOriginPointCloud(u,f);v&&((c=a==null?void 0:a.pointCloudInstance)==null||c.updateColor(v))}),l=I(o=>n.findIndex(d=>d.url===o)>=0,[n]);return{toggle2dVisible:i,isHighlightVisible:l}};export{L as useHighlight};
1
+ import{useContext as I,useCallback as y}from"react";import{PointCloudContext as x}from"../PointCloudContext.js";var L=(s,r,t)=>new Promise((a,u)=>{var n=i=>{try{e(t.next(i))}catch(l){u(l)}},h=i=>{try{e(t.throw(i))}catch(l){u(l)}},e=i=>i.done?a(i.value):Promise.resolve(i.value).then(n,h);e((t=t.apply(s,r)).next())});const b=({currentData:s})=>{var r;const{mainViewInstance:t,topViewInstance:a,pointCloudBoxList:u,highlight2DDataList:n,setHighlight2DDataList:h}=I(x),e=(r=s==null?void 0:s.mappingImgList)!=null?r:[],i=(o,d,f)=>L(void 0,null,function*(){var c;let g=[...n];if(n.find(p=>p.url===o)?g=n.filter(p=>p.url!==o):g.push({url:o,fallbackUrl:d,calib:f}),h(g),!t||(e==null?void 0:e.length)===0)return;const m=t.pointCloudObject;if(!m)return;const C=yield t.getHighlightIndexByMappingImgList({mappingImgList:g,points:m.geometry.attributes.position.array}),v=yield t.highlightOriginPointCloud(u,C);v&&((c=a==null?void 0:a.pointCloudInstance)==null||c.updateColor(v))}),l=y(o=>n.findIndex(d=>d.url===o)>=0,[n]);return{toggle2dVisible:i,isHighlightVisible:l}};export{b as useHighlight};
@@ -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};
@@ -0,0 +1 @@
1
+ import{useContext as m}from"react";import{synchronizeSideView as w,synchronizeBackView as C}from"./usePointCloudViews.js";import{useSingleBox as h}from"./useSingleBox.js";import{PointCloudContext as x}from"../PointCloudContext.js";import{useThrottleFn as f}from"ahooks";import{PointCloudUtils as V}from"@labelbee/lb-utils";const y=({currentData:t})=>{const e=m(x),{selectedBox:l,updateSelectedBox:c}=h(),{run:u}=f(a=>{const{topViewInstance:r,mainViewInstance:i,syncAllViewPointCloudColor:p}=e;if(!r||!i)return;const{pointCloud2dOperation:s}=r,o=l==null?void 0:l.info;if(!o||!(t==null?void 0:t.url)||!e.backViewInstance)return;const n=s.selectedPolygon.pointList||[],P=n.shift();n.push(P);const g=c({newPointList:n,rotation:V.restrictAngleRange(o.rotation+Number(Math.PI*a)/180),width:o.height,height:o.width});s.rotatePolygonEdge(n);const d=s.selectedPolygon;i.generateBox(o),p(g),w(o,d,e.sideViewInstance,t.url),C(o,d,e.backViewInstance,t.url),i.render()},{wait:800});return{updateRotateEdge:u}};export{y as useRotateEdge};
@@ -1 +1 @@
1
- import{useContext as G,useMemo as h,useCallback as u}from"react";import f from"lodash";import{PointCloudContext as J}from"../PointCloudContext.js";import{EToolName as D,cAnnotation as Q}from"@labelbee/lb-annotation";import{useHistory as U}from"./useHistory.js";import{usePolygon as X}from"./usePolygon.js";var Y=Object.defineProperty,Z=Object.defineProperties,$=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,ee=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,S=(i,e,l)=>e in i?Y(i,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[e]=l,ne=(i,e)=>{for(var l in e||(e={}))ee.call(e,l)&&S(i,l,e[l]);if(L)for(var l of L(e))oe.call(e,l)&&S(i,l,e[l]);return i},te=(i,e)=>Z(i,$(e));const{ESortDirection:y}=Q,ie=i=>{const{pointCloudBoxList:e,setPointCloudResult:l,topViewInstance:d,backViewInstance:g,sideViewInstance:C,selectedIDs:P,selectedID:m,mainViewInstance:c,setSelectedIDs:j,syncAllViewPointCloudColor:I,polygonList:R,pointCloudPattern:B}=G(J),{selectedPolygon:a,updateSelectedPolygon:A,updatePolygonValidByID:E,deletePolygon:N}=X(),{pushHistoryWithList:_}=U(),r=h(()=>{const o=e.findIndex(t=>t.id===m);if(o>-1)return{info:e[o],index:o}},[m,e]),O=u(o=>{var t;if(r==null?void 0:r.info){(t=i==null?void 0:i.generateRects)==null||t.call(i,o),e.splice(r.index,1,f.merge(r.info,o));const n=f.cloneDeep(e);return l(n),_({pointCloudBoxList:n}),n}return e},[m,e]),H=u((o,t)=>{const n=e.findIndex(s=>s.id===t);if(n>-1){e.splice(n,1,f.merge(e[n],o));const s=f.cloneDeep(e);return l(s),s}return e},[e]),v=u(o=>{d==null||d.pointCloud2dOperation.setPolygonValidAndRender(o,!0),C==null||C.pointCloud2dOperation.setPolygonValidAndRender(o,!0),g==null||g.pointCloud2dOperation.setPolygonValidAndRender(o,!0)},[d,C,g]),T=u(()=>{if(r==null?void 0:r.info){const{id:o,valid:t=!0}=r.info,n=O({valid:!t});I(n),v(o)}a&&(A(te(ne({},a),{valid:!a.valid})),d==null||d.pointCloud2dOperation.setPolygonValidAndRender(a.id,!0))},[v,r,a]),k=u(o=>{const t=e.find(n=>n.id===o);if(t){const{id:n,valid:s=!0}=t,x=H({valid:!s},n);return v(n),x}E(o)},[v,e,R]),b=u((o=y.ascend,t=!1)=>{if(!d||P.length>1)return;if(B!==D.Rect&&B!==D.Polygon){t&&document.dispatchEvent(new KeyboardEvent("keydown",{keyCode:9,shiftKey:o!==y.ascend}));return}const{pointCloud2dOperation:n}=d,s=n.switchToNextPolygon(o);s&&j(s)},[d,B,d==null?void 0:d.toolInstance]),K=(o=!1)=>{b(y.descend,o)},M=(o=!1)=>{b(y.ascend,o)},V=o=>{const t=e.filter(n=>n.id!==o);l(t),c==null||c.removeObjectByName(o,"box"),c==null||c.render(),I(t)},W=()=>{r&&(V(r.info.id),d==null||d.pointCloud2dOperation.deletePolygon(r.info.id)),a&&(N(a.id),d==null||d.pointCloud2dOperation.deletePolygon(a.id))},q=h(()=>e.filter(o=>P.includes(o.id)),[P,e]),z=u(o=>{var t;const n=f.cloneDeep(e);let s=!1;for(const x of o){const w=n.findIndex(p=>p.id===x.id);if(w>-1){const p=f.merge(n[w],x);(t=i==null?void 0:i.generateRects)==null||t.call(i,p),n.splice(w,1,p),c==null||c.generateBox(p),s=!0}}if(s)return l(n),_({pointCloudBoxList:n}),c==null||c.render(),n},[P,e]),F=u(o=>e.find(t=>t.id===o),[e]);return{selectedBox:r,updateSelectedBox:O,changeSelectedBoxValid:T,changeValidByID:k,selectNextBox:M,selectPrevBox:K,deletePointCloudBox:V,selectedBoxes:q,updateSelectedBoxes:z,getPointCloudByID:F,deleteSelectedPointCloudBoxAndPolygon:W}};export{ie as useSingleBox};
1
+ import{useContext as oe,useMemo as A,useCallback as c}from"react";import m from"lodash";import{PointCloudContext as te}from"../PointCloudContext.js";import{EToolName as M,cAnnotation as ne}from"@labelbee/lb-annotation";import{useHistory as ie}from"./useHistory.js";import{usePolygon as le}from"./usePolygon.js";var de=Object.defineProperty,re=Object.defineProperties,se=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,T=(i,o,l)=>o in i?de(i,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[o]=l,ue=(i,o)=>{for(var l in o||(o={}))ae.call(o,l)&&T(i,l,o[l]);if(H)for(var l of H(o))ce.call(o,l)&&T(i,l,o[l]);return i},fe=(i,o)=>re(i,se(o));const{ESortDirection:B}=ne,pe=i=>{const{pointCloudBoxList:o,setPointCloudResult:l,topViewInstance:r,backViewInstance:_,sideViewInstance:h,selectedIDs:y,selectedID:O,mainViewInstance:u,setSelectedIDs:k,syncAllViewPointCloudColor:b,polygonList:K,pointCloudPattern:V,rectList:D,removeRectIn2DView:S,addRectIn2DView:L}=oe(te),{selectedPolygon:f,updateSelectedPolygon:W,updatePolygonValidByID:q,deletePolygon:z}=le(),{pushHistoryWithList:E}=ie(),s=A(()=>{const e=o.findIndex(n=>n.id===O);if(e>-1)return{info:o[e],index:e}},[O,o]),R=c(e=>{var n;if(s==null?void 0:s.info){(n=i==null?void 0:i.generateRects)==null||n.call(i,e),o.splice(s.index,1,m.merge(s.info,e));const t=m.cloneDeep(o);return l(t),E({pointCloudBoxList:t}),t}return o},[O,o]),F=c((e,n)=>{const t=o.findIndex(d=>d.id===n);if(t>-1){o.splice(t,1,m.merge(o[t],e));const d=m.cloneDeep(o);return l(d),d}return o},[o]),I=c(e=>{r==null||r.pointCloud2dOperation.setPolygonValidAndRender(e,!0),h==null||h.pointCloud2dOperation.setPolygonValidAndRender(e,!0),_==null||_.pointCloud2dOperation.setPolygonValidAndRender(e,!0)},[r,h,_]),G=c(()=>{if(s==null?void 0:s.info){const{id:e,valid:n=!0}=s.info,t=R({valid:!n});b(t),I(e)}f&&(W(fe(ue({},f),{valid:!f.valid})),r==null||r.pointCloud2dOperation.setPolygonValidAndRender(f.id,!0))},[I,s,f]),J=c(e=>{const n=o.find(t=>t.id===e);if(n){const{id:t,valid:d=!0}=n,x=F({valid:!d},t);return I(t),x}q(e)},[I,o,K]),N=c((e=B.ascend,n=!1)=>{if(!r||y.length>1)return;if(V!==M.Rect&&V!==M.Polygon){n&&document.dispatchEvent(new KeyboardEvent("keydown",{keyCode:9,shiftKey:e!==B.ascend}));return}const{pointCloud2dOperation:t}=r,d=t.switchToNextPolygon(e);d&&k(d)},[r,V,r==null?void 0:r.toolInstance]),Q=(e=!1)=>{N(B.descend,e)},U=(e=!1)=>{N(B.ascend,e)},j=e=>{const n=o.filter(t=>t.id!==e);l(n),u==null||u.removeObjectByName(e,"box"),u==null||u.render(),b(n)},X=c((e,n)=>{var t,d;const x=new Set((d=(t=n.mappingImgList)==null?void 0:t.map(a=>a.path))!=null?d:[]),v=new Map;e.forEach(a=>{const C=a.id;(a.rects||[]).forEach(w=>{const{imageName:P}=w;if(x.has(P)){let g=v.get(P);g||(g=new Set,v.set(P,g)),g.add(C)}})});const p=D.filter(a=>{var C;const w=a.extId,P=a.imageName;if(P!==void 0&&w!==void 0){const g=v.get(P);return(C=g==null?void 0:g.has(w))!=null?C:!1}return!1});S(p),p.forEach(a=>{L(a)})},[D,S,L]),Y=e=>{s&&(j(s.info.id),r==null||r.pointCloud2dOperation.deletePolygon(s.info.id),X([s.info],e)),f&&(z(f.id),r==null||r.pointCloud2dOperation.deletePolygon(f.id))},Z=A(()=>o.filter(e=>y.includes(e.id)),[y,o]),$=c(e=>{var n;const t=m.cloneDeep(o);let d=!1;for(const x of e){const v=t.findIndex(p=>p.id===x.id);if(v>-1){const p=m.merge(t[v],x);(n=i==null?void 0:i.generateRects)==null||n.call(i,p),t.splice(v,1,p),u==null||u.generateBox(p),d=!0}}if(d)return l(t),E({pointCloudBoxList:t}),u==null||u.render(),t},[y,o]),ee=c(e=>o.find(n=>n.id===e),[o]);return{selectedBox:s,updateSelectedBox:R,changeSelectedBoxValid:G,changeValidByID:J,selectNextBox:U,selectPrevBox:Q,deletePointCloudBox:j,selectedBoxes:Z,updateSelectedBoxes:$,getPointCloudByID:ee,deleteSelectedPointCloudBoxAndPolygon:Y}};export{pe as useSingleBox};
@@ -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
+ const s=(n,r,d,a)=>{let e=n.get(r);e||(e=new Map,n.set(r,e));let t=e.get(d);return t||(t=new WeakSet,e.set(d,t)),t.add(a),n};export{s as addMapIndirectWeakSetItem};
@@ -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};