@labelbee/lb-components 1.23.0-alpha.56 → 1.23.0-alpha.58

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 (27) hide show
  1. package/dist/components/pointCloudView/PointCloud2DSingleView.js +1 -1
  2. package/dist/components/pointCloudView/PointCloudContext.js +1 -1
  3. package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
  4. package/dist/components/pointCloudView/hooks/useBoxes.js +1 -1
  5. package/dist/components/pointCloudView/hooks/useHighlight.js +1 -1
  6. package/dist/components/pointCloudView/hooks/useHistory.js +1 -1
  7. package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  8. package/dist/components/pointCloudView/hooks/useRotate.js +1 -1
  9. package/dist/components/pointCloudView/hooks/useRotateEdge.js +1 -1
  10. package/dist/components/pointCloudView/hooks/useSingleBox.js +1 -1
  11. package/dist/components/pointCloudView/hooks/useStatus.js +1 -1
  12. package/dist/types/components/pointCloudView/PointCloudContext.d.ts +2 -1
  13. package/dist/types/utils/ToolPointCloudBoxRenderHelper.d.ts +22 -0
  14. package/dist/utils/ToolPointCloudBoxRenderHelper.js +1 -0
  15. package/es/components/pointCloudView/PointCloud2DSingleView.js +1 -1
  16. package/es/components/pointCloudView/PointCloudContext.js +1 -1
  17. package/es/components/pointCloudView/PointCloudTopView.js +1 -1
  18. package/es/components/pointCloudView/hooks/useBoxes.js +1 -1
  19. package/es/components/pointCloudView/hooks/useHighlight.js +1 -1
  20. package/es/components/pointCloudView/hooks/useHistory.js +1 -1
  21. package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  22. package/es/components/pointCloudView/hooks/useRotate.js +1 -1
  23. package/es/components/pointCloudView/hooks/useRotateEdge.js +1 -1
  24. package/es/components/pointCloudView/hooks/useSingleBox.js +1 -1
  25. package/es/components/pointCloudView/hooks/useStatus.js +1 -1
  26. package/es/utils/ToolPointCloudBoxRenderHelper.js +1 -0
  27. package/package.json +2 -2
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),React=require("react"),index=require("../AnnotationView/index.js"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js"),useHighlight=require("./hooks/useHighlight.js"),index$2=require("./components/HighlightVisible/index.js"),PointCloudContext=require("./PointCloudContext.js"),useDataLinkSwitch=require("./hooks/useDataLinkSwitch.js"),index$1=require("../pointCloud2DRectOperationView/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,u,i)=>new Promise((l,s)=>{var f=t=>{try{o(i.next(t))}catch(n){s(n)}},r=t=>{try{o(i.throw(t))}catch(n){s(n)}},o=t=>t.done?l(t.value):Promise.resolve(t.value).then(f,r);o((i=i.apply(e,u)).next())});const PointCloud2DSingleView=({view2dData:e,setSelectedID:u,currentData:i,showEnlarge:l,checkMode:s=!1,measureVisible:f})=>{var r,o;const t=React.useRef(null),n=React.useRef(),{selectedBox:c}=useSingleBox.useSingleBox(),m=useSize(t),{url:p,fallbackUrl:x,calib:v,path:y}=e,{toggle2dVisible:j,isHighlightVisible:q}=useHighlight.useHighlight({currentData:i}),[P,b]=React.useState(!1),{cuboidBoxIn2DView:h,cacheImageNodeSize:_}=React.useContext(PointCloudContext.PointCloudContext),B=!e,V=React.useMemo(()=>({zIndex:l?-1:101,is2DView:!h,imageName:e.path}),[l,h,e.path]),{rendered:z,isLinking:I}=useDataLinkSwitch(V),k=d=>{g(),_({path:y,imgNode:d})},g=React.useCallback(()=>{var d,C;const L=(d=n.current)==null?void 0:d.toolInstance;if(u(""),!c||!L)return;const a=e.annotations.find(E=>E.annotation.id===c.info.id);let S="";a&&((C=a==null?void 0:a.annotation.pointList)==null?void 0:C.length)>0&&(L.focusPositionByPointList(a==null?void 0:a.annotation.pointList),S=c.info.id,u(S))},[c,n.current,e.annotations]);React.useEffect(()=>{g()},[g]);const R=()=>__async(void 0,null,function*(){b(!0),yield j(p,x!=null?x:"",v),b(!1)});return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-2d-image"),ref:t},h?React__default.default.createElement(index,{src:(r=e==null?void 0:e.url)!=null?r:"",fallbackSrc:(o=e==null?void 0:e.fallbackUrl)!=null?o:"",annotations:e.annotations,size:m,ref:n,globalStyle:{display:B?"none":"block"},afterImgOnLoad:k,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{shouldExcludePointCloudBoxListUpdate:!I,mappingData:e,size:m,checkMode:s,afterImgOnLoad:k}),!s&&z),v&&React__default.default.createElement(index$2,{visible:q(p),onClick:R,loading:P,style:{position:"absolute",right:16,top:16,zIndex:l?-1:101}}))};module.exports=PointCloud2DSingleView;
1
+ "use strict";var dom=require("../../utils/dom.js"),React=require("react"),index=require("../AnnotationView/index.js"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js"),useHighlight=require("./hooks/useHighlight.js"),index$2=require("./components/HighlightVisible/index.js"),PointCloudContext=require("./PointCloudContext.js"),useDataLinkSwitch=require("./hooks/useDataLinkSwitch.js"),index$1=require("../pointCloud2DRectOperationView/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,u,i)=>new Promise((s,a)=>{var f=t=>{try{o(i.next(t))}catch(n){a(n)}},c=t=>{try{o(i.throw(t))}catch(n){a(n)}},o=t=>t.done?s(t.value):Promise.resolve(t.value).then(f,c);o((i=i.apply(e,u)).next())});const PointCloud2DSingleView=({view2dData:e,setSelectedID:u,currentData:i,showEnlarge:s,checkMode:a=!1,measureVisible:f})=>{var c,o;const t=React.useRef(null),n=React.useRef(),{selectedBox:d}=useSingleBox.useSingleBox(),m=useSize(t),{url:p,fallbackUrl:x,calib:v,path:S}=e,{toggle2dVisible:j,isHighlightVisible:q}=useHighlight.useHighlight({currentData:i}),[P,k]=React.useState(!1),{cuboidBoxIn2DView:h,cacheImageNodeSize:_}=React.useContext(PointCloudContext.PointCloudContext),B=!e,V=React.useMemo(()=>({zIndex:s?-1:101,is2DView:!h,imageName:e.path}),[s,h,e.path]),{rendered:z,isLinking:I}=useDataLinkSwitch(V),b=l=>{g(),_({path:S,imgNode:l})},g=React.useCallback(()=>{var l,C;const y=(l=n.current)==null?void 0:l.toolInstance;if(u(""),!d||!y)return;const r=e.annotations.find(O=>O.annotation.id===d.info.id);let L="";r&&((C=r==null?void 0:r.annotation.pointList)==null?void 0:C.length)>0&&(y.focusPositionByPointList(r==null?void 0:r.annotation.pointList),L=d.info.id,u(L))},[d,n.current,e.annotations]);React.useEffect(()=>{g()},[g]);const R=()=>__async(void 0,null,function*(){k(!0);try{yield j(p,x!=null?x:"",v)}catch(l){console.error("highlightOnClick error:",l)}finally{k(!1)}});return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-2d-image"),ref:t},h?React__default.default.createElement(index,{src:(c=e==null?void 0:e.url)!=null?c:"",fallbackSrc:(o=e==null?void 0:e.fallbackUrl)!=null?o:"",annotations:e.annotations,size:m,ref:n,globalStyle:{display:B?"none":"block"},afterImgOnLoad:b,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{shouldExcludePointCloudBoxListUpdate:!I,mappingData:e,size:m,checkMode:a,afterImgOnLoad:b}),!a&&z),v&&React__default.default.createElement(index$2,{visible:q(p),onClick:R,loading:P,style:{position:"absolute",right:16,top:16,zIndex:s?-1:101}}))};module.exports=PointCloud2DSingleView;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),actionCreators=require("../../store/annotation/actionCreators.js"),index=require("../../store/annotatedBox/index.js"),_=require("lodash"),map=require("./utils/map.js");function _interopDefaultLegacy(a){return a&&typeof a=="object"&&"default"in a?a:{default:a}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(a,n,l)=>n in a?__defProp(a,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):a[n]=l,__spreadValues=(a,n)=>{for(var l in n||(n={}))__hasOwnProp.call(n,l)&&__defNormalProp(a,l,n[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(n))__propIsEnum.call(n,l)&&__defNormalProp(a,l,n[l]);return a},__spreadProps=(a,n)=>__defProps(a,__getOwnPropDescs(n)),__async=(a,n,l)=>new Promise((w,x)=>{var D=d=>{try{P(l.next(d))}catch(y){x(y)}},O=d=>{try{P(l.throw(d))}catch(y){x(y)}},P=d=>d.done?w(d.value):Promise.resolve(d.value).then(D,O);P((l=l.apply(a,n)).next())});const pickRectObject=a=>___default.default.pick(a,["id","attribute","width","height","x","y","imageName"]),PointCloudContext=React__default.default.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 lbAnnotation.ActionsHistory,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:lbAnnotation.EToolName.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:lbUtils.EPointCloudPattern.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:a=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:a=>!1,removeRectBySpecifyId:(a,n,l)=>!1,removeRectByPointCloudBoxId:a=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{}}),PointCloudProvider=({children:a})=>{const[n,l]=React.useState([]),[w,x]=React.useState([]),[D,O]=React.useState([]),[P,d]=React.useState([]),[y,ge]=React.useState([]),[h,H]=React.useState([]),[A,k]=React.useState([]),[T,me]=React.useState(!0),[W,ve]=React.useState(2),[Z,he]=React.useState(!0),[U,Pe]=React.useState(1),[f,J]=React.useState(),[K,Q]=React.useState(),[X,Y]=React.useState(),[u,$]=React.useState(),[ee,Ie]=React.useState(""),[E,Se]=React.useState(lbAnnotation.EToolName.Rect),ye=React.useRef(new lbAnnotation.ActionsHistory).current,[g,j]=React.useState([]),[te,Ce]=React.useState(""),[F,be]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,ne]=React.useState(void 0),[q,we]=React.useState([]),[z,Le]=React.useState([]),m=index(),[ie,Re]=React.useState({}),xe=ctx.useDispatch(),De=i=>{const{imgNode:o,path:t}=i;t&&o&&Re(c=>__spreadProps(__spreadValues({},c),{[t]:{width:o.width,height:o.height}}))},oe=React.useMemo(()=>h.length===1?h[0]:"",[h]),B=React.useCallback((i,o,t="extId")=>{const c=t||"id",r=new Set(o);return d(p=>{let C=!1;const b=p.filter(N=>{const G=N[c],M=r.has(G)?N.imageName!==i:!0;return M||(C=!0),M});return C?b:p}),!0},[]),se=React.useCallback(i=>{const o=n.map(t=>t.id);return B(i,o,"extId")},[n,B]),ae=React.useCallback(i=>{if(!i)return!1;const o=n.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:c,attribute:r,trackID:p}=t,C=t.rects.find(b=>b.imageName===i);if(C){const b=___default.default.pick(C,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},b),{id:lbAnnotation.uuid(),attribute:r,order:p,extId:c,lineDash:[]})}return null}).filter(t=>t!==null);return o.length?(d(t=>{const c=new Set(t.filter(p=>i===p.imageName).map(p=>p.extId)),r=o.filter(p=>c.has(p.extId)===!1);return r.length?[...t,...r]:t}),!0):!1},[n]),re=React.useMemo(()=>n.filter(o=>Array.isArray(o.rects)&&o.rects.length>0).reduce((o,t)=>{var c;return(c=t.rects)==null||c.forEach(r=>{const{imageName:p}=r;if(!p){console.warn("Missing image name"),console.trace(r,t);return}map.addMapIndirectWeakSetItem(o,p,t.id,t)}),o},new Map),[n]),le=React.useCallback(i=>{d(o=>i(o,pickRectObject))},[pickRectObject]),ce=React.useMemo(()=>P.filter(i=>i.extId!==void 0&&i.id!==void 0).reduce((i,o)=>{const t=o.imageName;return t?(map.addMapIndirectWeakSetItem(i,t,o.extId,o),i):(console.warn("missing image name"),console.log(o,P),i)},new Map),[P]),V=React.useMemo(()=>{const i=n.find(e=>e.id===oe),o=e=>{const s=n.concat(e);return l(s),s},t=e=>{const s=w.concat(e);return x(s),s},c=e=>{me(e!==!1)},r=e=>{e===void 0&&H([]),typeof e=="string"&&H([e]),Array.isArray(e)&&H(Array.from(new Set(e)))},p=e=>{h.includes(e)?r(h.filter(s=>s!==e)):r([...h,e])},C=e=>{const s=pickRectObject(e);d(v=>[...v,s])},b=(e,s=!1)=>{const v=pickRectObject(e);d(S=>S.map(I=>I.id===e.id?s?__spreadValues(__spreadValues({},I),v):v:I))},N=e=>{d(s=>s.filter(v=>!e.find(S=>S.id===v.id)))},G=e=>{A.includes(e)?k([]):k([e])},M=()=>{if(E===lbAnnotation.EToolName.Rect){const e=n.map(s=>s.id);r(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},Ae=e=>{r(n.filter(s=>s.attribute===e).map(s=>s.id))},de=n.filter(e=>!g.includes(e.attribute)),ue=w.filter(e=>!g.includes(e.attribute)),pe=y.filter(e=>e.attribute&&!g.includes(e.attribute)),Be=e=>{if(g.includes(e))j(g.filter(s=>s!==e));else{const s=g.concat(e);j(s)}},Ve=(e=de,s=D,v=ue,S=pe,I=q)=>{var R;u==null||u.clearAllBox(),u==null||u.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(v),f==null||f.updateLineList(S),u==null||u.generateBoxes(e),u==null||u.generateSpheres(v),(R=L==null?void 0:L.store)==null||R.updateCurrentSegment(I),fe(e)},Ne=()=>{J(void 0),Q(void 0),Y(void 0),$(void 0)},fe=(e,s)=>__async(void 0,null,function*(){var v;if(!u)return;const S=u.pointCloudObject;if(!!S)try{const I=yield u.getHighlightIndexByMappingImgList({mappingImgList:s!=null?s:z,points:S.geometry.attributes.position.array}),R=yield u==null?void 0:u.highlightOriginPointCloud(e,I);return R&&((v=f==null?void 0:f.pointCloudInstance)==null||v.updateColor(R)),R}catch(I){console.error(I)}});return{selectedID:oe,pointCloudBoxList:n,pointCloudSphereList:w,displayPointCloudList:de,displaySphereList:ue,displayLineList:pe,selectedIDs:h,setPointCloudResult:l,setSelectedIDs:r,addPointCloudBox:o,addPointCloudSphere:t,setPointCloudSphereList:x,valid:T,selectedPointCloudBox:i,setPointCloudValid:c,addSelectedID:p,addHighlightID:G,selectedAllBoxes:M,topViewInstance:f,setTopViewInstance:J,sideViewInstance:K,setSideViewInstance:Q,backViewInstance:X,setBackViewInstance:Y,mainViewInstance:u,setMainViewInstance:$,polygonList:D,setPolygonList:O,rectList:P,setRectList:d,addRectIn2DView:C,removeRectIn2DView:N,updateRectIn2DView:b,lineList:y,setLineList:ge,zoom:U,setZoom:Pe,history:ye,toggleAttributesVisible:Be,hideAttributes:g,setHideAttributes:j,reRender:Ve,attrPanelLayout:te,setAttrPanelLayout:Ce,syncAllViewPointCloudColor:fe,defaultAttribute:ee,setDefaultAttribute:Ie,pointCloudPattern:E,setPointCloudPattern:Se,selectSpecAttr:Ae,globalPattern:F,setGlobalPattern:e=>{F!==e&&(xe(actionCreators.ChangeSave),be(e),e===lbUtils.EPointCloudPattern.Detection&&ne(void 0))},ptSegmentInstance:L,setPtSegmentInstance:ne,segmentation:q,setSegmentation:we,clearAllDetectionInstance:Ne,highlight2DDataList:z,setHighlight2DDataList:Le,cuboidBoxIn2DView:Z,setCuboidBoxIn2DView:he,imageSizes:ie,cacheImageNodeSize:De,highlightIDs:A,setHighlightIDs:k,removeRectByPointCloudBoxId:se,removeRectBySpecifyId:B,addRectFromPointCloudBoxByImageName:ae,rectRotateSensitivity:W,setRectRotateSensitivity:ve,imageNamePointCloudBoxMap:re,linkageImageNameRectMap:ce,updateRectListByReducer:le}},[T,h,n,w,D,y,P,f,K,X,u,U,g,te,ee,E,F,L,q,z,Z,ie,A,se,B,ae,W,re,ce,le]);React.useEffect(()=>{var i,o,t;(i=m==null?void 0:m.setPointCloudBoxList)==null||i.call(m,n),(o=m==null?void 0:m.setHighlightIDs)==null||o.call(m,A),(t=m==null?void 0:m.setSelectedIDs)==null||t.call(m,h)},[n,h,A]),React.useEffect(()=>{var i;(i=m==null?void 0:m.setPtCtx)==null||i.call(m,V)},[V]);const _e=()=>{const i=n.filter(r=>g.includes(r.attribute)),{setSelectedIDs:o,reRender:t}=V,c=i.map(r=>r.id);c.length>0&&o(h.filter(r=>!c.includes(r))),t()};return React.useEffect(()=>{var i,o,t,c;_e(),(o=(i=f==null?void 0:f.toolInstance)==null?void 0:i.setHiddenAttributes)==null||o.call(i,g),(c=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||c.call(t,g)},[g]),React__default.default.createElement(PointCloudContext.Provider,{value:V},a)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),actionCreators=require("../../store/annotation/actionCreators.js"),index=require("../../store/annotatedBox/index.js"),_=require("lodash"),map=require("./utils/map.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,o,a)=>o in r?__defProp(r,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[o]=a,__spreadValues=(r,o)=>{for(var a in o||(o={}))__hasOwnProp.call(o,a)&&__defNormalProp(r,a,o[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(o))__propIsEnum.call(o,a)&&__defNormalProp(r,a,o[a]);return r},__spreadProps=(r,o)=>__defProps(r,__getOwnPropDescs(o)),__async=(r,o,a)=>new Promise((w,D)=>{var A=c=>{try{P(a.next(c))}catch(x){D(x)}},H=c=>{try{P(a.throw(c))}catch(x){D(x)}},P=c=>c.done?w(c.value):Promise.resolve(c.value).then(A,H);P((a=a.apply(r,o)).next())});const pickRectObject=r=>___default.default.pick(r,["id","attribute","width","height","x","y","imageName"]),PointCloudContext=React__default.default.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 lbAnnotation.ActionsHistory,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:lbAnnotation.EToolName.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:lbUtils.EPointCloudPattern.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,o,a)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{}}),PointCloudProvider=({children:r})=>{const[o,a]=React.useState([]),[w,D]=React.useState([]),[A,H]=React.useState([]),[P,c]=React.useState([]),[x,be]=React.useState([]),[h,j]=React.useState([]),[B,k]=React.useState([]),[U,xe]=React.useState(!0),[J,ye]=React.useState(2),[K,Re]=React.useState(!0),[Q,we]=React.useState(1),[f,X]=React.useState(),[Y,$]=React.useState(),[ee,te]=React.useState(),[u,oe]=React.useState(),[ne,Le]=React.useState(""),[q,De]=React.useState(lbAnnotation.EToolName.Rect),F=React.useRef(new lbAnnotation.ActionsHistory).current,[p,T]=React.useState([]),[ie,Ae]=React.useState(""),[z,Be]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,se]=React.useState(void 0),[G,_e]=React.useState([]),[W,Ve]=React.useState([]),m=index(),[re,Ne]=React.useState({}),Me=ctx.useDispatch(),Oe=n=>{const{imgNode:i,path:t}=n;t&&i&&Ne(d=>__spreadProps(__spreadValues({},d),{[t]:{width:i.width,height:i.height}}))},le=React.useMemo(()=>h.length===1?h[0]:"",[h]),N=React.useCallback((n,i,t="extId")=>{const d=t||"id",l=new Set(i);return c(g=>{let y=!1;const R=g.filter(O=>{const Z=O[d],E=l.has(Z)?O.imageName!==n:!0;return E||(y=!0),E});return y?R:g}),!0},[]),ae=React.useCallback(n=>{const i=o.map(t=>t.id);return N(n,i,"extId")},[o,N]),de=React.useCallback(n=>{if(!n)return!1;const i=o.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:d,attribute:l,trackID:g}=t,y=t.rects.find(R=>R.imageName===n);if(y){const R=___default.default.pick(y,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},R),{id:lbAnnotation.uuid(),attribute:l,order:g,extId:d,lineDash:[]})}return null}).filter(t=>t!==null);return i.length?(c(t=>{const d=new Set(t.filter(g=>n===g.imageName).map(g=>g.extId)),l=i.filter(g=>d.has(g.extId)===!1);return l.length?[...t,...l]:t}),!0):!1},[o]),ce=React.useMemo(()=>o.filter(i=>Array.isArray(i.rects)&&i.rects.length>0).reduce((i,t)=>{var d;return(d=t.rects)==null||d.forEach(l=>{const{imageName:g}=l;if(!g){console.warn("Missing image name"),console.trace(l,t);return}map.addMapIndirectWeakSetItem(i,g,t.id,t)}),i},new Map),[o]),ue=React.useCallback(n=>{c(i=>n(i,pickRectObject))},[pickRectObject]),ge=React.useMemo(()=>P.filter(n=>n.extId!==void 0&&n.id!==void 0).reduce((n,i)=>{const t=i.imageName;return t?(map.addMapIndirectWeakSetItem(n,t,i.extId,i),n):(console.warn("missing image name"),console.log(i,P),n)},new Map),[P]),M=React.useMemo(()=>{const n=o.find(e=>e.id===le),i=e=>{const s=o.concat(e);return a(s),s},t=e=>{const s=w.concat(e);return D(s),s},d=e=>{xe(e!==!1)},l=e=>{e===void 0&&j([]),typeof e=="string"&&j([e]),Array.isArray(e)&&j(Array.from(new Set(e)))},g=e=>{h.includes(e)?l(h.filter(s=>s!==e)):l([...h,e])},y=e=>{const s=pickRectObject(e);c(v=>[...v,s])},R=(e,s=!1)=>{const v=pickRectObject(e);c(I=>I.map(S=>S.id===e.id?s?__spreadValues(__spreadValues({},S),v):v:S))},O=e=>{c(s=>s.filter(v=>!e.find(I=>I.id===v.id)))},Z=e=>{B.includes(e)?k([]):k([e])},E=()=>{if(q===lbAnnotation.EToolName.Rect){const e=o.map(s=>s.id);l(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},He=e=>{l(o.filter(s=>s.attribute===e).map(s=>s.id))},fe=o.filter(e=>!p.includes(e.attribute)),pe=w.filter(e=>!p.includes(e.attribute)),me=x.filter(e=>e.attribute&&!p.includes(e.attribute)),je=e=>{if(p.includes(e))T(p.filter(s=>s!==e));else{const s=p.concat(e);T(s)}},ke=(e=fe,s=A,v=pe,I=me,S=G)=>{var V;u==null||u.clearAllBox(),u==null||u.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(v),f==null||f.updateLineList(I),u==null||u.generateBoxes(e),u==null||u.generateSpheres(v),(V=L==null?void 0:L.store)==null||V.updateCurrentSegment(S),ve(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},qe=()=>{X(void 0),$(void 0),te(void 0),oe(void 0)},ve=(e,s,v)=>__async(void 0,null,function*(){var I,S,V;if(!u)return;const he=u.pointCloudObject;if(!he)return;let Pe=[],Ie=[];try{if(s&&F.record.length){const{record:C,recordIndex:b}=F;let Se=b;b>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&s.length===((I=C[b])==null?void 0:I.pointCloudBoxList.length))&&(Se=b-1);let Fe=(S=C[Se])==null?void 0:S.pointCloudBoxList;const Ce=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,s,Fe);Pe=Ce.modifiedBoxIds,Ie=Ce.resetAreas}}catch(C){console.error("call calcResetAreasAndBoxIds error",C)}try{const C=yield u.getHighlightIndexByMappingImgList({mappingImgList:v!=null?v:W,points:he.geometry.attributes.position.array}),b=yield u==null?void 0:u.highlightOriginPointCloud(s,C,{modifiedBoxIds:Pe,resetAreas:Ie});return b&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(b)),b}catch(C){console.error("call highlightOriginPointCloud error",C)}});return{selectedID:le,pointCloudBoxList:o,pointCloudSphereList:w,displayPointCloudList:fe,displaySphereList:pe,displayLineList:me,selectedIDs:h,setPointCloudResult:a,setSelectedIDs:l,addPointCloudBox:i,addPointCloudSphere:t,setPointCloudSphereList:D,valid:U,selectedPointCloudBox:n,setPointCloudValid:d,addSelectedID:g,addHighlightID:Z,selectedAllBoxes:E,topViewInstance:f,setTopViewInstance:X,sideViewInstance:Y,setSideViewInstance:$,backViewInstance:ee,setBackViewInstance:te,mainViewInstance:u,setMainViewInstance:oe,polygonList:A,setPolygonList:H,rectList:P,setRectList:c,addRectIn2DView:y,removeRectIn2DView:O,updateRectIn2DView:R,lineList:x,setLineList:be,zoom:Q,setZoom:we,history:F,toggleAttributesVisible:je,hideAttributes:p,setHideAttributes:T,reRender:ke,attrPanelLayout:ie,setAttrPanelLayout:Ae,syncAllViewPointCloudColor:ve,defaultAttribute:ne,setDefaultAttribute:Le,pointCloudPattern:q,setPointCloudPattern:De,selectSpecAttr:He,globalPattern:z,setGlobalPattern:e=>{z!==e&&(Me(actionCreators.ChangeSave),Be(e),e===lbUtils.EPointCloudPattern.Detection&&se(void 0))},ptSegmentInstance:L,setPtSegmentInstance:se,segmentation:G,setSegmentation:_e,clearAllDetectionInstance:qe,highlight2DDataList:W,setHighlight2DDataList:Ve,cuboidBoxIn2DView:K,setCuboidBoxIn2DView:Re,imageSizes:re,cacheImageNodeSize:Oe,highlightIDs:B,setHighlightIDs:k,removeRectByPointCloudBoxId:ae,removeRectBySpecifyId:N,addRectFromPointCloudBoxByImageName:de,rectRotateSensitivity:J,setRectRotateSensitivity:ye,imageNamePointCloudBoxMap:ce,linkageImageNameRectMap:ge,updateRectListByReducer:ue}},[U,h,o,w,A,x,P,f,Y,ee,u,Q,p,ie,ne,q,z,L,G,W,K,re,B,ae,N,de,J,ce,ge,ue]);React.useEffect(()=>{var n,i,t;(n=m==null?void 0:m.setPointCloudBoxList)==null||n.call(m,o),(i=m==null?void 0:m.setHighlightIDs)==null||i.call(m,B),(t=m==null?void 0:m.setSelectedIDs)==null||t.call(m,h)},[o,h,B]),React.useEffect(()=>{var n;(n=m==null?void 0:m.setPtCtx)==null||n.call(m,M)},[M]);const Ee=()=>{const n=o.filter(l=>p.includes(l.attribute)),{setSelectedIDs:i,reRender:t}=M,d=n.map(l=>l.id);d.length>0&&i(h.filter(l=>!d.includes(l))),t()};return React.useEffect(()=>{var n,i,t,d;Ee(),(i=(n=f==null?void 0:f.toolInstance)==null?void 0:n.setHiddenAttributes)==null||i.call(n,p),(d=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||d.call(t,p)},[p]),React__default.default.createElement(PointCloudContext.Provider,{value:M},r)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),index$3=require("../../views/MainView/toolFooter/index.js"),index$4=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js"),_=require("lodash"),index$2=require("./components/PointCloudSizeSlider/index.js"),useHistory=require("./hooks/useHistory.js"),index$1=require("./components/TitleButton/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,l,s)=>l in o?__defProp(o,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[l]=s,__spreadValues=(o,l)=>{for(var s in l||(l={}))__hasOwnProp.call(l,s)&&__defNormalProp(o,s,l[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(l))__propIsEnum.call(l,s)&&__defNormalProp(o,s,l[s]);return o},__spreadProps=(o,l)=>__defProps(o,__getOwnPropDescs(l));const{EPolygonPattern,EToolName}=lbAnnotation.cTool,{ESortDirection}=lbAnnotation.cAnnotation,EKeyCode=lbAnnotation.cKeyCode.default,TransferCanvas2WorldOffset=(o,l,s=1)=>{const{width:C,height:c}=l,w={x:o.x+C*s/2,y:o.y+c*s/2},P={x:l.width/2,y:l.height/2};return{offsetX:(P.x-w.x)/s,offsetY:-(P.y-w.y)/s}},TopViewToolbar=({currentData:o})=>{var l,s;const{zoom:C,zoomIn:c,zoomOut:w,initialPosition:P}=useZoom.useZoom(),{selectNextBox:S,selectPrevBox:V}=useSingleBox.useSingleBox(),{switchToNextSphere:x}=useSphere.useSphere(),{updateRotate:y}=useRotate.useRotate({currentData:o}),{updateRotateEdge:E}=useRotateEdge.useRotateEdge({currentData:o}),g=React__default.default.useContext(PointCloudContext.PointCloudContext),{topViewInstance:I}=g,p=(s=(l=g==null?void 0:g.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:s.getCurrentToolName(),e=()=>{y(-Number(g.rectRotateSensitivity))},r=()=>{y(g.rectRotateSensitivity)},f=()=>{E(-90)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$2,{onChange:b=>{var h;(h=I==null?void 0:I.pointCloudInstance)==null||h.updatePointSize({customSize:b})}}),React__default.default.createElement("span",{onClick:r,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:e,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:f,className:dom.getClassName("point-cloud","rotate-90")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{if(p===EToolName.Point){x(ESortDirection.descend);return}V(!0)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{if(p===EToolName.Point){x(ESortDirection.ascend);return}S(!0)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(index$4.ZoomController,{initialPosition:P,zoomIn:c,zoomOut:w,zoom:C}))},ZAxisSlider=({setZAxisLimit:o,zAxisLimit:l,checkMode:s})=>s?null:React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:C=>{o(C)}})),PointCloudTopView=({currentData:o,imgList:l,stepInfo:s,drawLayerSlot:C,checkMode:c,intelligentFit:w,setIsEnlargeTopView:P,isEnlargeTopView:S,onExitZoom:V,highlightAttribute:x})=>{var y,E;const[g,I]=React.useState({zoom:1,currentPos:{x:0,y:0}}),p=React.useRef(null),e=React__default.default.useContext(PointCloudContext.PointCloudContext),r=useSize(p),f=index.jsonParser(s.config),{setZoom:b,syncTopviewToolZoom:h}=useZoom.useZoom(),{hideAttributes:A}=e,{addPolygon:B,deletePolygon:D}=usePolygon.usePolygon(),{deletePointCloudSphere:U}=useSphere.useSphere(),{deletePointCloudBox:Z,changeValidByID:z}=useSingleBox.useSingleBox(),[L,H]=React.useState(10),{t:k}=reactI18next.useTranslation(),m=usePointCloudViews.usePointCloudViews(),{pushHistoryWithList:F}=useHistory.useHistory();React.useLayoutEffect(()=>{if(!e.topViewInstance&&p.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const n={width:p.current.clientWidth,height:p.current.clientHeight},a=new lbAnnotation.PointCloudAnnotation({container:p.current,size:n,pcdPath:o.url,config:__spreadProps(__spreadValues({},f),{pointCloudPattern:e.pointCloudPattern}),checkMode:c,toolName:ToolUtils.getPointCloudToolList(),proxyMode:c});e.setTopViewInstance(a)}},[o]),React.useEffect(()=>{if(!r||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:n}=e.topViewInstance;n.singleOn("dataUpdated",(t,i)=>{const d=___default.default.cloneDeep(t).map(u=>__spreadProps(__spreadValues({},u),{pointList:lbUtils.PointCloudUtils.pointListTransferCanvas2World(u.pointList,r)}));e.setSelectedIDs(i),e.setLineList(d),F({lineList:d})}),n.singleOn("pointCreated",(t,i)=>{m.topViewAddSphere({newPoint:t,size:r,trackConfigurable:f.trackConfigurable,zoom:i})}),n.singleOn("pointDeleted",t=>{U(t)}),n.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),n.singleOn("updatePointByDrag",(t,i)=>{var d;(d=m.topViewUpdatePoint)==null||d.call(m,t,r)}),n.singleOn("polygonCreated",(t,i)=>{if(n.pattern===EPolygonPattern.Normal||!(o==null?void 0:o.url)){const d=__spreadProps(__spreadValues({},t),{pointList:t.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,r))});B(d),e.setSelectedIDs(A.includes(t.attribute)?"":t.id);return}m.topViewAddBox({polygon:t,size:r,imgList:l,trackConfigurable:f.trackConfigurable,zoom:i,intelligentFit:w})}),n.singleOn("deletedObject",({id:t})=>{Z(t),D(t)}),n.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),n.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),n.singleOn("setSelectedIDs",t=>{e.setSelectedIDs(t)}),n.singleOn("updatePolygonByDrag",t=>{var i;(i=m.topViewUpdateBox)==null||i.call(m,t,r)});const a=t=>{var i;const d=z(t);d&&e.syncAllViewPointCloudColor(d),e.polygonList.find(u=>u.id===t)&&((i=e.topViewInstance)==null||i.toolInstance.setPolygonValidAndRender(t,!0))};return n.on("validUpdate",a),()=>{n.unbind("validUpdate",a)}},[e,r,o,m,e.polygonList,e.lineList,(y=e.topViewInstance)==null?void 0:y.toolInstance]),React.useEffect(()=>{var n,a;if(!(r==null?void 0:r.width)||!e.topViewInstance)return;const t=(a=(n=f==null?void 0:f.attributeList)==null?void 0:n[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(r),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:i,toolInstance:d}}=e;d.singleOn("renderZoom",(u,v)=>{const{offsetX:O,offsetY:q}=TransferCanvas2WorldOffset(v,r,u);if(i.camera.zoom=u,v){const{x:j,y:T,z:N}=i.initCameraPosition;i.camera.position.set(j+q,T-O,N)}i.camera.updateProjectionMatrix(),i.render(),b(u),h(v,u,r),I({zoom:u,currentPos:v})}),d.singleOn("dragMove",({currentPos:u,zoom:v})=>{const{offsetX:O,offsetY:q}=TransferCanvas2WorldOffset(u,r,v);i.camera.zoom=v;const{x:j,y:T,z:N}=i.initCameraPosition;i.camera.position.set(j+q,T-O,N),i.render(),h(u,v,r),I({zoom:v,currentPos:u})})},[r,e.topViewInstance,(E=e.topViewInstance)==null?void 0:E.toolInstance]),React.useEffect(()=>{var n,a;(a=(n=e.topViewInstance)==null?void 0:n.pointCloudInstance)==null||a.applyZAxisPoints(L)},[L]),React.useEffect(()=>{var n,a,t,i;m.topViewSelectedChanged({}),(i=(t=(a=(n=e.topViewInstance)==null?void 0:n.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||i.call(t,e.selectedIDs)},[e.selectedIDs]),React.useEffect(()=>(window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R)}),[]);const R=n=>{const{keyCode:a}=n;a===EKeyCode.Esc&&V()};return React.useEffect(()=>{var n,a,t;(t=(a=(n=e.topViewInstance)==null?void 0:n.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,x)},[e.topViewInstance,x]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:S?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{V()}}),React__default.default.createElement("span",null,k("TopView")),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:c,config:f,style:{display:"flex",position:"initial",margin:"0px 20px"}})):React__default.default.createElement(index$1,{title:k("TopView"),onClick:()=>{P(!0)}}),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:o})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:p},C==null?void 0:C(g)),!S&&React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:c,config:f}),React__default.default.createElement(ZAxisSlider,{checkMode:c,zAxisLimit:L,setZAxisLimit:H}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudTopView);module.exports=PointCloudTopView$1;
1
+ "use strict";var dom=require("../../utils/dom.js"),index$3=require("../../views/MainView/toolFooter/index.js"),index$4=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js"),_=require("lodash"),index$2=require("./components/PointCloudSizeSlider/index.js"),useHistory=require("./hooks/useHistory.js"),index$1=require("./components/TitleButton/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,l,s)=>l in o?__defProp(o,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[l]=s,__spreadValues=(o,l)=>{for(var s in l||(l={}))__hasOwnProp.call(l,s)&&__defNormalProp(o,s,l[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(l))__propIsEnum.call(l,s)&&__defNormalProp(o,s,l[s]);return o},__spreadProps=(o,l)=>__defProps(o,__getOwnPropDescs(l));const{EPolygonPattern,EToolName}=lbAnnotation.cTool,{ESortDirection}=lbAnnotation.cAnnotation,EKeyCode=lbAnnotation.cKeyCode.default,TransferCanvas2WorldOffset=(o,l,s=1)=>{const{width:C,height:c}=l,w={x:o.x+C*s/2,y:o.y+c*s/2},P={x:l.width/2,y:l.height/2};return{offsetX:(P.x-w.x)/s,offsetY:-(P.y-w.y)/s}},TopViewToolbar=({currentData:o})=>{var l,s;const{zoom:C,zoomIn:c,zoomOut:w,initialPosition:P}=useZoom.useZoom(),{selectNextBox:S,selectPrevBox:V}=useSingleBox.useSingleBox(),{switchToNextSphere:x}=useSphere.useSphere(),{updateRotate:y}=useRotate.useRotate({currentData:o}),{updateRotateEdge:E}=useRotateEdge.useRotateEdge({currentData:o}),g=React__default.default.useContext(PointCloudContext.PointCloudContext),{topViewInstance:I}=g,p=(s=(l=g==null?void 0:g.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:s.getCurrentToolName(),e=()=>{y(-Number(g.rectRotateSensitivity))},r=()=>{y(g.rectRotateSensitivity)},f=()=>{E(-90)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$2,{onChange:b=>{var h;(h=I==null?void 0:I.pointCloudInstance)==null||h.updatePointSize({customSize:b})}}),React__default.default.createElement("span",{onClick:r,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:e,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:f,className:dom.getClassName("point-cloud","rotate-90")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{if(p===EToolName.Point){x(ESortDirection.descend);return}V(!0)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{if(p===EToolName.Point){x(ESortDirection.ascend);return}S(!0)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(index$4.ZoomController,{initialPosition:P,zoomIn:c,zoomOut:w,zoom:C}))},ZAxisSlider=({setZAxisLimit:o,zAxisLimit:l,checkMode:s})=>s?null:React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:C=>{o(C)}})),PointCloudTopView=({currentData:o,imgList:l,stepInfo:s,drawLayerSlot:C,checkMode:c,intelligentFit:w,setIsEnlargeTopView:P,isEnlargeTopView:S,onExitZoom:V,highlightAttribute:x})=>{var y,E;const[g,I]=React.useState({zoom:1,currentPos:{x:0,y:0}}),p=React.useRef(null),e=React__default.default.useContext(PointCloudContext.PointCloudContext),r=useSize(p),f=index.jsonParser(s.config),{setZoom:b,syncTopviewToolZoom:h}=useZoom.useZoom(),{hideAttributes:B}=e,{addPolygon:A,deletePolygon:D}=usePolygon.usePolygon(),{deletePointCloudSphere:U}=useSphere.useSphere(),{deletePointCloudBox:Z,changeValidByID:H}=useSingleBox.useSingleBox(),[L,z]=React.useState(10),{t:N}=reactI18next.useTranslation(),m=usePointCloudViews.usePointCloudViews(),{pushHistoryWithList:F}=useHistory.useHistory();React.useLayoutEffect(()=>{if(!e.topViewInstance&&p.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const n={width:p.current.clientWidth,height:p.current.clientHeight},a=new lbAnnotation.PointCloudAnnotation({container:p.current,size:n,pcdPath:o.url,config:__spreadProps(__spreadValues({},f),{pointCloudPattern:e.pointCloudPattern}),checkMode:c,toolName:ToolUtils.getPointCloudToolList(),proxyMode:c});e.setTopViewInstance(a)}},[o]),React.useEffect(()=>{if(!r||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:n}=e.topViewInstance;n.singleOn("dataUpdated",(t,i)=>{const d=___default.default.cloneDeep(t).map(u=>__spreadProps(__spreadValues({},u),{pointList:lbUtils.PointCloudUtils.pointListTransferCanvas2World(u.pointList,r)}));e.setSelectedIDs(i),e.setLineList(d),F({lineList:d})}),n.singleOn("pointCreated",(t,i)=>{m.topViewAddSphere({newPoint:t,size:r,trackConfigurable:f.trackConfigurable,zoom:i})}),n.singleOn("pointDeleted",t=>{U(t)}),n.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),n.singleOn("updatePointByDrag",(t,i)=>{var d;(d=m.topViewUpdatePoint)==null||d.call(m,t,r)}),n.singleOn("polygonCreated",(t,i)=>{if(n.pattern===EPolygonPattern.Normal||!(o==null?void 0:o.url)){const d=__spreadProps(__spreadValues({},t),{pointList:t.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,r))});A(d),e.setSelectedIDs(B.includes(t.attribute)?"":t.id);return}m.topViewAddBox({polygon:t,size:r,imgList:l,trackConfigurable:f.trackConfigurable,zoom:i,intelligentFit:w})}),n.singleOn("deletedObject",({id:t})=>{Z(t),D(t)}),n.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),n.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),n.singleOn("setSelectedIDs",t=>{e.setSelectedIDs(t)}),n.singleOn("updatePolygonByDrag",t=>{var i;(i=m.topViewUpdateBox)==null||i.call(m,t,r)});const a=t=>{var i;const d=H(t);d&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,d),e.polygonList.find(u=>u.id===t)&&((i=e.topViewInstance)==null||i.toolInstance.setPolygonValidAndRender(t,!0))};return n.on("validUpdate",a),()=>{n.unbind("validUpdate",a)}},[e,r,o,m,e.polygonList,e.lineList,(y=e.topViewInstance)==null?void 0:y.toolInstance]),React.useEffect(()=>{var n,a;if(!(r==null?void 0:r.width)||!e.topViewInstance)return;const t=(a=(n=f==null?void 0:f.attributeList)==null?void 0:n[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(r),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:i,toolInstance:d}}=e;d.singleOn("renderZoom",(u,v)=>{const{offsetX:O,offsetY:q}=TransferCanvas2WorldOffset(v,r,u);if(i.camera.zoom=u,v){const{x:j,y:T,z:R}=i.initCameraPosition;i.camera.position.set(j+q,T-O,R)}i.camera.updateProjectionMatrix(),i.render(),b(u),h(v,u,r),I({zoom:u,currentPos:v})}),d.singleOn("dragMove",({currentPos:u,zoom:v})=>{const{offsetX:O,offsetY:q}=TransferCanvas2WorldOffset(u,r,v);i.camera.zoom=v;const{x:j,y:T,z:R}=i.initCameraPosition;i.camera.position.set(j+q,T-O,R),i.render(),h(u,v,r),I({zoom:v,currentPos:u})})},[r,e.topViewInstance,(E=e.topViewInstance)==null?void 0:E.toolInstance]),React.useEffect(()=>{var n,a;(a=(n=e.topViewInstance)==null?void 0:n.pointCloudInstance)==null||a.applyZAxisPoints(L)},[L]),React.useEffect(()=>{var n,a,t,i;m.topViewSelectedChanged({}),(i=(t=(a=(n=e.topViewInstance)==null?void 0:n.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||i.call(t,e.selectedIDs)},[e.selectedIDs]),React.useEffect(()=>(window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k)}),[]);const k=n=>{const{keyCode:a}=n;a===EKeyCode.Esc&&V()};return React.useEffect(()=>{var n,a,t;(t=(a=(n=e.topViewInstance)==null?void 0:n.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,x)},[e.topViewInstance,x]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:S?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{V()}}),React__default.default.createElement("span",null,N("TopView")),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:c,config:f,style:{display:"flex",position:"initial",margin:"0px 20px"}})):React__default.default.createElement(index$1,{title:N("TopView"),onClick:()=>{P(!0)}}),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:o})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:p},C==null?void 0:C(g)),!S&&React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:c,config:f}),React__default.default.createElement(ZAxisSlider,{checkMode:c,zAxisLimit:L,setZAxisLimit:z}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudTopView);module.exports=PointCloudTopView$1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),_=require("lodash"),antd=require("antd"),usePointCloudViews=require("./usePointCloudViews.js"),PointCloudContext=require("../PointCloudContext.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var ___default=_interopDefaultLegacy(_);const useBoxes=({config:t})=>{const{selectedIDs:l,pointCloudBoxList:c,displayPointCloudList:s,setPointCloudResult:p,syncAllViewPointCloudColor:f}=React.useContext(PointCloudContext.PointCloudContext),[o,a]=React.useState([]),{pointCloudBoxListUpdated:d}=usePointCloudViews.usePointCloudViews(),{t:r,i18n:C}=reactI18next.useTranslation(),x=n=>t.trackConfigurable!==!0?!1:c.some(u=>n.some(e=>e.trackID===u.trackID)),i=React.useMemo(()=>s.filter(n=>l.includes(n.id)),[l,s]),D=React.useCallback(()=>{i.length>0?a(___default.default.cloneDeep(i)):(a([]),antd.message.error(r("CopyEmptyInPointCloud")))},[l,s,C.language]),P=React.useCallback(()=>{if(o.length===0){antd.message.error(r("PasteEmptyInPointCloud"));return}const n=x(o),u=e=>{p(e),d==null||d(e),a([]),f(e)};if(n)antd.Modal.confirm({title:r("HasDuplicateIDHeader"),content:r("HasDuplicateIDMsg"),onOk:()=>{const e=c.filter(g=>!o.find(I=>I.trackID===g.trackID)).concat(o);u(e)}});else{const e=[...s,...o];u(e)}},[o,s,C.language]);return{copySelectedBoxes:D,pasteSelectedBoxes:P,copiedBoxes:o,selectedBoxes:i}};exports.useBoxes=useBoxes;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),_=require("lodash"),antd=require("antd"),usePointCloudViews=require("./usePointCloudViews.js"),PointCloudContext=require("../PointCloudContext.js"),reactI18next=require("react-i18next"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var ___default=_interopDefaultLegacy(_);const useBoxes=({config:t})=>{const{selectedIDs:l,pointCloudBoxList:c,displayPointCloudList:r,setPointCloudResult:p,syncAllViewPointCloudColor:f}=React.useContext(PointCloudContext.PointCloudContext),[o,i]=React.useState([]),{pointCloudBoxListUpdated:d}=usePointCloudViews.usePointCloudViews(),{t:n,i18n:C}=reactI18next.useTranslation(),x=s=>t.trackConfigurable!==!0?!1:c.some(u=>s.some(e=>e.trackID===u.trackID)),a=React.useMemo(()=>r.filter(s=>l.includes(s.id)),[l,r]),P=React.useCallback(()=>{a.length>0?i(___default.default.cloneDeep(a)):(i([]),antd.message.error(n("CopyEmptyInPointCloud")))},[l,r,C.language]),D=React.useCallback(()=>{if(o.length===0){antd.message.error(n("PasteEmptyInPointCloud"));return}const s=x(o),u=e=>{p(e),d==null||d(e),i([]),f(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiPaste,e)};if(s)antd.Modal.confirm({title:n("HasDuplicateIDHeader"),content:n("HasDuplicateIDMsg"),onOk:()=>{const e=c.filter(g=>!o.find(I=>I.trackID===g.trackID)).concat(o);u(e)}});else{const e=[...r,...o];u(e)}},[o,r,C.language]);return{copySelectedBoxes:P,pasteSelectedBoxes:D,copiedBoxes:o,selectedBoxes:a}};exports.useBoxes=useBoxes;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__async=(s,r,t)=>new Promise((u,a)=>{var e=i=>{try{n(t.next(i))}catch(l){a(l)}},d=i=>{try{n(t.throw(i))}catch(l){a(l)}},n=i=>i.done?u(i.value):Promise.resolve(i.value).then(e,d);n((t=t.apply(s,r)).next())});const useHighlight=({currentData:s})=>{var r;const{mainViewInstance:t,topViewInstance:u,pointCloudBoxList:a,highlight2DDataList:e,setHighlight2DDataList:d}=React.useContext(PointCloudContext.PointCloudContext),n=(r=s==null?void 0:s.mappingImgList)!=null?r:[],i=(o,h,f)=>__async(void 0,null,function*(){var p;let g=[...e];if(e.find(c=>c.url===o)?g=e.filter(c=>c.url!==o):g.push({url:o,fallbackUrl:h,calib:f}),d(g),!t||(n==null?void 0:n.length)===0)return;const v=t.pointCloudObject;if(!v)return;const m=yield t.getHighlightIndexByMappingImgList({mappingImgList:g,points:v.geometry.attributes.position.array}),C=yield t.highlightOriginPointCloud(a,m);C&&((p=u==null?void 0:u.pointCloudInstance)==null||p.updateColor(C))}),l=React.useCallback(o=>e.findIndex(h=>h.url===o)>=0,[e]);return{toggle2dVisible:i,isHighlightVisible:l}};exports.useHighlight=useHighlight;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__async=(s,u,t)=>new Promise((g,a)=>{var n=i=>{try{o(t.next(i))}catch(l){a(l)}},d=i=>{try{o(t.throw(i))}catch(l){a(l)}},o=i=>i.done?g(i.value):Promise.resolve(i.value).then(n,d);o((t=t.apply(s,u)).next())});const useHighlight=({currentData:s})=>{var u;const{mainViewInstance:t,topViewInstance:g,pointCloudBoxList:a,highlight2DDataList:n,setHighlight2DDataList:d}=React.useContext(PointCloudContext.PointCloudContext),o=(u=s==null?void 0:s.mappingImgList)!=null?u:[],i=(r,c,C)=>__async(void 0,null,function*(){var p;let h=[...n];if(n.find(e=>e.url===r)?h=n.filter(e=>e.url!==r):h.push({url:r,fallbackUrl:c,calib:C}),d(h),!t||(o==null?void 0:o.length)===0)return;const v=t.pointCloudObject;if(!v)return;const f=yield t.getHighlightIndexByMappingImgList({mappingImgList:h,points:v.geometry.attributes.position.array});try{const e=yield t.highlightOriginPointCloud(a,f);e&&((p=g==null?void 0:g.pointCloudInstance)==null||p.updateColor(e))}catch(e){console.error("toggle2dVisible highlightOriginPointCloud error:",e)}}),l=React.useCallback(r=>n.findIndex(c=>c.url===r)>=0,[n]);return{toggle2dVisible:i,isHighlightVisible:l}};exports.useHighlight=useHighlight;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,n,s)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,__spreadValues=(e,n)=>{for(var s in n||(n={}))__hasOwnProp.call(n,s)&&__defNormalProp(e,s,n[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(n))__propIsEnum.call(n,s)&&__defNormalProp(e,s,n[s]);return e};const useHistory=()=>{const{history:e,setPointCloudResult:n,setSelectedIDs:s,pointCloudBoxList:L,pointCloudSphereList:y,setPointCloudSphereList:g,mainViewInstance:u,topViewInstance:d,polygonList:c,setPolygonList:f,lineList:p,setLineList:C,syncAllViewPointCloudColor:P,segmentation:a}=React.useContext(PointCloudContext.PointCloudContext),x=({newBoxParams:t,newPolygon:o,newLine:i,newSphereParams:l})=>{const r={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:y};t&&(r.pointCloudBoxList=L.concat(t)),o&&(r.polygonList=c.concat(o)),i&&(r.lineList=p.concat(i)),l&&(r.pointCloudSphereList=y.concat(l)),e.pushHistory(r)},v=t=>{const o={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:y,segmentation:a};t.pointCloudBoxList&&(o.pointCloudBoxList=t.pointCloudBoxList),t.polygonList&&(o.polygonList=t.polygonList),t.lineList&&(o.lineList=t.lineList),t.pointCloudSphereList&&(o.pointCloudSphereList=t.pointCloudSphereList),t.segmentation&&(o.segmentation=t.segmentation),e.pushHistory(o)},S=t=>{if(p.find(i=>i.id===t.id)){const i=p.map(l=>l.id===t.id?t:__spreadValues({},l));e.pushHistory({lineList:i}),C(i)}},_=t=>{if(c.find(i=>i.id===t.id)){const i=c.map(l=>l.id===t.id?t:__spreadValues({},l));e.pushHistory({pointCloudBoxList:L,polygonList:i}),f(i)}},H=({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i})=>{e.initRecord({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i,lineList:p},!0)},h=t=>{if(!t)return;const{pointCloudBoxList:o=[],polygonList:i=[],lineList:l=[],pointCloudSphereList:r=[]}=t;o&&(L.length!==o.length&&s(),u==null||u.clearAllBox(),u==null||u.generateBoxes(o),n(o),P(o)),r&&(y.length!==r.length&&s(),u==null||u.clearAllSphere(),u==null||u.generateSpheres(r),g(r)),i&&f(i),l&&C(l),d==null||d.updatePolygonList(o!=null?o:[],i!=null?i:[]),d==null||d.updateLineList(l!=null?l:[]),d==null||d.updatePointList(r)};return{addHistory:x,pushHistoryWithList:v,initHistory:H,pushHistoryUnderUpdatePolygon:_,pushHistoryUnderUpdateLine:S,redo:()=>{h(e.redo())},undo:()=>{h(e.undo())}}};exports.useHistory=useHistory;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,n,s)=>n in i?__defProp(i,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[n]=s,__spreadValues=(i,n)=>{for(var s in n||(n={}))__hasOwnProp.call(n,s)&&__defNormalProp(i,s,n[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(n))__propIsEnum.call(n,s)&&__defNormalProp(i,s,n[s]);return i};const useHistory=()=>{const{history:i,setPointCloudResult:n,setSelectedIDs:s,pointCloudBoxList:L,pointCloudSphereList:y,setPointCloudSphereList:h,mainViewInstance:d,topViewInstance:u,polygonList:c,setPolygonList:f,lineList:p,setLineList:C,syncAllViewPointCloudColor:P,segmentation:a}=React.useContext(PointCloudContext.PointCloudContext),x=({newBoxParams:t,newPolygon:o,newLine:e,newSphereParams:l})=>{const r={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:y};t&&(r.pointCloudBoxList=L.concat(t)),o&&(r.polygonList=c.concat(o)),e&&(r.lineList=p.concat(e)),l&&(r.pointCloudSphereList=y.concat(l)),i.pushHistory(r)},v=t=>{const o={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:y,segmentation:a};t.pointCloudBoxList&&(o.pointCloudBoxList=t.pointCloudBoxList),t.polygonList&&(o.polygonList=t.polygonList),t.lineList&&(o.lineList=t.lineList),t.pointCloudSphereList&&(o.pointCloudSphereList=t.pointCloudSphereList),t.segmentation&&(o.segmentation=t.segmentation),i.pushHistory(o)},S=t=>{if(p.find(e=>e.id===t.id)){const e=p.map(l=>l.id===t.id?t:__spreadValues({},l));i.pushHistory({lineList:e}),C(e)}},_=t=>{if(c.find(e=>e.id===t.id)){const e=c.map(l=>l.id===t.id?t:__spreadValues({},l));i.pushHistory({pointCloudBoxList:L,polygonList:e}),f(e)}},B=({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:e})=>{i.initRecord({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:e,lineList:p},!0)},g=t=>{if(!t)return;const{pointCloudBoxList:o=[],polygonList:e=[],lineList:l=[],pointCloudSphereList:r=[]}=t;o&&(L.length!==o.length&&s(),d==null||d.clearAllBox(),d==null||d.generateBoxes(o),n(o),P(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.UndoRedo,o)),r&&(y.length!==r.length&&s(),d==null||d.clearAllSphere(),d==null||d.generateSpheres(r),h(r)),e&&f(e),l&&C(l),u==null||u.updatePolygonList(o!=null?o:[],e!=null?e:[]),u==null||u.updateLineList(l!=null?l:[]),u==null||u.updatePointList(r)};return{addHistory:x,pushHistoryWithList:v,initHistory:B,pushHistoryUnderUpdatePolygon:_,pushHistoryUnderUpdateLine:S,redo:()=>{g(i.redo())},undo:()=>{g(i.undo())}}};exports.useHistory=useHistory;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,s)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,__spreadValues=(e,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(e,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(e,s,t[s]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,s)=>new Promise((d,o)=>{var u=p=>{try{c(s.next(p))}catch(h){o(h)}},P=p=>{try{c(s.throw(p))}catch(h){o(h)}},c=p=>p.done?d(p.value):Promise.resolve(p.value).then(u,P);c((s=s.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,s,d,o)=>{const{x:u,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,p={center:{x:u,y:P,z:c},id:e.id},h=d?__spreadValues(__spreadValues({},d),p):__spreadProps(__spreadValues({},p),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,s,d,o,u)=>{let P=e.pointList.map(m=>lbUtils.PointCloudUtils.transferCanvas2World(m,t)),c=0,p=1,h={};if(s){const m=s.getSensesPointZAxisInPolygon(P,void 0,u);u&&m.fittedCoordinates.length>0&&(P=m.fittedCoordinates),c=(m.maxZ+m.minZ)/2,p=m.maxZ-m.minZ,h={count:m.zCount}}const[y,b,T]=P,U=lbAnnotation.MathUtils.getLineCenterPoint([y,T]),I=lbAnnotation.MathUtils.getLineLength(y,b),D=lbAnnotation.MathUtils.getLineLength(b,T),R=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,p=d.depth);const V={center:{x:U.x,y:U.y,z:c},width:u?D+INTELLIGENT_FIT_MARGIN:D,height:u?I+INTELLIGENT_FIT_MARGIN:I,depth:p,rotation:R,id:e.id},_=__spreadValues(d?__spreadValues(__spreadValues({},d),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);o&&Object.assign(_,o);const k=P.map(m=>lbUtils.PointCloudUtils.transferWorld2Canvas(m,t));return{boxParams:_,newPointList:k}},sideViewPoint2PointCloud=(e,t,s)=>{const d={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x-d.x,y:s.center.y,z:s.center.z-d.y}})},sideViewPolygon2PointCloud=(e,t,s,d)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),U={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},I=lbAnnotation.MathUtils.getLineLength(o,u),D=lbAnnotation.MathUtils.getLineLength(c,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_,{newBoxParams:m}=d.getNewBoxBySideUpdate(U,k,R,s);return m},backViewPoint2PointCloud=(e,t,s)=>{const d={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x,y:s.center.y-d.x,z:s.center.z-d.y}})},backViewPolygon2PointCloud=(e,t,s,d)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),U={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},I=lbAnnotation.MathUtils.getLineLength(o,u),D=lbAnnotation.MathUtils.getLineLength(c,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_;let{newBoxParams:m}=d.getNewBoxByBackUpdate(U,k,R,s);return m},syncSideViewByPoint=(e,t,s,d,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(d,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,s,d)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(d,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxSidePolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,s,d,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(d,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,s,d)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(d,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxBackPolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,s,d)=>{if(!s||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),d.render();const{toolInstance:o,pointCloudInstance:u}=s,{point2d:P}=u.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(p=>p.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,s,d)=>{var o,u;if(!s||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=s,{polygon2d:p}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],y=h.find(b=>b.id===t.id);y?(y.pointList=p,y.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(u=e.valid)!=null?u:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:s,backViewInstance:d,mainViewInstance:o,addPointCloudBox:u,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:p,pointCloudBoxList:h,pointCloudSphereList:y,hideAttributes:b,setHighlight2DDataList:T,cuboidBoxIn2DView:U,imageSizes:I}=e,{addHistory:D,initHistory:R,pushHistoryUnderUpdatePolygon:V}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{getPointCloudSphereByID:k,updatePointCloudSphere:m,selectedSphere:N}=useSphere.useSphere(),{currentData:j,config:L}=ctx.useSelector(n=>{const{stepList:i,step:a,imgList:l,imgIndex:r}=n.annotation;return{currentData:l[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(a,i).config)}}),A=ctx.useDispatch(),tt=ahooks.useLatest(U),W=n=>{const{enableAutoMap2DRect:i=!1}=L;if(!tt.current||i){const{mappingImgList:a=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:n,mappingImgList:a,imageSizes:I})}},{selectedBox:S,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),X=S==null?void 0:S.info;if(!t||!s||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},nt=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:n,size:i,zoom:a,trackConfigurable:l})=>{var r;const C={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const f=topViewPoint2PointCloud(n,i,G,void 0,C);c(n.id);const g=P(f);q(PointCloudView.Top,n,f,a,g,L),D({newSphereParams:f})},lt=({polygon:n,size:i,imgList:a,trackConfigurable:l,zoom:r,intelligentFit:C})=>{var f,g,v;const w={attribute:(f=t.toolInstance.defaultAttribute)!=null?f:""};l===!0&&Object.assign(w,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:y})});const z=t==null?void 0:t.toolInstance,B=__spreadValues({},n);let{boxParams:x,newPointList:O}=topViewPolygon2PointCloud(B,i,G,void 0,w,C);x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[x],stepConfig:L,action:"viewUpdateBox"}))[0],C&&(O==null?void 0:O.length)&&(B.pointList=O);const Q=b.includes(B.attribute);W(x);const E=u(x),F=(g=e==null?void 0:e.polygonList)!=null?g:[];x.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((L==null?void 0:L.secondaryAttributeConfigurable)?(v=L==null?void 0:L.inputList)!=null?v:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],F),Q?c([]):(c(x.id),z.selection.setSelectedIDs(B.id),M({omitView:PointCloudView.Top,polygon:B,boxParams:x,zoom:r,newPointCloudBoxList:E}),C&&synchronizeTopView(x,B,t,o)),D({newBoxParams:x})},rt=n=>{const{boxID:i,imageName:a,width:l,height:r,x:C,y:f}=n,g=h.find(x=>x.id===i);if(!(g==null?void 0:g.rects)||!g.rects.find(x=>x.imageName===a))return;const w=g.rects.map(x=>x.imageName===a?__spreadProps(__spreadValues({},x),{width:l,height:r,x:C,y:f}):x),z=__spreadProps(__spreadValues({},g),{rects:w}),B=h.map(x=>x.id===i?z:x);return t==null||t.updatePolygonList(B!=null?B:[]),B},at=n=>{const{boxID:i,imageName:a}=n,l=h.find(g=>g.id===i);if(!(l==null?void 0:l.rects))return;const r=l.rects.filter(g=>g.imageName!==a),C=__spreadProps(__spreadValues({},l),{rects:r}),f=h.map(g=>g.id===i?C:g);return t==null||t.updatePolygonList(f!=null?f:[]),f},dt=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:a,newSphereList:l})=>{var r;const C=t==null?void 0:t.toolInstance;if(!(p.length===0||!C)){if(n||(S==null?void 0:S.info)){const f=n!=null?n:S==null?void 0:S.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(p[0]);const g=C.selectedPolygon;if(p.length===1&&f){M({omitView:PointCloudView.Top,polygon:g,boxParams:f,newPointCloudBoxList:i});return}}if((a||N)&&p.length===1){const f=a!=null?a:N;C.setSelectedID(p[0]);const g=C.selectedPoint;f&&q(PointCloudView.Top,g,f,void 0,l,L)}}},Y=(n,i,a)=>{if(X){let l,r;switch(a){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(r=l(n,i,X,s.pointCloudInstance),o){const{count:w}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:w})}const f=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:L,action:"viewUpdateBox"}))[0],g=r.valid!==f.valid;r=f;const v=ot(r);return r=v.find(w=>w.id===r.id),M({omitView:g?void 0:a,polygon:n,boxParams:r,newPointCloudBoxList:v}),v}},K=(n,i,a)=>{if(N){let l,r;switch(a){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}r=l(n,i,N);const C=m(r);return q(a,n,r,void 0,C,L),C}},ut=(n,i)=>{K(n,i,PointCloudView.Side)},ct=(n,i)=>{K(n,i,PointCloudView.Back)},pt=(n,i)=>{Y(n,i,PointCloudView.Side)},Pt=(n,i)=>{Y(n,i,PointCloudView.Back)},Ct=(n,i)=>{const a=k(n.id),l=topViewPoint2PointCloud(n,i,G,a),r=m(l);q(PointCloudView.Top,n,l,void 0,r,L)},gt=(n,i)=>{if(_){const l=__spreadValues({},n[0].newPolygon);l.pointList=l.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,i)),V(l);return}let a=n.map(({newPolygon:l})=>{const r=et(l.id),{boxParams:C}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,r);return C});if(a=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:a,stepConfig:L,action:"viewUpdateBox"})),a.length===1){const{newPolygon:l}=n[0],r=Z(a);M({polygon:l,boxParams:a[0],newPointCloudBoxList:r})}else{const l=Z(a);l&&e.syncAllViewPointCloudColor(l)}},ft=n=>{var i,a,l,r,C;if(S){const f=Number(n.widthDefault),g=Number(n.depthDefault),v=Number(n.heightDefault),w=S==null?void 0:S.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(H=>(H==null?void 0:H.trackID)===w),x={width:(l=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:l.width,height:(C=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:C.height},O=B.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,x)),J=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(O,v,f),Q=J[0],E=J[2],F=lbAnnotation.MathUtils.getLineCenterPoint([Q,E]),ht=S.info.center.z-S.info.depth/2,$=__spreadProps(__spreadValues({},S.info),{center:{x:F.x,y:F.y,z:ht+g/2},width:f,height:v,depth:g,valid:!0}),vt=Z([$]);M({omitView:PointCloudView["3D"],polygon:B,boxParams:$,newPointCloudBoxList:vt})}},q=(n,i,a,l,r,C)=>__async(void 0,null,function*(){const f=j==null?void 0:j.url,g={[PointCloudView.Side]:()=>{syncSideViewByPoint(a,i,s,f,C)},[PointCloudView.Back]:()=>{d&&syncBackViewByPoint(a,i,d,f,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(a,i,t,o)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),l&&(o==null||o.updateCameraZoom(l)),nt(a)}),M=n=>__async(void 0,null,function*(){const{omitView:i,polygon:a,boxParams:l,zoom:r,newPointCloudBoxList:C}=n,f=j==null?void 0:j.url;C&&(yield e.syncAllViewPointCloudColor(C));const g={[PointCloudView.Side]:()=>{synchronizeSideView(l,a,s,f)},[PointCloudView.Back]:()=>{d&&synchronizeBackView(l,a,d,f)},[PointCloudView.Top]:()=>{synchronizeTopView(l,a,t,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),r&&(o==null||o.updateCameraZoom(r)),it(l)});return{topViewAddSphere:st,topViewAddBox:lt,topViewSelectedChanged:dt,topViewUpdatePoint:Ct,sideViewUpdatePoint:ut,backViewUpdatePoint:ct,topViewUpdateBox:gt,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(i=j){var a,l,r,C,f,g;if(!(i==null?void 0:i.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(i.url,(a=L==null?void 0:L.radius)!=null?a:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],w=[],z=[],B=[];o.updateTopCamera();const x=(r=(l=index.jsonParser(i.result))==null?void 0:l.valid)!=null?r:!0;if(e.setPointCloudValid(x),(C=e.sideViewInstance)==null||C.clearAllData(),(f=e.backViewInstance)==null||f.clearAllData(),i.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(L==null?void 0:L.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,L,v);const O=index.jsonParser(i.result);O[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,i.result=JSON.stringify(O),e.setPointCloudResult(v)}z=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),w=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(g=L==null?void 0:L.radius)!=null?g:DEFAULT_RADIUS}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(B),yield e.syncAllViewPointCloudColor(v,[])}R({pointCloudBoxList:v,polygonList:z,lineList:w,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:ft,generateRects:W,update2DViewRect:rt,remove2DViewRect:at}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,s)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,__spreadValues=(e,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(e,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(e,s,t[s]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,s)=>new Promise((a,o)=>{var u=p=>{try{c(s.next(p))}catch(h){o(h)}},P=p=>{try{c(s.throw(p))}catch(h){o(h)}},c=p=>p.done?a(p.value):Promise.resolve(p.value).then(u,P);c((s=s.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,s,a,o)=>{const{x:u,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,p={center:{x:u,y:P,z:c},id:e.id},h=a?__spreadValues(__spreadValues({},a),p):__spreadProps(__spreadValues({},p),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,s,a,o,u)=>{let P=e.pointList.map(m=>lbUtils.PointCloudUtils.transferCanvas2World(m,t)),c=0,p=1,h={};if(s){const m=s.getSensesPointZAxisInPolygon(P,void 0,u);u&&m.fittedCoordinates.length>0&&(P=m.fittedCoordinates),c=(m.maxZ+m.minZ)/2,p=m.maxZ-m.minZ,h={count:m.zCount}}const[y,b,z]=P,D=lbAnnotation.MathUtils.getLineCenterPoint([y,z]),U=lbAnnotation.MathUtils.getLineLength(y,b),O=lbAnnotation.MathUtils.getLineLength(b,z),I=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(c=a.center.z,p=a.depth);const V={center:{x:D.x,y:D.y,z:c},width:u?O+INTELLIGENT_FIT_MARGIN:O,height:u?U+INTELLIGENT_FIT_MARGIN:U,depth:p,rotation:I,id:e.id},_=__spreadValues(a?__spreadValues(__spreadValues({},a),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);o&&Object.assign(_,o);const k=P.map(m=>lbUtils.PointCloudUtils.transferWorld2Canvas(m,t));return{boxParams:_,newPointList:k}},sideViewPoint2PointCloud=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x-a.x,y:s.center.y,z:s.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,s,a)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),D={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},U=lbAnnotation.MathUtils.getLineLength(o,u),O=lbAnnotation.MathUtils.getLineLength(c,p),I=U-O,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_,{newBoxParams:m}=a.getNewBoxBySideUpdate(D,k,I,s);return m},backViewPoint2PointCloud=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x,y:s.center.y-a.x,z:s.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,s,a)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),D={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},U=lbAnnotation.MathUtils.getLineLength(o,u),O=lbAnnotation.MathUtils.getLineLength(c,p),I=U-O,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_;let{newBoxParams:m}=a.getNewBoxByBackUpdate(D,k,I,s);return m},syncSideViewByPoint=(e,t,s,a,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(a,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxSidePolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,s,a,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(a,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxBackPolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,s,a)=>{if(!s||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:u}=s,{point2d:P}=u.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(p=>p.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,s,a)=>{var o,u;if(!s||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=s,{polygon2d:p}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],y=h.find(b=>b.id===t.id);y?(y.pointList=p,y.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(u=e.valid)!=null?u:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:s,backViewInstance:a,mainViewInstance:o,addPointCloudBox:u,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:p,pointCloudBoxList:h,pointCloudSphereList:y,hideAttributes:b,setHighlight2DDataList:z,cuboidBoxIn2DView:D,imageSizes:U,history:O}=e,{addHistory:I,initHistory:V,pushHistoryUnderUpdatePolygon:_}=useHistory.useHistory(),{selectedPolygon:k}=usePolygon.usePolygon(),{getPointCloudSphereByID:m,updatePointCloudSphere:X,selectedSphere:N}=useSphere.useSphere(),{currentData:j,config:L}=ctx.useSelector(n=>{const{stepList:i,step:d,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,i).config)}}),A=ctx.useDispatch(),ot=ahooks.useLatest(D),W=n=>{const{enableAutoMap2DRect:i=!1}=L;if(!ot.current||i){const{mappingImgList:d=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:n,mappingImgList:d,imageSizes:U})}},{selectedBox:S,updateSelectedBox:et,updateSelectedBoxes:Z,getPointCloudByID:it}=useSingleBox.useSingleBox({generateRects:W}),Y=S==null?void 0:S.info;if(!t||!s||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,nt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},st=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},rt=({newPoint:n,size:i,zoom:d,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const f=topViewPoint2PointCloud(n,i,G,void 0,g);c(n.id);const C=P(f);H(PointCloudView.Top,n,f,d,C,L),I({newSphereParams:f})},lt=({polygon:n,size:i,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var f,C,x;const w={attribute:(f=t.toolInstance.defaultAttribute)!=null?f:""};r===!0&&Object.assign(w,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:y})});const T=t==null?void 0:t.toolInstance,B=__spreadValues({},n);let{boxParams:v,newPointList:R}=topViewPolygon2PointCloud(B,i,G,void 0,w,g);v=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[v],stepConfig:L,action:"viewUpdateBox"}))[0],g&&(R==null?void 0:R.length)&&(B.pointList=R);const Q=b.includes(B.attribute);W(v);const E=u(v),q=(C=e==null?void 0:e.polygonList)!=null?C:[];v.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((L==null?void 0:L.secondaryAttributeConfigurable)?(x=L==null?void 0:L.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],q),Q?c([]):(c(v.id),T.selection.setSelectedIDs(B.id),M({omitView:PointCloudView.Top,polygon:B,boxParams:v,zoom:l,newPointCloudBoxList:E}),g&&synchronizeTopView(v,B,t,o)),I({newBoxParams:v})},dt=n=>{const{boxID:i,imageName:d,width:r,height:l,x:g,y:f}=n,C=h.find(v=>v.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(v=>v.imageName===d))return;const w=C.rects.map(v=>v.imageName===d?__spreadProps(__spreadValues({},v),{width:r,height:l,x:g,y:f}):v),T=__spreadProps(__spreadValues({},C),{rects:w}),B=h.map(v=>v.id===i?T:v);return t==null||t.updatePolygonList(B!=null?B:[]),B},at=n=>{const{boxID:i,imageName:d}=n,r=h.find(C=>C.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(C=>C.imageName!==d),g=__spreadProps(__spreadValues({},r),{rects:l}),f=h.map(C=>C.id===i?g:C);return t==null||t.updatePolygonList(f!=null?f:[]),f},ut=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:d,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(p.length===0||!g)){if(n||(S==null?void 0:S.info)){const f=n!=null?n:S==null?void 0:S.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(p[0]);const C=g.selectedPolygon;if(p.length===1&&f){M({omitView:PointCloudView.Top,polygon:C,boxParams:f,newPointCloudBoxList:i});return}}if((d||N)&&p.length===1){const f=d!=null?d:N;g.setSelectedID(p[0]);const C=g.selectedPoint;f&&H(PointCloudView.Top,C,f,void 0,r,L)}}},K=(n,i,d)=>{if(Y){let r,l;switch(d){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}if(l=r(n,i,Y,s.pointCloudInstance),o){const{count:w}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:w})}const f=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:L,action:"viewUpdateBox"}))[0],C=l.valid!==f.valid;l=f;const x=et(l);return l=x.find(w=>w.id===l.id),M({omitView:C?void 0:d,polygon:n,boxParams:l,newPointCloudBoxList:x}),x}},$=(n,i,d)=>{if(N){let r,l;switch(d){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(n,i,N);const g=X(l);return H(d,n,l,void 0,g,L),g}},ct=(n,i)=>{$(n,i,PointCloudView.Side)},pt=(n,i)=>{$(n,i,PointCloudView.Back)},Pt=(n,i)=>{K(n,i,PointCloudView.Side)},gt=(n,i)=>{K(n,i,PointCloudView.Back)},Ct=(n,i)=>{const d=m(n.id),r=topViewPoint2PointCloud(n,i,G,d),l=X(r);H(PointCloudView.Top,n,r,void 0,l,L)},ft=(n,i)=>{if(k){const r=__spreadValues({},n[0].newPolygon);r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,i)),_(r);return}let d=n.map(({newPolygon:r})=>{const l=it(r.id),{boxParams:g}=topViewPolygon2PointCloud(r,i,t.pointCloudInstance,l);return g});if(d=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:L,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=n[0],l=Z(d);M({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=Z(d);r&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},ht=n=>{var i,d,r,l,g;if(S){const f=Number(n.widthDefault),C=Number(n.depthDefault),x=Number(n.heightDefault),w=S==null?void 0:S.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(F=>(F==null?void 0:F.trackID)===w),v={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},R=B.pointList.map(F=>lbUtils.PointCloudUtils.transferCanvas2World(F,v)),J=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(R,x,f),Q=J[0],E=J[2],q=lbAnnotation.MathUtils.getLineCenterPoint([Q,E]),xt=S.info.center.z-S.info.depth/2,tt=__spreadProps(__spreadValues({},S.info),{center:{x:q.x,y:q.y,z:xt+C/2},width:f,height:x,depth:C,valid:!0}),vt=Z([tt]);M({omitView:PointCloudView["3D"],polygon:B,boxParams:tt,newPointCloudBoxList:vt})}},H=(n,i,d,r,l,g)=>__async(void 0,null,function*(){const f=j==null?void 0:j.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,i,s,f,g)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(d,i,a,f,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,i,t,o)}};Object.keys(C).forEach(x=>{x!==n&&C[x]()}),r&&(o==null||o.updateCameraZoom(r)),st(d)}),M=n=>__async(void 0,null,function*(){const{omitView:i,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:g}=n,f=j==null?void 0:j.url;g&&(yield e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,g));const C={[PointCloudView.Side]:()=>{synchronizeSideView(r,d,s,f)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(r,d,a,f)},[PointCloudView.Top]:()=>{synchronizeTopView(r,d,t,o)}};Object.keys(C).forEach(x=>{x!==i&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),nt(r)});return{topViewAddSphere:rt,topViewAddBox:lt,topViewSelectedChanged:ut,topViewUpdatePoint:Ct,sideViewUpdatePoint:ct,backViewUpdatePoint:pt,topViewUpdateBox:ft,sideViewUpdateBox:Pt,backViewUpdateBox:gt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(i=j){var d,r,l,g,f,C;if(!(i==null?void 0:i.url)||!o)return;z([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(i.url,(d=L==null?void 0:L.radius)!=null?d:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],w=[],T=[],B=[];o.updateTopCamera();const v=(l=(r=index.jsonParser(i.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(v),(g=e.sideViewInstance)==null||g.clearAllData(),(f=e.backViewInstance)==null||f.clearAllData(),i.result){if(x=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(x==null?void 0:x.length)>0&&i.isPreResult&&(L==null?void 0:L.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(i.url,L,x);const R=index.jsonParser(i.result);R[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=x,i.result=JSON.stringify(R),e.setPointCloudResult(x)}T=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),w=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(C=L==null?void 0:L.radius)!=null?C:DEFAULT_RADIUS}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(B),yield e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,x,[])}V({pointCloudBoxList:x,polygonList:T,lineList:w,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:ht,generateRects:W,update2DViewRect:dt,remove2DViewRect:at}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),usePointCloudViews=require("./usePointCloudViews.js"),useSingleBox=require("./useSingleBox.js"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),ahooks=require("ahooks");const{ERotateDirection}=lbAnnotation.cAnnotation,useRotate=({currentData:o})=>{const t=React.useContext(PointCloudContext.PointCloudContext),{selectedBox:i,updateSelectedBox:a}=useSingleBox.useSingleBox(),{run:c}=ahooks.useThrottleFn(s=>{const{topViewInstance:l,mainViewInstance:n,syncAllViewPointCloudColor:d}=t;if(!l||!n)return;const{pointCloud2dOperation:r}=l,e=i==null?void 0:i.info;if(!e||!(o==null?void 0:o.url)||!t.backViewInstance)return;const C=a({rotation:lbUtils.PointCloudUtils.restrictAngleRange(e.rotation+Number(Math.PI*s)/180)});r.rotatePolygon(s,ERotateDirection.Anticlockwise);const u=r.selectedPolygon;n.generateBox(e),d(C),usePointCloudViews.synchronizeSideView(e,u,t.sideViewInstance,o.url),usePointCloudViews.synchronizeBackView(e,u,t.backViewInstance,o.url),n.render()},{wait:800});return{updateRotate:c}};exports.useRotate=useRotate;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),usePointCloudViews=require("./usePointCloudViews.js"),useSingleBox=require("./useSingleBox.js"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),ahooks=require("ahooks");const{ERotateDirection}=lbAnnotation.cAnnotation,useRotate=({currentData:o})=>{const t=React.useContext(PointCloudContext.PointCloudContext),{selectedBox:i,updateSelectedBox:a}=useSingleBox.useSingleBox(),{run:c}=ahooks.useThrottleFn(r=>{const{topViewInstance:l,mainViewInstance:n,syncAllViewPointCloudColor:d}=t;if(!l||!n)return;const{pointCloud2dOperation:s}=l,e=i==null?void 0:i.info;if(!e||!(o==null?void 0:o.url)||!t.backViewInstance)return;const C=a({rotation:lbUtils.PointCloudUtils.restrictAngleRange(e.rotation+Number(Math.PI*r)/180)});s.rotatePolygon(r,ERotateDirection.Anticlockwise);const u=s.selectedPolygon;n.generateBox(e),d(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate,C),usePointCloudViews.synchronizeSideView(e,u,t.sideViewInstance,o.url),usePointCloudViews.synchronizeBackView(e,u,t.backViewInstance,o.url),n.render()},{wait:800});return{updateRotate:c}};exports.useRotate=useRotate;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),usePointCloudViews=require("./usePointCloudViews.js"),useSingleBox=require("./useSingleBox.js"),PointCloudContext=require("../PointCloudContext.js"),ahooks=require("ahooks"),lbUtils=require("@labelbee/lb-utils");const useRotateEdge=({currentData:t})=>{const o=React.useContext(PointCloudContext.PointCloudContext),{selectedBox:l,updateSelectedBox:d}=useSingleBox.useSingleBox(),{run:c}=ahooks.useThrottleFn(a=>{const{topViewInstance:r,mainViewInstance:i,syncAllViewPointCloudColor:P}=o;if(!r||!i)return;const{pointCloud2dOperation:s}=r,e=l==null?void 0:l.info;if(!e||!(t==null?void 0:t.url)||!o.backViewInstance)return;const n=s.selectedPolygon.pointList||[],g=n.shift();n.push(g);const C=d({newPointList:n,rotation:lbUtils.PointCloudUtils.restrictAngleRange(e.rotation+Number(Math.PI*a)/180),width:e.height,height:e.width});s.rotatePolygonEdge(n);const u=s.selectedPolygon;i.generateBox(e),P(C),usePointCloudViews.synchronizeSideView(e,u,o.sideViewInstance,t.url),usePointCloudViews.synchronizeBackView(e,u,o.backViewInstance,t.url),i.render()},{wait:800});return{updateRotateEdge:c}};exports.useRotateEdge=useRotateEdge;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),usePointCloudViews=require("./usePointCloudViews.js"),useSingleBox=require("./useSingleBox.js"),PointCloudContext=require("../PointCloudContext.js"),ahooks=require("ahooks"),lbUtils=require("@labelbee/lb-utils");const useRotateEdge=({currentData:t})=>{const o=React.useContext(PointCloudContext.PointCloudContext),{selectedBox:r,updateSelectedBox:d}=useSingleBox.useSingleBox(),{run:a}=ahooks.useThrottleFn(c=>{const{topViewInstance:l,mainViewInstance:i}=o;if(!l||!i)return;const{pointCloud2dOperation:s}=l,e=r==null?void 0:r.info;if(!e||!(t==null?void 0:t.url)||!o.backViewInstance)return;const n=s.selectedPolygon.pointList||[],g=n.shift();n.push(g),d({newPointList:n,rotation:lbUtils.PointCloudUtils.restrictAngleRange(e.rotation+Number(Math.PI*c)/180),width:e.height,height:e.width}),s.rotatePolygonEdge(n);const u=s.selectedPolygon;i.generateBox(e),usePointCloudViews.synchronizeSideView(e,u,o.sideViewInstance,t.url),usePointCloudViews.synchronizeBackView(e,u,o.backViewInstance,t.url),i.render()},{wait:800});return{updateRotateEdge:a}};exports.useRotateEdge=useRotateEdge;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),_=require("lodash"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js");function _interopDefaultLegacy(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(l,t,d)=>t in l?__defProp(l,t,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[t]=d,__spreadValues=(l,t)=>{for(var d in t||(t={}))__hasOwnProp.call(t,d)&&__defNormalProp(l,d,t[d]);if(__getOwnPropSymbols)for(var d of __getOwnPropSymbols(t))__propIsEnum.call(t,d)&&__defNormalProp(l,d,t[d]);return l},__spreadProps=(l,t)=>__defProps(l,__getOwnPropDescs(t));const{ESortDirection}=lbAnnotation.cAnnotation,useSingleBox=l=>{const{pointCloudBoxList:t,setPointCloudResult:d,topViewInstance:a,backViewInstance:I,sideViewInstance:m,selectedIDs:P,selectedID:b,mainViewInstance:f,setSelectedIDs:N,syncAllViewPointCloudColor:O,polygonList:j,pointCloudPattern:B,rectList:h,updateRectIn2DView:Z,removeRectIn2DView:k,addRectIn2DView:A,updateRectListByReducer:D}=React.useContext(PointCloudContext.PointCloudContext),{selectedPolygon:p,updateSelectedPolygon:M,updatePolygonValidByID:q,deletePolygon:H}=usePolygon.usePolygon(),{pushHistoryWithList:R}=useHistory.useHistory(),r=React.useMemo(()=>{const e=t.findIndex(n=>n.id===b);if(e>-1)return{info:t[e],index:e}},[b,t]),S=React.useCallback(e=>{var n;if(r==null?void 0:r.info){(n=l==null?void 0:l.generateRects)==null||n.call(l,e),t.splice(r.index,1,___default.default.merge(r.info,e));const o=___default.default.cloneDeep(t);return d(o),R({pointCloudBoxList:o}),o}return t},[b,t]),T=React.useCallback((e,n)=>{const o=t.findIndex(i=>i.id===n);if(o>-1){t.splice(o,1,___default.default.merge(t[o],e));const i=___default.default.cloneDeep(t);return d(i),i}return t},[t]),y=React.useCallback(e=>{a==null||a.pointCloud2dOperation.setPolygonValidAndRender(e,!0),m==null||m.pointCloud2dOperation.setPolygonValidAndRender(e,!0),I==null||I.pointCloud2dOperation.setPolygonValidAndRender(e,!0)},[a,m,I]),K=React.useCallback(()=>{if(r==null?void 0:r.info){const{id:e,valid:n=!0}=r.info,o=S({valid:!n});O(o),y(e)}p&&(M(__spreadProps(__spreadValues({},p),{valid:!p.valid})),a==null||a.pointCloud2dOperation.setPolygonValidAndRender(p.id,!0))},[y,r,p]),U=React.useCallback(e=>{const n=t.find(o=>o.id===e);if(n){const{id:o,valid:i=!0}=n,u=T({valid:!i},o);return y(o),u}q(e)},[y,t,j]),V=React.useCallback((e=ESortDirection.ascend,n=!1)=>{if(!a||P.length>1)return;if(B!==lbAnnotation.EToolName.Rect&&B!==lbAnnotation.EToolName.Polygon){n&&document.dispatchEvent(new KeyboardEvent("keydown",{keyCode:9,shiftKey:e!==ESortDirection.ascend}));return}const{pointCloud2dOperation:o}=a,i=o.switchToNextPolygon(e);i&&N(i)},[a,B,a==null?void 0:a.toolInstance]),F=(e=!1)=>{V(ESortDirection.descend,e)},W=(e=!1)=>{V(ESortDirection.ascend,e)},L=(e,n=!0)=>{const o=t.filter(i=>i.id!==e);if(d(o),f==null||f.removeObjectByName(e,"box"),f==null||f.render(),O(o),n){const i=h.filter(s=>s.extId===e),u=new Set(i.map(s=>s.id));D(E(u))}},E=e=>(n,o)=>{let i=!1;const u=n.map(s=>e.has(s.id)?(i=!0,o(s)):s);return i?u:n},z=React.useCallback((e,n)=>{var o,i;const u=new Set((i=(o=n.mappingImgList)==null?void 0:o.map(c=>c.path))!=null?i:[]),s=new Map;e.forEach(c=>{const C=c.id;(c.rects||[]).forEach(w=>{const{imageName:x}=w;if(u.has(x)){let g=s.get(x);g||(g=new Set,s.set(x,g)),g.add(C)}})});const v=h.filter(c=>{var C;const w=c.extId,x=c.imageName;if(x!==void 0&&w!==void 0){const g=s.get(x);return(C=g==null?void 0:g.has(w))!=null?C:!1}return!1}),Y=new Set(v.map(c=>c.id));D(E(Y))},[h,k,A]),G=e=>{r&&(L(r.info.id,!1),a==null||a.pointCloud2dOperation.deletePolygon(r.info.id),z([r.info],e)),p&&(H(p.id),a==null||a.pointCloud2dOperation.deletePolygon(p.id))},J=React.useMemo(()=>t.filter(e=>P.includes(e.id)),[P,t]),Q=React.useCallback(e=>{var n;const o=___default.default.cloneDeep(t);let i=!1;for(const u of e){const s=o.findIndex(v=>v.id===u.id);if(s>-1){const v=___default.default.merge(o[s],u);(n=l==null?void 0:l.generateRects)==null||n.call(l,v),o.splice(s,1,v),f==null||f.generateBox(v),i=!0}}if(i)return d(o),R({pointCloudBoxList:o}),f==null||f.render(),o},[P,t]),X=React.useCallback(e=>t.find(n=>n.id===e),[t]);return{selectedBox:r,updateSelectedBox:S,changeSelectedBoxValid:K,changeValidByID:U,selectNextBox:W,selectPrevBox:F,deletePointCloudBox:L,selectedBoxes:J,updateSelectedBoxes:Q,getPointCloudByID:X,deleteSelectedPointCloudBoxAndPolygon:G}};exports.useSingleBox=useSingleBox;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),_=require("lodash"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js");function _interopDefaultLegacy(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(l,t,d)=>t in l?__defProp(l,t,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[t]=d,__spreadValues=(l,t)=>{for(var d in t||(t={}))__hasOwnProp.call(t,d)&&__defNormalProp(l,d,t[d]);if(__getOwnPropSymbols)for(var d of __getOwnPropSymbols(t))__propIsEnum.call(t,d)&&__defNormalProp(l,d,t[d]);return l},__spreadProps=(l,t)=>__defProps(l,__getOwnPropDescs(t));const{ESortDirection}=lbAnnotation.cAnnotation,useSingleBox=l=>{const{pointCloudBoxList:t,setPointCloudResult:d,topViewInstance:s,backViewInstance:I,sideViewInstance:m,selectedIDs:P,selectedID:B,mainViewInstance:f,setSelectedIDs:N,syncAllViewPointCloudColor:R,polygonList:j,pointCloudPattern:b,rectList:h,updateRectIn2DView:Z,removeRectIn2DView:k,addRectIn2DView:A,updateRectListByReducer:O}=React.useContext(PointCloudContext.PointCloudContext),{selectedPolygon:p,updateSelectedPolygon:T,updatePolygonValidByID:q,deletePolygon:H}=usePolygon.usePolygon(),{pushHistoryWithList:S}=useHistory.useHistory(),a=React.useMemo(()=>{const e=t.findIndex(n=>n.id===B);if(e>-1)return{info:t[e],index:e}},[B,t]),D=React.useCallback(e=>{var n;if(a==null?void 0:a.info){(n=l==null?void 0:l.generateRects)==null||n.call(l,e),t.splice(a.index,1,___default.default.merge(a.info,e));const o=___default.default.cloneDeep(t);return d(o),S({pointCloudBoxList:o}),o}return t},[B,t]),M=React.useCallback((e,n)=>{const o=t.findIndex(i=>i.id===n);if(o>-1){t.splice(o,1,___default.default.merge(t[o],e));const i=___default.default.cloneDeep(t);return d(i),i}return t},[t]),y=React.useCallback(e=>{s==null||s.pointCloud2dOperation.setPolygonValidAndRender(e,!0),m==null||m.pointCloud2dOperation.setPolygonValidAndRender(e,!0),I==null||I.pointCloud2dOperation.setPolygonValidAndRender(e,!0)},[s,m,I]),K=React.useCallback(()=>{if(a==null?void 0:a.info){const{id:e,valid:n=!0}=a.info,o=D({valid:!n});R(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid,o),y(e)}p&&(T(__spreadProps(__spreadValues({},p),{valid:!p.valid})),s==null||s.pointCloud2dOperation.setPolygonValidAndRender(p.id,!0))},[y,a,p]),U=React.useCallback(e=>{const n=t.find(o=>o.id===e);if(n){const{id:o,valid:i=!0}=n,u=M({valid:!i},o);return y(o),u}q(e)},[y,t,j]),V=React.useCallback((e=ESortDirection.ascend,n=!1)=>{if(!s||P.length>1)return;if(b!==lbAnnotation.EToolName.Rect&&b!==lbAnnotation.EToolName.Polygon){n&&document.dispatchEvent(new KeyboardEvent("keydown",{keyCode:9,shiftKey:e!==ESortDirection.ascend}));return}const{pointCloud2dOperation:o}=s,i=o.switchToNextPolygon(e);i&&N(i)},[s,b,s==null?void 0:s.toolInstance]),F=(e=!1)=>{V(ESortDirection.descend,e)},W=(e=!1)=>{V(ESortDirection.ascend,e)},L=(e,n=!0)=>{const o=t.filter(i=>i.id!==e);if(d(o),f==null||f.removeObjectByName(e,"box"),f==null||f.render(),R(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleDelete,o),n){const i=h.filter(r=>r.extId===e),u=new Set(i.map(r=>r.id));O(E(u))}},E=e=>(n,o)=>{let i=!1;const u=n.map(r=>e.has(r.id)?(i=!0,o(r)):r);return i?u:n},z=React.useCallback((e,n)=>{var o,i;const u=new Set((i=(o=n.mappingImgList)==null?void 0:o.map(c=>c.path))!=null?i:[]),r=new Map;e.forEach(c=>{const C=c.id;(c.rects||[]).forEach(w=>{const{imageName:x}=w;if(u.has(x)){let v=r.get(x);v||(v=new Set,r.set(x,v)),v.add(C)}})});const g=h.filter(c=>{var C;const w=c.extId,x=c.imageName;if(x!==void 0&&w!==void 0){const v=r.get(x);return(C=v==null?void 0:v.has(w))!=null?C:!1}return!1}),Y=new Set(g.map(c=>c.id));O(E(Y))},[h,k,A]),G=e=>{a&&(L(a.info.id,!1),s==null||s.pointCloud2dOperation.deletePolygon(a.info.id),z([a.info],e)),p&&(H(p.id),s==null||s.pointCloud2dOperation.deletePolygon(p.id))},J=React.useMemo(()=>t.filter(e=>P.includes(e.id)),[P,t]),Q=React.useCallback(e=>{var n;const o=___default.default.cloneDeep(t);let i=!1;for(const u of e){const r=o.findIndex(g=>g.id===u.id);if(r>-1){const g=___default.default.merge(o[r],u);(n=l==null?void 0:l.generateRects)==null||n.call(l,g),o.splice(r,1,g),f==null||f.generateBox(g),i=!0}}if(i)return d(o),S({pointCloudBoxList:o}),f==null||f.render(),o},[P,t]),X=React.useCallback(e=>t.find(n=>n.id===e),[t]);return{selectedBox:a,updateSelectedBox:D,changeSelectedBoxValid:K,changeValidByID:U,selectNextBox:W,selectPrevBox:F,deletePointCloudBox:L,selectedBoxes:J,updateSelectedBoxes:Q,getPointCloudByID:X,deleteSelectedPointCloudBoxAndPolygon:G}};exports.useSingleBox=useSingleBox;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js"),lbUtils=require("@labelbee/lb-utils");const{EToolName,EPolygonPattern}=lbAnnotation.cTool,useStatus=()=>{const{topViewInstance:i,sideViewInstance:r,backViewInstance:u,mainViewInstance:e,setPointCloudResult:d,setPointCloudSphereList:P,setPolygonList:C,setRectList:v,pointCloudPattern:a,setPointCloudPattern:o,syncAllViewPointCloudColor:b,globalPattern:n,setLineList:h}=React.useContext(PointCloudContext.PointCloudContext),{pushHistoryWithList:p}=useHistory.useHistory(),y=()=>{e==null||e.clearAllBox(),e==null||e.clearAllSphere(),e==null||e.render(),d([]),C([]),P([]),h([]),v([]),i==null||i.toolScheduler.clearStatusAndResult(),b([]),p({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},l=()=>{r==null||r.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()},L=c=>{if(c===a)return;const s=[i,r,u];switch(c){case EToolName.Rect:l(),s.forEach(t=>{t==null||t.switchToCanvas(EToolName.PointCloudPolygon),t==null||t.toolInstance.setPattern(EPolygonPattern.Rect)}),o(EToolName.Rect);break;case EToolName.Polygon:l(),s.forEach(t=>{t==null||t.switchToCanvas(EToolName.PointCloudPolygon),t==null||t.toolInstance.setPattern(EPolygonPattern.Normal)}),o(EToolName.Polygon);break;case EToolName.Point:l(),s.forEach(t=>{t==null||t.switchToCanvas(EToolName.Point)}),o(EToolName.Point);break;case EToolName.Line:l(),s.forEach(t=>{t==null||t.switchToCanvas(EToolName.Line)}),o(EToolName.Line);break}},w=React.useMemo(()=>n===lbUtils.EPointCloudPattern.Detection,[n]),R=React.useMemo(()=>n===lbUtils.EPointCloudPattern.Segmentation,[n]);return{clearAllResult:y,updatePointCloudPattern:L,pointCloudPattern:a,isPointCloudDetectionPattern:w,isPointCloudSegmentationPattern:R}};exports.useStatus=useStatus;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js"),lbUtils=require("@labelbee/lb-utils"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js");const{EToolName,EPolygonPattern}=lbAnnotation.cTool,useStatus=()=>{const{topViewInstance:i,sideViewInstance:s,backViewInstance:u,mainViewInstance:e,setPointCloudResult:d,setPointCloudSphereList:P,setPolygonList:C,setRectList:v,pointCloudPattern:a,setPointCloudPattern:o,syncAllViewPointCloudColor:b,globalPattern:l,setLineList:h}=React.useContext(PointCloudContext.PointCloudContext),{pushHistoryWithList:p}=useHistory.useHistory(),R=()=>{e==null||e.clearAllBox(),e==null||e.clearAllSphere(),e==null||e.render(),d([]),C([]),P([]),h([]),v([]),i==null||i.toolScheduler.clearStatusAndResult(),b(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.ClearAll,[]),p({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},n=()=>{s==null||s.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()},y=c=>{if(c===a)return;const r=[i,s,u];switch(c){case EToolName.Rect:n(),r.forEach(t=>{t==null||t.switchToCanvas(EToolName.PointCloudPolygon),t==null||t.toolInstance.setPattern(EPolygonPattern.Rect)}),o(EToolName.Rect);break;case EToolName.Polygon:n(),r.forEach(t=>{t==null||t.switchToCanvas(EToolName.PointCloudPolygon),t==null||t.toolInstance.setPattern(EPolygonPattern.Normal)}),o(EToolName.Polygon);break;case EToolName.Point:n(),r.forEach(t=>{t==null||t.switchToCanvas(EToolName.Point)}),o(EToolName.Point);break;case EToolName.Line:n(),r.forEach(t=>{t==null||t.switchToCanvas(EToolName.Line)}),o(EToolName.Line);break}},g=React.useMemo(()=>l===lbUtils.EPointCloudPattern.Detection,[l]),L=React.useMemo(()=>l===lbUtils.EPointCloudPattern.Segmentation,[l]);return{clearAllResult:R,updatePointCloudPattern:y,pointCloudPattern:a,isPointCloudDetectionPattern:g,isPointCloudSegmentationPattern:L}};exports.useStatus=useStatus;
@@ -1,5 +1,6 @@
1
1
  import { IPointCloudBox, IPointCloudBoxList, IPolygonData, IPointCloudSphereList, IPointCloudSphere, ILine, EPointCloudPattern, IPointCloudSegmentation, ICalib, ISize, IPointCloudBoxRect, IPointCloud2DRectOperationViewRect } from '@labelbee/lb-utils';
2
2
  import React, { PropsWithChildren } from 'react';
3
+ import { EPointCloudBoxRenderTrigger } from '@/utils/ToolPointCloudBoxRenderHelper';
3
4
  import { PointCloud, PointCloudAnnotation, ActionsHistory, EToolName } from '@labelbee/lb-annotation';
4
5
  import type { MapIndirectWeakSet } from './utils/map';
5
6
  interface IPointCloudContextInstances {
@@ -69,7 +70,7 @@ export interface IPointCloudContext extends IPointCloudContextInstances, IPointC
69
70
  reRender: (_displayPointCloudList: IPointCloudBoxList, _polygonList: IPolygonData[], _displaySphereList: IPointCloudSphereList, _lineList: ILine[], _segmentation: IPointCloudSegmentation[]) => void;
70
71
  attrPanelLayout: AttrPanelLayout;
71
72
  setAttrPanelLayout: (layout: AttrPanelLayout) => void;
72
- syncAllViewPointCloudColor: (newPointCloudList?: IPointCloudBox[], newHighlight2DDataList?: IHighlight2DData[]) => Promise<any>;
73
+ syncAllViewPointCloudColor: (syncByTrigger: EPointCloudBoxRenderTrigger, newPointCloudList?: IPointCloudBox[], newHighlight2DDataList?: IHighlight2DData[]) => Promise<any>;
73
74
  defaultAttribute: string;
74
75
  setDefaultAttribute: (defaultAttribute: string) => void;
75
76
  pointCloudPattern: EToolName.Rect | EToolName.Polygon | EToolName.Point | EToolName.Line;
@@ -0,0 +1,22 @@
1
+ import { ICoordinate, IPointCloudBox } from '@labelbee/lb-utils';
2
+ export declare enum EPointCloudBoxRenderTrigger {
3
+ Default = "Default",
4
+ UndoRedo = "UndoRedo",
5
+ ClearAll = "ClearAll",
6
+ Single = "Single",
7
+ SingleDelete = "SingleDelete",
8
+ SingleToggleValid = "SingleToggleValid",
9
+ SingleRotate = "SingleRotate",
10
+ MultiPaste = "MultiPaste",
11
+ MultiMove = "MultiMove"
12
+ }
13
+ export declare enum EPointCloudBoxSingleModifiedType {
14
+ ChangeAttribute = "ChangeAttribute",
15
+ Move = "Move",
16
+ ChangeDepth = "ChangeDepth",
17
+ ChangeSize = "ChangeSize"
18
+ }
19
+ export declare const calcResetAreasAndBoxIds: (trigger: EPointCloudBoxRenderTrigger, newList: IPointCloudBox[], oldList: IPointCloudBox[]) => {
20
+ resetAreas: ICoordinate[][];
21
+ modifiedBoxIds: string[];
22
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__spreadValues=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));exports.EPointCloudBoxRenderTrigger=void 0,function(e){e.Default="Default",e.UndoRedo="UndoRedo",e.ClearAll="ClearAll",e.Single="Single",e.SingleDelete="SingleDelete",e.SingleToggleValid="SingleToggleValid",e.SingleRotate="SingleRotate",e.MultiPaste="MultiPaste",e.MultiMove="MultiMove"}(exports.EPointCloudBoxRenderTrigger||(exports.EPointCloudBoxRenderTrigger={})),exports.EPointCloudBoxSingleModifiedType=void 0,function(e){e.ChangeAttribute="ChangeAttribute",e.Move="Move",e.ChangeDepth="ChangeDepth",e.ChangeSize="ChangeSize"}(exports.EPointCloudBoxSingleModifiedType||(exports.EPointCloudBoxSingleModifiedType={}));const getExternalBox=e=>{const o=Math.max(e.width,e.height)/Math.sqrt(2);return __spreadProps(__spreadValues({},e),{width:o*2,height:o*2})},checkRectanglesIntersect=(e,t)=>{const o=getAxes(e).concat(getAxes(t));for(const n of o){const r=projectRectangle(e,n),i=projectRectangle(t,n);if(!projectionsOverlap(r,i))return!1}return!0},getAxes=e=>{const t=[];for(let o=0;o<e.length;o++){const n=e[o],r=e[(o+1)%e.length],i={x:r.x-n.x,y:r.y-n.y},s={x:-i.y,y:i.x};t.push(s)}return t},projectRectangle=(e,t)=>{let o=dotProduct(e[0],t),n=o;for(const r of e){const i=dotProduct(r,t);i<o&&(o=i),i>n&&(n=i)}return{min:o,max:n}},projectionsOverlap=(e,t)=>!(e.max<t.min||t.max<e.min),dotProduct=(e,t)=>e.x*t.x+e.y*t.y,getIntersectingBoxIds=(e,t)=>{const o=[];return t.forEach(n=>{const{polygonPointList:r}=lbAnnotation.getCuboidFromPointCloudBox(n);checkRectanglesIntersect(e,r)&&o.push(n.id)}),o},getAddBoxId=(e,t)=>{const o=e.map(r=>r.id),n=t.map(r=>r.id);return o.find(r=>!n.includes(r))||""},getDeletedBox=(e,t)=>{const o=e.map(n=>n.id);return t.find(n=>!o.includes(n.id))},getRotationModifiedOrValidChangedBox=(e,t)=>e.find(n=>{const r=t.find(i=>i.id===n.id);return r&&(r.rotation!==n.rotation||r.valid!==n.valid)}),getIntersectingBoxIdsOfExternalBox=(e,t)=>{const o=getExternalBox(e),n=lbAnnotation.getCuboidFromPointCloudBox(o);return{ids:getIntersectingBoxIds(n.polygonPointList,t.filter(i=>i.id!==e.id)),rect:n.polygonPointList}},getModifiedBox=(e,t)=>{const o=(n,r)=>n.attribute===r.attribute&&n.center.x===r.center.x&&n.center.y===r.center.y&&n.depth===r.depth&&n.width===r.width&&n.height===r.height;for(const n of e){const r=t.find(i=>i.id===n.id);if(r&&!o(n,r)){let i;if(r.attribute!==n.attribute?i=exports.EPointCloudBoxSingleModifiedType.ChangeAttribute:r.center.x!==n.center.x||r.center.y!==n.center.y?i=exports.EPointCloudBoxSingleModifiedType.Move:r.depth!==n.depth?i=exports.EPointCloudBoxSingleModifiedType.ChangeDepth:(r.width!==n.width||r.height!==n.height)&&(i=exports.EPointCloudBoxSingleModifiedType.ChangeSize),i!==void 0)return{modifiedType:i,box:n}}}},calcResetAreasAndBoxIds=(e,t,o)=>{const n=[],r=[];try{switch(e){case exports.EPointCloudBoxRenderTrigger.Single:if(t.length>o.length){const i=getAddBoxId(t,o);i&&r.push(i)}else{const i=getModifiedBox(t,o);if(i&&(r.push(i.box.id),t.length>1&&(i.modifiedType===exports.EPointCloudBoxSingleModifiedType.ChangeSize||i.modifiedType===exports.EPointCloudBoxSingleModifiedType.Move))){const s=o.find(a=>a.id===i.box.id),d=o.filter(a=>a.id!==i.box.id),{ids:c,rect:l}=getIntersectingBoxIdsOfExternalBox(s,d);r.push(...c),n.push(l)}}break;case exports.EPointCloudBoxRenderTrigger.SingleDelete:if(t.length<o.length){const i=getDeletedBox(t,o);if(i){const s=lbAnnotation.getCuboidFromPointCloudBox(i);if(n.push(s.polygonPointList),t.length>1){const{ids:d}=getIntersectingBoxIdsOfExternalBox(i,o);d.length&&r.push(...d)}}}break;case exports.EPointCloudBoxRenderTrigger.SingleRotate:if(getRotationModifiedOrValidChangedBox(t,o)){const i=getRotationModifiedOrValidChangedBox(t,o);if(r.push(i.id),t.length>1){const s=o.filter(l=>l.id!==i.id),{ids:d,rect:c}=getIntersectingBoxIdsOfExternalBox(i,s);r.push(...d),n.push(c)}}break;case exports.EPointCloudBoxRenderTrigger.SingleToggleValid:if(getRotationModifiedOrValidChangedBox(t,o)){const i=getRotationModifiedOrValidChangedBox(t,o);r.push(i.id)}break;case exports.EPointCloudBoxRenderTrigger.MultiPaste:case exports.EPointCloudBoxRenderTrigger.MultiMove:break;case exports.EPointCloudBoxRenderTrigger.Default:case exports.EPointCloudBoxRenderTrigger.UndoRedo:case exports.EPointCloudBoxRenderTrigger.ClearAll:default:break}}catch(i){return console.error("calcResetAreasAndBoxIds error:",i),{resetAreas:n,modifiedBoxIds:r}}return{resetAreas:n,modifiedBoxIds:r}};exports.calcResetAreasAndBoxIds=calcResetAreasAndBoxIds;
@@ -1 +1 @@
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
+ import{getClassName as U}from"../../utils/dom.js";import s,{useRef as P,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=(o,u,e)=>new Promise((a,r)=>{var f=t=>{try{i(e.next(t))}catch(n){r(n)}},d=t=>{try{i(e.throw(t))}catch(n){r(n)}},i=t=>t.done?a(t.value):Promise.resolve(t.value).then(f,d);i((e=e.apply(o,u)).next())});const $=({view2dData:o,setSelectedID:u,currentData:e,showEnlarge:a,checkMode:r=!1,measureVisible:f})=>{var d,i;const t=P(null),n=P(),{selectedBox:m}=K(),g=J(t),{url:k,fallbackUrl:x,calib:b,path:j}=o,{toggle2dVisible:_,isHighlightVisible:v}=M({currentData:e}),[z,C]=A(!1),{cuboidBoxIn2DView:h,cacheImageNodeSize:B}=F(W),I=!o,O=T(()=>({zIndex:a?-1:101,is2DView:!h,imageName:o.path}),[a,h,o.path]),{rendered:R,isLinking:E}=X(O),L=l=>{p(),B({path:j,imgNode:l})},p=q(()=>{var l,S;const y=(l=n.current)==null?void 0:l.toolInstance;if(u(""),!m||!y)return;const c=o.annotations.find(N=>N.annotation.id===m.info.id);let V="";c&&((S=c==null?void 0:c.annotation.pointList)==null?void 0:S.length)>0&&(y.focusPositionByPointList(c==null?void 0:c.annotation.pointList),V=m.info.id,u(V))},[m,n.current,o.annotations]);w(()=>{p()},[p]);const H=()=>Z(void 0,null,function*(){C(!0);try{yield _(k,x!=null?x:"",b)}catch(l){console.error("highlightOnClick error:",l)}finally{C(!1)}});return s.createElement("div",{className:U("point-cloud-2d-image"),ref:t},h?s.createElement(G,{src:(d=o==null?void 0:o.url)!=null?d:"",fallbackSrc:(i=o==null?void 0:o.fallbackUrl)!=null?i:"",annotations:o.annotations,size:g,ref:n,globalStyle:{display:I?"none":"block"},afterImgOnLoad:L,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):s.createElement(s.Fragment,null,s.createElement(Y,{shouldExcludePointCloudBoxListUpdate:!E,mappingData:o,size:g,checkMode:r,afterImgOnLoad:L}),!r&&R),b&&s.createElement(Q,{visible:v(k),onClick:H,loading:z,style:{position:"absolute",right:16,top:16,zIndex:a?-1:101}}))};export{$ as default};
@@ -1 +1 @@
1
- import{EPointCloudPattern as K}from"@labelbee/lb-utils";import wt,{useState as r,useRef as Qt,useMemo as H,useCallback as M,useEffect as Q}from"react";import{ActionsHistory as bt,EToolName as U,uuid as Ut}from"@labelbee/lb-annotation";import{useDispatch as Xt}from"../../store/ctx.js";import{ChangeSave as Yt}from"../../store/annotation/actionCreators.js";import $t from"../../store/annotatedBox/index.js";import Ct from"lodash";import{addMapIndirectWeakSetItem as St}from"./utils/map.js";var te=Object.defineProperty,ee=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,Rt=(a,n,c)=>n in a?te(a,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[n]=c,j=(a,n)=>{for(var c in n||(n={}))ie.call(n,c)&&Rt(a,c,n[c]);if(Lt)for(var c of Lt(n))oe.call(n,c)&&Rt(a,c,n[c]);return a},Dt=(a,n)=>ee(a,ne(n)),se=(a,n,c)=>new Promise((L,x)=>{var A=u=>{try{P(c.next(u))}catch(b){x(b)}},F=u=>{try{P(c.throw(u))}catch(b){x(b)}},P=u=>u.done?L(u.value):Promise.resolve(u.value).then(A,F);P((c=c.apply(a,n)).next())});const k=a=>Ct.pick(a,["id","attribute","width","height","x","y","imageName"]),xt=wt.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 bt,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:U.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:K.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,updateRectListByReducer:()=>{}}),re=({children:a})=>{const[n,c]=r([]),[L,x]=r([]),[A,F]=r([]),[P,u]=r([]),[b,At]=r([]),[I,z]=r([]),[B,E]=r([]),[X,Bt]=r(!0),[Y,_t]=r(2),[$,Vt]=r(!0),[tt,Nt]=r(1),[f,et]=r(),[nt,it]=r(),[ot,st]=r(),[p,rt]=r(),[lt,Ot]=r(""),[G,Ht]=r(U.Rect),Mt=Qt(new bt).current,[g,T]=r([]),[at,jt]=r(""),[Z,kt]=r(K.Detection),[R,ct]=r(void 0),[W,Ft]=r([]),[q,zt]=r([]),h=$t(),[dt,Et]=r({}),Gt=Xt(),Tt=i=>{const{imgNode:o,path:e}=i;e&&o&&Et(d=>Dt(j({},d),{[e]:{width:o.width,height:o.height}}))},ut=H(()=>I.length===1?I[0]:"",[I]),_=M((i,o,e="extId")=>{const d=e||"id",l=new Set(o);return u(m=>{let C=!1;const S=m.filter(N=>{const J=N[d],O=l.has(J)?N.imageName!==i:!0;return O||(C=!0),O});return C?S:m}),!0},[]),pt=M(i=>{const o=n.map(e=>e.id);return _(i,o,"extId")},[n,_]),mt=M(i=>{if(!i)return!1;const o=n.filter(e=>Array.isArray(e.rects)).map(e=>{const{id:d,attribute:l,trackID:m}=e,C=e.rects.find(S=>S.imageName===i);if(C){const S=Ct.pick(C,["width","height","x","y","imageName"]);return Dt(j({},S),{id:Ut(),attribute:l,order:m,extId:d,lineDash:[]})}return null}).filter(e=>e!==null);return o.length?(u(e=>{const d=new Set(e.filter(m=>i===m.imageName).map(m=>m.extId)),l=o.filter(m=>d.has(m.extId)===!1);return l.length?[...e,...l]:e}),!0):!1},[n]),ft=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:m}=l;if(!m){console.warn("Missing image name"),console.trace(l,e);return}St(o,m,e.id,e)}),o},new Map),[n]),gt=M(i=>{u(o=>i(o,k))},[k]),ht=H(()=>P.filter(i=>i.extId!==void 0&&i.id!==void 0).reduce((i,o)=>{const e=o.imageName;return e?(St(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===ut),o=t=>{const s=n.concat(t);return c(s),s},e=t=>{const s=L.concat(t);return x(s),s},d=t=>{Bt(t!==!1)},l=t=>{t===void 0&&z([]),typeof t=="string"&&z([t]),Array.isArray(t)&&z(Array.from(new Set(t)))},m=t=>{I.includes(t)?l(I.filter(s=>s!==t)):l([...I,t])},C=t=>{const s=k(t);u(v=>[...v,s])},S=(t,s=!1)=>{const v=k(t);u(w=>w.map(y=>y.id===t.id?s?j(j({},y),v):v:y))},N=t=>{u(s=>s.filter(v=>!t.find(w=>w.id===v.id)))},J=t=>{B.includes(t)?E([]):E([t])},O=()=>{if(G===U.Rect){const t=n.map(s=>s.id);l(t),f==null||f.pointCloud2dOperation.setSelectedIDs(t)}},Wt=t=>{l(n.filter(s=>s.attribute===t).map(s=>s.id))},vt=n.filter(t=>!g.includes(t.attribute)),It=L.filter(t=>!g.includes(t.attribute)),Pt=b.filter(t=>t.attribute&&!g.includes(t.attribute)),qt=t=>{if(g.includes(t))T(g.filter(s=>s!==t));else{const s=g.concat(t);T(s)}},Jt=(t=vt,s=A,v=It,w=Pt,y=W)=>{var D;p==null||p.clearAllBox(),p==null||p.clearAllSphere(),f==null||f.updatePolygonList(t,s),f==null||f.updatePointList(v),f==null||f.updateLineList(w),p==null||p.generateBoxes(t),p==null||p.generateSpheres(v),(D=R==null?void 0:R.store)==null||D.updateCurrentSegment(y),yt(t)},Kt=()=>{et(void 0),it(void 0),st(void 0),rt(void 0)},yt=(t,s)=>se(void 0,null,function*(){var v;if(!p)return;const w=p.pointCloudObject;if(!!w)try{const y=yield p.getHighlightIndexByMappingImgList({mappingImgList:s!=null?s:q,points:w.geometry.attributes.position.array}),D=yield p==null?void 0:p.highlightOriginPointCloud(t,y);return D&&((v=f==null?void 0:f.pointCloudInstance)==null||v.updateColor(D)),D}catch(y){console.error(y)}});return{selectedID:ut,pointCloudBoxList:n,pointCloudSphereList:L,displayPointCloudList:vt,displaySphereList:It,displayLineList:Pt,selectedIDs:I,setPointCloudResult:c,setSelectedIDs:l,addPointCloudBox:o,addPointCloudSphere:e,setPointCloudSphereList:x,valid:X,selectedPointCloudBox:i,setPointCloudValid:d,addSelectedID:m,addHighlightID:J,selectedAllBoxes:O,topViewInstance:f,setTopViewInstance:et,sideViewInstance:nt,setSideViewInstance:it,backViewInstance:ot,setBackViewInstance:st,mainViewInstance:p,setMainViewInstance:rt,polygonList:A,setPolygonList:F,rectList:P,setRectList:u,addRectIn2DView:C,removeRectIn2DView:N,updateRectIn2DView:S,lineList:b,setLineList:At,zoom:tt,setZoom:Nt,history:Mt,toggleAttributesVisible:qt,hideAttributes:g,setHideAttributes:T,reRender:Jt,attrPanelLayout:at,setAttrPanelLayout:jt,syncAllViewPointCloudColor:yt,defaultAttribute:lt,setDefaultAttribute:Ot,pointCloudPattern:G,setPointCloudPattern:Ht,selectSpecAttr:Wt,globalPattern:Z,setGlobalPattern:t=>{Z!==t&&(Gt(Yt),kt(t),t===K.Detection&&ct(void 0))},ptSegmentInstance:R,setPtSegmentInstance:ct,segmentation:W,setSegmentation:Ft,clearAllDetectionInstance:Kt,highlight2DDataList:q,setHighlight2DDataList:zt,cuboidBoxIn2DView:$,setCuboidBoxIn2DView:Vt,imageSizes:dt,cacheImageNodeSize:Tt,highlightIDs:B,setHighlightIDs:E,removeRectByPointCloudBoxId:pt,removeRectBySpecifyId:_,addRectFromPointCloudBoxByImageName:mt,rectRotateSensitivity:Y,setRectRotateSensitivity:_t,imageNamePointCloudBoxMap:ft,linkageImageNameRectMap:ht,updateRectListByReducer:gt}},[X,I,n,L,A,b,P,f,nt,ot,p,tt,g,at,lt,G,Z,R,W,q,$,dt,B,pt,_,mt,Y,ft,ht,gt]);Q(()=>{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,B),(e=h==null?void 0:h.setSelectedIDs)==null||e.call(h,I)},[n,I,B]),Q(()=>{var i;(i=h==null?void 0:h.setPtCtx)==null||i.call(h,V)},[V]);const Zt=()=>{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 Q(()=>{var i,o,e,d;Zt(),(o=(i=f==null?void 0:f.toolInstance)==null?void 0:i.setHiddenAttributes)==null||o.call(i,g),(d=(e=R==null?void 0:R.store)==null?void 0:e.setHiddenAttributes)==null||d.call(e,g)},[g]),wt.createElement(xt.Provider,{value:V},a)};export{xt as PointCloudContext,re as PointCloudProvider};
1
+ import{EPointCloudPattern as Y}from"@labelbee/lb-utils";import Be,{useState as r,useRef as it,useMemo as j,useCallback as k,useEffect as $}from"react";import{EPointCloudBoxRenderTrigger as F,calcResetAreasAndBoxIds as st}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as _e,EToolName as ee,uuid as rt}from"@labelbee/lb-annotation";import{useDispatch as lt}from"../../store/ctx.js";import{ChangeSave as at}from"../../store/annotation/actionCreators.js";import ct from"../../store/annotatedBox/index.js";import Ve from"lodash";import{addMapIndirectWeakSetItem as Ne}from"./utils/map.js";var dt=Object.defineProperty,ut=Object.defineProperties,pt=Object.getOwnPropertyDescriptors,Oe=Object.getOwnPropertySymbols,mt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,He=(a,o,c)=>o in a?dt(a,o,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[o]=c,E=(a,o)=>{for(var c in o||(o={}))mt.call(o,c)&&He(a,c,o[c]);if(Oe)for(var c of Oe(o))ft.call(o,c)&&He(a,c,o[c]);return a},Me=(a,o)=>ut(a,pt(o)),gt=(a,o,c)=>new Promise((L,A)=>{var B=u=>{try{P(c.next(u))}catch(C){A(C)}},G=u=>{try{P(c.throw(u))}catch(C){A(C)}},P=u=>u.done?L(u.value):Promise.resolve(u.value).then(B,G);P((c=c.apply(a,o)).next())});const z=a=>Ve.pick(a,["id","attribute","width","height","x","y","imageName"]),je=Be.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 _e,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:ee.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:Y.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:a=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:a=>!1,removeRectBySpecifyId:(a,o,c)=>!1,removeRectByPointCloudBoxId:a=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{}}),ht=({children:a})=>{const[o,c]=r([]),[L,A]=r([]),[B,G]=r([]),[P,u]=r([]),[C,ke]=r([]),[v,T]=r([]),[_,Z]=r([]),[te,Fe]=r(!0),[oe,Ee]=r(2),[ne,ze]=r(!0),[ie,Ge]=r(1),[f,se]=r(),[re,le]=r(),[ae,ce]=r(),[p,de]=r(),[ue,Te]=r(""),[W,Ze]=r(ee.Rect),q=it(new _e).current,[g,J]=r([]),[pe,We]=r(""),[K,qe]=r(Y.Detection),[D,me]=r(void 0),[Q,Je]=r([]),[U,Ke]=r([]),h=ct(),[fe,Qe]=r({}),Ue=lt(),Xe=n=>{const{imgNode:i,path:t}=n;t&&i&&Qe(d=>Me(E({},d),{[t]:{width:i.width,height:i.height}}))},ge=j(()=>v.length===1?v[0]:"",[v]),N=k((n,i,t="extId")=>{const d=t||"id",l=new Set(i);return u(m=>{let R=!1;const x=m.filter(H=>{const X=H[d],M=l.has(X)?H.imageName!==n:!0;return M||(R=!0),M});return R?x:m}),!0},[]),he=k(n=>{const i=o.map(t=>t.id);return N(n,i,"extId")},[o,N]),Ie=k(n=>{if(!n)return!1;const i=o.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:d,attribute:l,trackID:m}=t,R=t.rects.find(x=>x.imageName===n);if(R){const x=Ve.pick(R,["width","height","x","y","imageName"]);return Me(E({},x),{id:rt(),attribute:l,order:m,extId:d,lineDash:[]})}return null}).filter(t=>t!==null);return i.length?(u(t=>{const d=new Set(t.filter(m=>n===m.imageName).map(m=>m.extId)),l=i.filter(m=>d.has(m.extId)===!1);return l.length?[...t,...l]:t}),!0):!1},[o]),ve=j(()=>o.filter(i=>Array.isArray(i.rects)&&i.rects.length>0).reduce((i,t)=>{var d;return(d=t.rects)==null||d.forEach(l=>{const{imageName:m}=l;if(!m){console.warn("Missing image name"),console.trace(l,t);return}Ne(i,m,t.id,t)}),i},new Map),[o]),Pe=k(n=>{u(i=>n(i,z))},[z]),ye=j(()=>P.filter(n=>n.extId!==void 0&&n.id!==void 0).reduce((n,i)=>{const t=i.imageName;return t?(Ne(n,t,i.extId,i),n):(console.warn("missing image name"),console.log(i,P),n)},new Map),[P]),O=j(()=>{const n=o.find(e=>e.id===ge),i=e=>{const s=o.concat(e);return c(s),s},t=e=>{const s=L.concat(e);return A(s),s},d=e=>{Fe(e!==!1)},l=e=>{e===void 0&&T([]),typeof e=="string"&&T([e]),Array.isArray(e)&&T(Array.from(new Set(e)))},m=e=>{v.includes(e)?l(v.filter(s=>s!==e)):l([...v,e])},R=e=>{const s=z(e);u(I=>[...I,s])},x=(e,s=!1)=>{const I=z(e);u(y=>y.map(S=>S.id===e.id?s?E(E({},S),I):I:S))},H=e=>{u(s=>s.filter(I=>!e.find(y=>y.id===I.id)))},X=e=>{_.includes(e)?Z([]):Z([e])},M=()=>{if(W===ee.Rect){const e=o.map(s=>s.id);l(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},$e=e=>{l(o.filter(s=>s.attribute===e).map(s=>s.id))},Se=o.filter(e=>!g.includes(e.attribute)),be=L.filter(e=>!g.includes(e.attribute)),we=C.filter(e=>e.attribute&&!g.includes(e.attribute)),et=e=>{if(g.includes(e))J(g.filter(s=>s!==e));else{const s=g.concat(e);J(s)}},tt=(e=Se,s=B,I=be,y=we,S=Q)=>{var V;p==null||p.clearAllBox(),p==null||p.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(I),f==null||f.updateLineList(y),p==null||p.generateBoxes(e),p==null||p.generateSpheres(I),(V=D==null?void 0:D.store)==null||V.updateCurrentSegment(S),Ce(F.Default,e)},ot=()=>{se(void 0),le(void 0),ce(void 0),de(void 0)},Ce=(e,s,I)=>gt(void 0,null,function*(){var y,S,V;if(!p)return;const Re=p.pointCloudObject;if(!Re)return;let xe=[],Le=[];try{if(s&&q.record.length){const{record:b,recordIndex:w}=q;let De=w;w>0&&(e===F.SingleToggleValid||e===F.SingleRotate||e===F.Single&&s.length===((y=b[w])==null?void 0:y.pointCloudBoxList.length))&&(De=w-1);let nt=(S=b[De])==null?void 0:S.pointCloudBoxList;const Ae=st(e,s,nt);xe=Ae.modifiedBoxIds,Le=Ae.resetAreas}}catch(b){console.error("call calcResetAreasAndBoxIds error",b)}try{const b=yield p.getHighlightIndexByMappingImgList({mappingImgList:I!=null?I:U,points:Re.geometry.attributes.position.array}),w=yield p==null?void 0:p.highlightOriginPointCloud(s,b,{modifiedBoxIds:xe,resetAreas:Le});return w&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(w)),w}catch(b){console.error("call highlightOriginPointCloud error",b)}});return{selectedID:ge,pointCloudBoxList:o,pointCloudSphereList:L,displayPointCloudList:Se,displaySphereList:be,displayLineList:we,selectedIDs:v,setPointCloudResult:c,setSelectedIDs:l,addPointCloudBox:i,addPointCloudSphere:t,setPointCloudSphereList:A,valid:te,selectedPointCloudBox:n,setPointCloudValid:d,addSelectedID:m,addHighlightID:X,selectedAllBoxes:M,topViewInstance:f,setTopViewInstance:se,sideViewInstance:re,setSideViewInstance:le,backViewInstance:ae,setBackViewInstance:ce,mainViewInstance:p,setMainViewInstance:de,polygonList:B,setPolygonList:G,rectList:P,setRectList:u,addRectIn2DView:R,removeRectIn2DView:H,updateRectIn2DView:x,lineList:C,setLineList:ke,zoom:ie,setZoom:Ge,history:q,toggleAttributesVisible:et,hideAttributes:g,setHideAttributes:J,reRender:tt,attrPanelLayout:pe,setAttrPanelLayout:We,syncAllViewPointCloudColor:Ce,defaultAttribute:ue,setDefaultAttribute:Te,pointCloudPattern:W,setPointCloudPattern:Ze,selectSpecAttr:$e,globalPattern:K,setGlobalPattern:e=>{K!==e&&(Ue(at),qe(e),e===Y.Detection&&me(void 0))},ptSegmentInstance:D,setPtSegmentInstance:me,segmentation:Q,setSegmentation:Je,clearAllDetectionInstance:ot,highlight2DDataList:U,setHighlight2DDataList:Ke,cuboidBoxIn2DView:ne,setCuboidBoxIn2DView:ze,imageSizes:fe,cacheImageNodeSize:Xe,highlightIDs:_,setHighlightIDs:Z,removeRectByPointCloudBoxId:he,removeRectBySpecifyId:N,addRectFromPointCloudBoxByImageName:Ie,rectRotateSensitivity:oe,setRectRotateSensitivity:Ee,imageNamePointCloudBoxMap:ve,linkageImageNameRectMap:ye,updateRectListByReducer:Pe}},[te,v,o,L,B,C,P,f,re,ae,p,ie,g,pe,ue,W,K,D,Q,U,ne,fe,_,he,N,Ie,oe,ve,ye,Pe]);$(()=>{var n,i,t;(n=h==null?void 0:h.setPointCloudBoxList)==null||n.call(h,o),(i=h==null?void 0:h.setHighlightIDs)==null||i.call(h,_),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,v)},[o,v,_]),$(()=>{var n;(n=h==null?void 0:h.setPtCtx)==null||n.call(h,O)},[O]);const Ye=()=>{const n=o.filter(l=>g.includes(l.attribute)),{setSelectedIDs:i,reRender:t}=O,d=n.map(l=>l.id);d.length>0&&i(v.filter(l=>!d.includes(l))),t()};return $(()=>{var n,i,t,d;Ye(),(i=(n=f==null?void 0:f.toolInstance)==null?void 0:n.setHiddenAttributes)==null||i.call(n,g),(d=(t=D==null?void 0:D.store)==null?void 0:t.setHiddenAttributes)==null||d.call(t,g)},[g]),Be.createElement(je.Provider,{value:O},a)};export{je as PointCloudContext,ht as PointCloudProvider};
@@ -1 +1 @@
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};
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 de,UpSquareOutlined as ce,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{EPointCloudBoxRenderTrigger as we}from"../../utils/ToolPointCloudBoxRenderHelper.js";import i,{useState as W,useRef as Ce,useLayoutEffect as ge,useEffect as x}from"react";import{PointCloudContext as F}from"./PointCloudContext.js";import{useRotate as Pe}from"./hooks/useRotate.js";import{useRotateEdge as ye}from"./hooks/useRotateEdge.js";import{useSingleBox as K}from"./hooks/useSingleBox.js";import{PointCloudContainer as Ie}from"./PointCloudLayout.js";import{BoxInfos as X,PointCloudValidity as xe}from"./PointCloudInfos.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useSphere as Y}from"./hooks/useSphere.js";import{useZoom as q}from"./hooks/useZoom.js";import{Slider as Ve}from"antd";import{a2MapStateToProps as Se}from"../../store/annotation/map.js";import{connect as _e}from"react-redux";import{usePointCloudViews as Ee}from"./hooks/usePointCloudViews.js";import Le from"../../hooks/useSize.js";import{useTranslation as Oe}from"react-i18next";import{LabelBeeContext as be}from"../../store/ctx.js";import{jsonParser as je}from"../../utils/index.js";import Te from"../../utils/ToolUtils.js";import ke from"lodash";import Re from"./components/PointCloudSizeSlider/index.js";import{useHistory as Ae}from"./hooks/useHistory.js";import Be from"./components/TitleButton/index.js";var Ne=Object.defineProperty,De=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,Ze=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,$=(n,l,r)=>l in n?Ne(n,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[l]=r,N=(n,l)=>{for(var r in l||(l={}))Ze.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)=>De(n,Ue(l));const{EPolygonPattern:He,EToolName:G}=fe,{ESortDirection:J}=ve,We=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}},Fe=({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}=Pe({currentData:n}),{updateRotateEdge:O}=ye({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))},d=()=>{V(g.rectRotateSensitivity)},f=()=>{O(-90)};return i.createElement(i.Fragment,null,i.createElement(Re,{onChange:b=>{var _;(_=S==null?void 0:S.pointCloudInstance)==null||_.updatePointSize({customSize:b})}}),i.createElement("span",{onClick:d,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(ce,{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}))},Ke=({setZAxisLimit:n,zAxisLimit:l,checkMode:r})=>r?null:i.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},i.createElement(Ve,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:w=>{n(w)}})),Xe=({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=Ce(null),e=i.useContext(F),d=Le(m),f=je(r.config),{setZoom:b,syncTopviewToolZoom:_}=q(),{hideAttributes:ee}=e,{addPolygon:te,deletePolygon:oe}=he(),{deletePointCloudSphere:ne}=Y(),{deletePointCloudBox:ie,changeValidByID:se}=K(),[j,le]=W(10),{t:U}=Oe(),C=Ee(),{pushHistoryWithList:re}=Ae();ge(()=>{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(N({},f),{pointCloudPattern:e.pointCloudPattern}),checkMode:u,toolName:Te.getPointCloudToolList(),proxyMode:u});e.setTopViewInstance(a)}},[n]),x(()=>{if(!d||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:o}=e.topViewInstance;o.singleOn("dataUpdated",(t,s)=>{const p=ke.cloneDeep(t).map(c=>D(N({},c),{pointList:H.pointListTransferCanvas2World(c.pointList,d)}));e.setSelectedIDs(s),e.setLineList(p),re({lineList:p})}),o.singleOn("pointCreated",(t,s)=>{C.topViewAddSphere({newPoint:t,size:d,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,d)}),o.singleOn("polygonCreated",(t,s)=>{if(o.pattern===He.Normal||!(n==null?void 0:n.url)){const p=D(N({},t),{pointList:t.pointList.map(c=>H.transferCanvas2World(c,d))});te(p),e.setSelectedIDs(ee.includes(t.attribute)?"":t.id);return}C.topViewAddBox({polygon:t,size:d,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,d)});const a=t=>{var s;const p=se(t);p&&e.syncAllViewPointCloudColor(we.Default,p),e.polygonList.find(c=>c.id===t)&&((s=e.topViewInstance)==null||s.toolInstance.setPolygonValidAndRender(t,!0))};return o.on("validUpdate",a),()=>{o.unbind("validUpdate",a)}},[e,d,n,C,e.polygonList,e.lineList,(V=e.topViewInstance)==null?void 0:V.toolInstance]),x(()=>{var o,a;if(!(d==null?void 0:d.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(d),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",(c,v)=>{const{offsetX:T,offsetY:k}=Q(v,d,c);if(s.camera.zoom=c,v){const{x:R,y:A,z:B}=s.initCameraPosition;s.camera.position.set(R+k,A-T,B)}s.camera.updateProjectionMatrix(),s.render(),b(c),_(v,c,d),S({zoom:c,currentPos:v})}),p.singleOn("dragMove",({currentPos:c,zoom:v})=>{const{offsetX:T,offsetY:k}=Q(c,d,v);s.camera.zoom=v;const{x:R,y:A,z:B}=s.initCameraPosition;s.camera.position.set(R+k,A-T,B),s.render(),_(c,v,d),S({zoom:v,currentPos:c})})},[d,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===We.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(Ie,{className:I("point-cloud-container","top-view"),title:E?i.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},i.createElement(de,{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(Be,{title:U("TopView"),onClick:()=>{y(!0)}}),toolbar:i.createElement(Fe,{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(Ke,{checkMode:u,zAxisLimit:j,setZAxisLimit:le}),i.createElement(xe,null)))};var Ye=_e(Se,null,null,{context:be})(Xe);export{Ye as default};
@@ -1 +1 @@
1
- import{useContext as y,useState as B,useMemo as h,useCallback as p}from"react";import R from"lodash";import{message as C,Modal as w}from"antd";import{usePointCloudViews as H}from"./usePointCloudViews.js";import{PointCloudContext as M}from"../PointCloudContext.js";import{useTranslation as S}from"react-i18next";const V=({config:m})=>{const{selectedIDs:l,pointCloudBoxList:a,displayPointCloudList:o,setPointCloudResult:f,syncAllViewPointCloudColor:D}=y(M),[t,i]=B([]),{pointCloudBoxListUpdated:c}=H(),{t:n,i18n:d}=S(),x=s=>m.trackConfigurable!==!0?!1:a.some(r=>s.some(e=>e.trackID===r.trackID)),u=h(()=>o.filter(s=>l.includes(s.id)),[l,o]),P=p(()=>{u.length>0?i(R.cloneDeep(u)):(i([]),C.error(n("CopyEmptyInPointCloud")))},[l,o,d.language]),I=p(()=>{if(t.length===0){C.error(n("PasteEmptyInPointCloud"));return}const s=x(t),r=e=>{f(e),c==null||c(e),i([]),D(e)};if(s)w.confirm({title:n("HasDuplicateIDHeader"),content:n("HasDuplicateIDMsg"),onOk:()=>{const e=a.filter(g=>!t.find(k=>k.trackID===g.trackID)).concat(t);r(e)}});else{const e=[...o,...t];r(e)}},[t,o,d.language]);return{copySelectedBoxes:P,pasteSelectedBoxes:I,copiedBoxes:t,selectedBoxes:u}};export{V as useBoxes};
1
+ import{useContext as k,useState as y,useMemo as R,useCallback as p}from"react";import h from"lodash";import{message as C,Modal as H}from"antd";import{usePointCloudViews as M}from"./usePointCloudViews.js";import{PointCloudContext as j}from"../PointCloudContext.js";import{useTranslation as w}from"react-i18next";import{EPointCloudBoxRenderTrigger as E}from"../../../utils/ToolPointCloudBoxRenderHelper.js";const S=({config:m})=>{const{selectedIDs:l,pointCloudBoxList:a,displayPointCloudList:o,setPointCloudResult:f,syncAllViewPointCloudColor:P}=k(j),[t,i]=y([]),{pointCloudBoxListUpdated:c}=M(),{t:n,i18n:d}=w(),x=s=>m.trackConfigurable!==!0?!1:a.some(r=>s.some(e=>e.trackID===r.trackID)),u=R(()=>o.filter(s=>l.includes(s.id)),[l,o]),D=p(()=>{u.length>0?i(h.cloneDeep(u)):(i([]),C.error(n("CopyEmptyInPointCloud")))},[l,o,d.language]),g=p(()=>{if(t.length===0){C.error(n("PasteEmptyInPointCloud"));return}const s=x(t),r=e=>{f(e),c==null||c(e),i([]),P(E.MultiPaste,e)};if(s)H.confirm({title:n("HasDuplicateIDHeader"),content:n("HasDuplicateIDMsg"),onOk:()=>{const e=a.filter(I=>!t.find(B=>B.trackID===I.trackID)).concat(t);r(e)}});else{const e=[...o,...t];r(e)}},[t,o,d.language]);return{copySelectedBoxes:D,pasteSelectedBoxes:g,copiedBoxes:t,selectedBoxes:u}};export{S as useBoxes};
@@ -1 +1 @@
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
+ import{useContext as C,useCallback as y}from"react";import{PointCloudContext as I}from"../PointCloudContext.js";var x=(s,g,t)=>new Promise((a,h)=>{var e=i=>{try{o(t.next(i))}catch(l){h(l)}},d=i=>{try{o(t.throw(i))}catch(l){h(l)}},o=i=>i.done?a(i.value):Promise.resolve(i.value).then(e,d);o((t=t.apply(s,g)).next())});const L=({currentData:s})=>{var g;const{mainViewInstance:t,topViewInstance:a,pointCloudBoxList:h,highlight2DDataList:e,setHighlight2DDataList:d}=C(I),o=(g=s==null?void 0:s.mappingImgList)!=null?g:[],i=(r,c,v)=>x(void 0,null,function*(){var p;let u=[...e];if(e.find(n=>n.url===r)?u=e.filter(n=>n.url!==r):u.push({url:r,fallbackUrl:c,calib:v}),d(u),!t||(o==null?void 0:o.length)===0)return;const m=t.pointCloudObject;if(!m)return;const f=yield t.getHighlightIndexByMappingImgList({mappingImgList:u,points:m.geometry.attributes.position.array});try{const n=yield t.highlightOriginPointCloud(h,f);n&&((p=a==null?void 0:a.pointCloudInstance)==null||p.updateColor(n))}catch(n){console.error("toggle2dVisible highlightOriginPointCloud error:",n)}}),l=y(r=>e.findIndex(c=>c.url===r)>=0,[e]);return{toggle2dVisible:i,isHighlightVisible:l}};export{L as useHighlight};
@@ -1 +1 @@
1
- import{useContext as m}from"react";import{PointCloudContext as I}from"../PointCloudContext.js";var R=Object.defineProperty,g=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,P=(e,n,s)=>n in e?R(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,a=(e,n)=>{for(var s in n||(n={}))U.call(n,s)&&P(e,s,n[s]);if(g)for(var s of g(n))V.call(n,s)&&P(e,s,n[s]);return e};const j=()=>{const{history:e,setPointCloudResult:n,setSelectedIDs:s,pointCloudBoxList:L,pointCloudSphereList:f,setPointCloudSphereList:x,mainViewInstance:d,topViewInstance:u,polygonList:c,setPolygonList:y,lineList:p,setLineList:h,syncAllViewPointCloudColor:S,segmentation:v}=m(I),_=({newBoxParams:t,newPolygon:o,newLine:i,newSphereParams:l})=>{const r={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:f};t&&(r.pointCloudBoxList=L.concat(t)),o&&(r.polygonList=c.concat(o)),i&&(r.lineList=p.concat(i)),l&&(r.pointCloudSphereList=f.concat(l)),e.pushHistory(r)},w=t=>{const o={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:f,segmentation:v};t.pointCloudBoxList&&(o.pointCloudBoxList=t.pointCloudBoxList),t.polygonList&&(o.polygonList=t.polygonList),t.lineList&&(o.lineList=t.lineList),t.pointCloudSphereList&&(o.pointCloudSphereList=t.pointCloudSphereList),t.segmentation&&(o.segmentation=t.segmentation),e.pushHistory(o)},B=t=>{if(p.find(i=>i.id===t.id)){const i=p.map(l=>l.id===t.id?t:a({},l));e.pushHistory({lineList:i}),h(i)}},H=t=>{if(c.find(i=>i.id===t.id)){const i=c.map(l=>l.id===t.id?t:a({},l));e.pushHistory({pointCloudBoxList:L,polygonList:i}),y(i)}},O=({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i})=>{e.initRecord({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i,lineList:p},!0)},C=t=>{if(!t)return;const{pointCloudBoxList:o=[],polygonList:i=[],lineList:l=[],pointCloudSphereList:r=[]}=t;o&&(L.length!==o.length&&s(),d==null||d.clearAllBox(),d==null||d.generateBoxes(o),n(o),S(o)),r&&(f.length!==r.length&&s(),d==null||d.clearAllSphere(),d==null||d.generateSpheres(r),x(r)),i&&y(i),l&&h(l),u==null||u.updatePolygonList(o!=null?o:[],i!=null?i:[]),u==null||u.updateLineList(l!=null?l:[]),u==null||u.updatePointList(r)};return{addHistory:_,pushHistoryWithList:w,initHistory:O,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:B,redo:()=>{C(e.redo())},undo:()=>{C(e.undo())}}};export{j as useHistory};
1
+ import{EPointCloudBoxRenderTrigger as m}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{useContext as R}from"react";import{PointCloudContext as I}from"../PointCloudContext.js";var U=Object.defineProperty,h=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,P=(e,n,s)=>n in e?U(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,a=(e,n)=>{for(var s in n||(n={}))j.call(n,s)&&P(e,s,n[s]);if(h)for(var s of h(n))V.call(n,s)&&P(e,s,n[s]);return e};const A=()=>{const{history:e,setPointCloudResult:n,setSelectedIDs:s,pointCloudBoxList:L,pointCloudSphereList:f,setPointCloudSphereList:x,mainViewInstance:d,topViewInstance:u,polygonList:c,setPolygonList:y,lineList:p,setLineList:C,syncAllViewPointCloudColor:S,segmentation:v}=R(I),B=({newBoxParams:t,newPolygon:o,newLine:i,newSphereParams:l})=>{const r={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:f};t&&(r.pointCloudBoxList=L.concat(t)),o&&(r.polygonList=c.concat(o)),i&&(r.lineList=p.concat(i)),l&&(r.pointCloudSphereList=f.concat(l)),e.pushHistory(r)},_=t=>{const o={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:f,segmentation:v};t.pointCloudBoxList&&(o.pointCloudBoxList=t.pointCloudBoxList),t.polygonList&&(o.polygonList=t.polygonList),t.lineList&&(o.lineList=t.lineList),t.pointCloudSphereList&&(o.pointCloudSphereList=t.pointCloudSphereList),t.segmentation&&(o.segmentation=t.segmentation),e.pushHistory(o)},H=t=>{if(p.find(i=>i.id===t.id)){const i=p.map(l=>l.id===t.id?t:a({},l));e.pushHistory({lineList:i}),C(i)}},w=t=>{if(c.find(i=>i.id===t.id)){const i=c.map(l=>l.id===t.id?t:a({},l));e.pushHistory({pointCloudBoxList:L,polygonList:i}),y(i)}},O=({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i})=>{e.initRecord({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i,lineList:p},!0)},g=t=>{if(!t)return;const{pointCloudBoxList:o=[],polygonList:i=[],lineList:l=[],pointCloudSphereList:r=[]}=t;o&&(L.length!==o.length&&s(),d==null||d.clearAllBox(),d==null||d.generateBoxes(o),n(o),S(m.UndoRedo,o)),r&&(f.length!==r.length&&s(),d==null||d.clearAllSphere(),d==null||d.generateSpheres(r),x(r)),i&&y(i),l&&C(l),u==null||u.updatePolygonList(o!=null?o:[],i!=null?i:[]),u==null||u.updateLineList(l!=null?l:[]),u==null||u.updatePointList(r)};return{addHistory:B,pushHistoryWithList:_,initHistory:O,pushHistoryUnderUpdatePolygon:w,pushHistoryUnderUpdateLine:H,redo:()=>{g(e.redo())},undo:()=>{g(e.undo())}}};export{A as useHistory};
@@ -1 +1 @@
1
- import{EPointCloudName as it,TagUtils as Gt,MathUtils as w,getCuboidFromPointCloudBox as Jt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Qt,DEFAULT_SPHERE_PARAMS as Xt}from"@labelbee/lb-utils";import{useContext as Yt}from"react";import{PointCloudContext as qt}from"../PointCloudContext.js";import{useSingleBox as Kt}from"./useSingleBox.js";import{useSphere as $t}from"./useSphere.js";import{useSelector as to,useDispatch as oo}from"../../../store/ctx.js";import eo from"../../../utils/StepUtils.js";import{jsonParser as st,generatePointCloudBoxRects as no}from"../../../utils/index.js";import{PreDataProcess as rt,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as io}from"./useHistory.js";import{usePolygon as so}from"./usePolygon.js";import{useLatest as ro}from"ahooks";var lo=Object.defineProperty,ao=Object.defineProperties,co=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,xt=(e,t,s)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,L=(e,t)=>{for(var s in t||(t={}))uo.call(t,s)&&xt(e,s,t[s]);if(mt)for(var s of mt(t))po.call(t,s)&&xt(e,s,t[s]);return e},O=(e,t)=>ao(e,co(t)),lt=(e,t,s)=>new Promise((a,o)=>{var c=p=>{try{u(s.next(p))}catch(m){o(m)}},g=p=>{try{u(s.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((s=s.apply(e,t)).next())});const q=5,K=90,ht=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,t,s,a,o)=>{const{x:c,y:g}=V.transferCanvas2World(e,t),{defaultZ:u}=Xt,p={center:{x:c,y:g,z:u},id:e.id},m=a?L(L({},a),p):O(L({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},at=(e,t,s,a,o,c)=>{let g=e.pointList.map(b=>V.transferCanvas2World(b,t)),u=0,p=1,m={};if(s){const b=s.getSensesPointZAxisInPolygon(g,void 0,c);c&&b.fittedCoordinates.length>0&&(g=b.fittedCoordinates),u=(b.maxZ+b.minZ)/2,p=b.maxZ-b.minZ,m={count:b.zCount}}const[v,D,H]=g,A=w.getLineCenterPoint([v,H]),k=w.getLineLength(v,D),R=w.getLineLength(D,H),j=w.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const U={center:{x:A.x,y:A.y,z:u},width:c?R+ht:R,height:c?k+ht:k,depth:p,rotation:j,id:e.id},T=L(a?L(L({},a),U):O(L({},U),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(b=>V.transferWorld2Canvas(b,t));return{boxParams:T,newPointList:N}},vt=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},s),{center:{x:s.center.x-a.x,y:s.center.y,z:s.center.z-a.y}})},Lt=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T,{newBoxParams:b}=a.getNewBoxBySideUpdate(A,N,j,s);return b},go=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},s),{center:{x:s.center.x,y:s.center.y-a.x,z:s.center.z-a.y}})},fo=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T;let{newBoxParams:b}=a.getNewBoxByBackUpdate(A,N,j,s);return b},yt=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Left);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{width:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Left);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Back);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{height:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Back);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,s,a)=>{if(!s||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=s,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},ct=(e,t,s,a)=>{var o,c;if(!s||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=s,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],v=m.find(D=>D.id===t.id);v?(v.pointList=p,v.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),g.setResultAndSelectedID(m,t.id)},Co=()=>{const e=Yt(qt),{topViewInstance:t,sideViewInstance:s,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:v,hideAttributes:D,setHighlight2DDataList:H,cuboidBoxIn2DView:A,imageSizes:k}=e,{addHistory:R,initHistory:j,pushHistoryUnderUpdatePolygon:U}=io(),{selectedPolygon:T}=so(),{getPointCloudSphereByID:N,updatePointCloudSphere:b,selectedSphere:J}=$t(),{currentData:W,config:B}=to(i=>{const{stepList:n,step:d,imgList:r,imgIndex:l}=i.annotation;return{currentData:r[l],config:st(eo.getCurrentStepInfo(d,n).config)}}),E=oo(),Dt=ro(A),$=i=>{const{enableAutoMap2DRect:n=!1}=B;if(!Dt.current||n){const{mappingImgList:d=[]}=W;no({pointCloudBox:i,mappingImgList:d,imageSizes:k})}},{selectedBox:_,updateSelectedBox:St,updateSelectedBoxes:tt,getPointCloudByID:_t}=Kt({generateRects:$}),ut=_==null?void 0:_.info;if(!t||!s||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},Ot=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},Rt=({newPoint:i,size:n,zoom:d,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const P=dt(i,n,ot,void 0,f);u(i.id);const C=g(P);Q(y.Top,i,P,d,C,B),R({newSphereParams:P})},At=({polygon:i,size:n,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var P,C,x;const S={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};r===!0&&Object.assign(S,{trackID:V.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:v})});const F=t==null?void 0:t.toolInstance,I=L({},i);let{boxParams:h,newPointList:z}=at(I,n,ot,void 0,S,f);h=E(rt({tool:it.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],f&&(z==null?void 0:z.length)&&(I.pointList=z);const nt=D.includes(I.attribute);$(h);const M=c(h),X=(C=e==null?void 0:e.polygonList)!=null?C:[];h.subAttribute=Gt.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(x=B==null?void 0:B.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(M!=null?M:[],X),nt?u([]):(u(h.id),F.selection.setSelectedIDs(I.id),Z({omitView:y.Top,polygon:I,boxParams:h,zoom:l,newPointCloudBoxList:M}),f&&ct(h,I,t,o)),R({newBoxParams:h})},kt=i=>{const{boxID:n,imageName:d,width:r,height:l,x:f,y:P}=i,C=m.find(h=>h.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(h=>h.imageName===d))return;const S=C.rects.map(h=>h.imageName===d?O(L({},h),{width:r,height:l,x:f,y:P}):h),F=O(L({},C),{rects:S}),I=m.map(h=>h.id===n?F:h);return t==null||t.updatePolygonList(I!=null?I:[]),I},Ut=i=>{const{boxID:n,imageName:d}=i,r=m.find(C=>C.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(C=>C.imageName!==d),f=O(L({},r),{rects:l}),P=m.map(C=>C.id===n?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},Tt=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(i||(_==null?void 0:_.info)){const P=i!=null?i:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){Z({omitView:y.Top,polygon:C,boxParams:P,newPointCloudBoxList:n});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(y.Top,C,P,void 0,r,B)}}},pt=(i,n,d)=>{if(ut){let r,l;switch(d){case y.Back:r=fo;break;case y.Side:r=Lt;break;default:r=Lt;break}if(l=r(i,n,ut,s.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(Jt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:S})}const P=E(rt({tool:it.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const x=St(l);return l=x.find(S=>S.id===l.id),Z({omitView:C?void 0:d,polygon:i,boxParams:l,newPointCloudBoxList:x}),x}},gt=(i,n,d)=>{if(J){let r,l;switch(d){case y.Back:r=go;break;case y.Side:r=vt;break;default:r=vt;break}l=r(i,n,J);const f=b(l);return Q(d,i,l,void 0,f,B),f}},zt=(i,n)=>{gt(i,n,y.Side)},jt=(i,n)=>{gt(i,n,y.Back)},Nt=(i,n)=>{pt(i,n,y.Side)},Et=(i,n)=>{pt(i,n,y.Back)},Ft=(i,n)=>{const d=N(i.id),r=dt(i,n,ot,d),l=b(r);Q(y.Top,i,r,void 0,l,B)},Ht=(i,n)=>{if(T){const r=L({},i[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,n)),U(r);return}let d=i.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=at(r,n,t.pointCloudInstance,l);return f});if(d=E(rt({tool:it.PointCloud,dataList:d,stepConfig:B,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=i[0],l=tt(d);Z({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=tt(d);r&&e.syncAllViewPointCloudColor(r)}},Wt=i=>{var n,d,r,l,f;if(_){const P=Number(i.widthDefault),C=Number(i.depthDefault),x=Number(i.heightDefault),S=_==null?void 0:_.info.trackID,I=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===S),h={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},z=I.pointList.map(Y=>V.transferCanvas2World(Y,h)),et=w.getModifiedRectangleCoordinates(z,x,P),nt=et[0],M=et[2],X=w.getLineCenterPoint([nt,M]),Zt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:X.x,y:X.y,z:Zt+C/2},width:P,height:x,depth:C,valid:!0}),Mt=tt([ft]);Z({omitView:y["3D"],polygon:I,boxParams:ft,newPointCloudBoxList:Mt})}},Q=(i,n,d,r,l,f)=>lt(void 0,null,function*(){const P=W==null?void 0:W.url,C={[y.Side]:()=>{yt(d,n,s,P,f)},[y.Back]:()=>{a&&bt(d,n,a,P,f)},[y.Top]:()=>{It(d,n,t,o)}};Object.keys(C).forEach(x=>{x!==i&&C[x]()}),r&&(o==null||o.updateCameraZoom(r)),Ot(d)}),Z=i=>lt(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:f}=i,P=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const C={[y.Side]:()=>{Bt(r,d,s,P)},[y.Back]:()=>{a&&wt(r,d,a,P)},[y.Top]:()=>{ct(r,d,t,o)}};Object.keys(C).forEach(x=>{x!==n&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(r)});return{topViewAddSphere:Rt,topViewAddBox:At,topViewSelectedChanged:Tt,topViewUpdatePoint:Ft,sideViewUpdatePoint:zt,backViewUpdatePoint:jt,topViewUpdateBox:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=V.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>lt(void 0,[...i],function*(n=W){var d,r,l,f,P,C;if(!(n==null?void 0:n.url)||!o)return;H([]),Ct(E,!0),Pt(E,!0),yield o.loadPCDFile(n.url,(d=B==null?void 0:B.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],S=[],F=[],I=[];o.updateTopCamera();const h=(l=(r=st(n.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(h),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),n.result){if(x=V.getBoxParamsFromResultList(n.result),(x==null?void 0:x.length)>0&&n.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(n.url,B,x);const z=st(n.result);z[Qt].result=x,n.result=JSON.stringify(z),e.setPointCloudResult(x)}F=V.getPolygonListFromResultList(n.result),S=V.getLineListFromResultList(n.result),I=V.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(C=B==null?void 0:B.radius)!=null?C:K}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(I),yield e.syncAllViewPointCloudColor(x,[])}j({pointCloudBoxList:x,polygonList:F,lineList:S,pointCloudSphereList:I}),Ct(E,!1),Pt(E,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:kt,remove2DViewRect:Ut}};export{bt as syncBackViewByPoint,yt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,Co as usePointCloudViews};
1
+ import{EPointCloudName as it,TagUtils as Qt,MathUtils as b,getCuboidFromPointCloudBox as Xt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Yt,DEFAULT_SPHERE_PARAMS as qt}from"@labelbee/lb-utils";import{useContext as Kt}from"react";import{PointCloudContext as $t}from"../PointCloudContext.js";import{useSingleBox as to}from"./useSingleBox.js";import{useSphere as oo}from"./useSphere.js";import{useSelector as eo,useDispatch as no}from"../../../store/ctx.js";import io from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as st}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as rt,generatePointCloudBoxRects as so}from"../../../utils/index.js";import{PreDataProcess as lt,SetPointCloudLoading as mt,SetLoadPCDFileLoading as xt}from"../../../store/annotation/actionCreators.js";import{useHistory as ro}from"./useHistory.js";import{usePolygon as lo}from"./usePolygon.js";import{useLatest as ao}from"ahooks";var co=Object.defineProperty,uo=Object.defineProperties,po=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,go=Object.prototype.hasOwnProperty,fo=Object.prototype.propertyIsEnumerable,vt=(e,t,s)=>t in e?co(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,L=(e,t)=>{for(var s in t||(t={}))go.call(t,s)&&vt(e,s,t[s]);if(ht)for(var s of ht(t))fo.call(t,s)&&vt(e,s,t[s]);return e},R=(e,t)=>uo(e,po(t)),dt=(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,Lt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,t,s,a,o)=>{const{x:c,y:g}=V.transferCanvas2World(e,t),{defaultZ:u}=qt,p={center:{x:c,y:g,z:u},id:e.id},m=a?L(L({},a),p):R(L({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},ct=(e,t,s,a,o,c)=>{let g=e.pointList.map(w=>V.transferCanvas2World(w,t)),u=0,p=1,m={};if(s){const w=s.getSensesPointZAxisInPolygon(g,void 0,c);c&&w.fittedCoordinates.length>0&&(g=w.fittedCoordinates),u=(w.maxZ+w.minZ)/2,p=w.maxZ-w.minZ,m={count:w.zCount}}const[v,D,F]=g,O=b.getLineCenterPoint([v,F]),A=b.getLineLength(v,D),j=b.getLineLength(D,F),k=b.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const U={center:{x:O.x,y:O.y,z:u},width:c?j+Lt:j,height:c?A+Lt:A,depth:p,rotation:k,id:e.id},T=L(a?L(L({},a),U):R(L({},U),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(w=>V.transferWorld2Canvas(w,t));return{boxParams:T,newPointList:N}},yt=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(L({},s),{center:{x:s.center.x-a.x,y:s.center.y,z:s.center.z-a.y}})},Bt=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=b.getLineCenterPoint([o,g]),D=b.getLineCenterPoint([u,m]),O={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},A=b.getLineLength(o,c),j=b.getLineLength(u,p),k=A-j,U=b.getLineLength(c,g),T=b.getLineLength(p,m),N=U-T,{newBoxParams:w}=a.getNewBoxBySideUpdate(O,N,k,s);return w},Co=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(L({},s),{center:{x:s.center.x,y:s.center.y-a.x,z:s.center.z-a.y}})},Po=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=b.getLineCenterPoint([o,g]),D=b.getLineCenterPoint([u,m]),O={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},A=b.getLineLength(o,c),j=b.getLineLength(u,p),k=A-j,U=b.getLineLength(c,g),T=b.getLineLength(p,m),N=U-T;let{newBoxParams:w}=a.getNewBoxByBackUpdate(O,N,k,s);return w},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.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([R(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,{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)},It=(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([R(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Dt=(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)},St=(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?R(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},ut=(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)},mo=()=>{const e=Kt($t),{topViewInstance:t,sideViewInstance:s,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:v,hideAttributes:D,setHighlight2DDataList:F,cuboidBoxIn2DView:O,imageSizes:A,history:j}=e,{addHistory:k,initHistory:U,pushHistoryUnderUpdatePolygon:T}=ro(),{selectedPolygon:N}=lo(),{getPointCloudSphereByID:w,updatePointCloudSphere:pt,selectedSphere:J}=oo(),{currentData:M,config:B}=eo(i=>{const{stepList:n,step:d,imgList:r,imgIndex:l}=i.annotation;return{currentData:r[l],config:rt(io.getCurrentStepInfo(d,n).config)}}),E=no(),_t=ao(O),$=i=>{const{enableAutoMap2DRect:n=!1}=B;if(!_t.current||n){const{mappingImgList:d=[]}=M;so({pointCloudBox:i,mappingImgList:d,imageSizes:A})}},{selectedBox:_,updateSelectedBox:Vt,updateSelectedBoxes:tt,getPointCloudByID:Rt}=to({generateRects:$}),gt=_==null?void 0:_.info;if(!t||!s||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Ot=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},At=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},kt=({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=at(i,n,ot,void 0,f);u(i.id);const C=g(P);Q(y.Top,i,P,d,C,B),k({newSphereParams:P})},Ut=({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 H=t==null?void 0:t.toolInstance,I=L({},i);let{boxParams:h,newPointList:z}=ct(I,n,ot,void 0,S,f);h=E(lt({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 Z=c(h),X=(C=e==null?void 0:e.polygonList)!=null?C:[];h.subAttribute=Qt.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(x=B==null?void 0:B.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(Z!=null?Z:[],X),nt?u([]):(u(h.id),H.selection.setSelectedIDs(I.id),W({omitView:y.Top,polygon:I,boxParams:h,zoom:l,newPointCloudBoxList:Z}),f&&ut(h,I,t,o)),k({newBoxParams:h})},Tt=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?R(L({},h),{width:r,height:l,x:f,y:P}):h),H=R(L({},C),{rects:S}),I=m.map(h=>h.id===n?H:h);return t==null||t.updatePolygonList(I!=null?I:[]),I},zt=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=R(L({},r),{rects:l}),P=m.map(C=>C.id===n?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},jt=({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){W({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)}}},ft=(i,n,d)=>{if(gt){let r,l;switch(d){case y.Back:r=Po;break;case y.Side:r=Bt;break;default:r=Bt;break}if(l=r(i,n,gt,s.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(Xt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=R(L({},l),{count:S})}const P=E(lt({tool:it.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const x=Vt(l);return l=x.find(S=>S.id===l.id),W({omitView:C?void 0:d,polygon:i,boxParams:l,newPointCloudBoxList:x}),x}},Ct=(i,n,d)=>{if(J){let r,l;switch(d){case y.Back:r=Co;break;case y.Side:r=yt;break;default:r=yt;break}l=r(i,n,J);const f=pt(l);return Q(d,i,l,void 0,f,B),f}},Nt=(i,n)=>{Ct(i,n,y.Side)},Et=(i,n)=>{Ct(i,n,y.Back)},Ht=(i,n)=>{ft(i,n,y.Side)},Ft=(i,n)=>{ft(i,n,y.Back)},Mt=(i,n)=>{const d=w(i.id),r=at(i,n,ot,d),l=pt(r);Q(y.Top,i,r,void 0,l,B)},Wt=(i,n)=>{if(N){const r=L({},i[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,n)),T(r);return}let d=i.map(({newPolygon:r})=>{const l=Rt(r.id),{boxParams:f}=ct(r,n,t.pointCloudInstance,l);return f});if(d=E(lt({tool:it.PointCloud,dataList:d,stepConfig:B,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=i[0],l=tt(d);W({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=tt(d);r&&e.syncAllViewPointCloudColor(st.MultiMove,r)}},Zt=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=b.getModifiedRectangleCoordinates(z,x,P),nt=et[0],Z=et[2],X=b.getLineCenterPoint([nt,Z]),Gt=_.info.center.z-_.info.depth/2,Pt=R(L({},_.info),{center:{x:X.x,y:X.y,z:Gt+C/2},width:P,height:x,depth:C,valid:!0}),Jt=tt([Pt]);W({omitView:y["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:Jt})}},Q=(i,n,d,r,l,f)=>dt(void 0,null,function*(){const P=M==null?void 0:M.url,C={[y.Side]:()=>{bt(d,n,s,P,f)},[y.Back]:()=>{a&&It(d,n,a,P,f)},[y.Top]:()=>{St(d,n,t,o)}};Object.keys(C).forEach(x=>{x!==i&&C[x]()}),r&&(o==null||o.updateCameraZoom(r)),At(d)}),W=i=>dt(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:f}=i,P=M==null?void 0:M.url;f&&(yield e.syncAllViewPointCloudColor(st.Single,f));const C={[y.Side]:()=>{wt(r,d,s,P)},[y.Back]:()=>{a&&Dt(r,d,a,P)},[y.Top]:()=>{ut(r,d,t,o)}};Object.keys(C).forEach(x=>{x!==n&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),Ot(r)});return{topViewAddSphere:kt,topViewAddBox:Ut,topViewSelectedChanged:jt,topViewUpdatePoint:Mt,sideViewUpdatePoint:Nt,backViewUpdatePoint:Et,topViewUpdateBox:Wt,sideViewUpdateBox:Ht,backViewUpdateBox:Ft,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)=>dt(void 0,[...i],function*(n=M){var d,r,l,f,P,C;if(!(n==null?void 0:n.url)||!o)return;F([]),mt(E,!0),xt(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=[],H=[],I=[];o.updateTopCamera();const h=(l=(r=rt(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=rt(n.result);z[Yt].result=x,n.result=JSON.stringify(z),e.setPointCloudResult(x)}H=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(st.Default,x,[])}U({pointCloudBoxList:x,polygonList:H,lineList:S,pointCloudSphereList:I}),mt(E,!1),xt(E,!1)}),updateViewsByDefaultSize:Zt,generateRects:$,update2DViewRect:Tt,remove2DViewRect:zt}};export{It as syncBackViewByPoint,bt as syncSideViewByPoint,St as syncTopViewByPoint,Dt as synchronizeBackView,wt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,mo as usePointCloudViews};
@@ -1 +1 @@
1
- import{useContext as p}from"react";import{synchronizeSideView as C,synchronizeBackView as P}from"./usePointCloudViews.js";import{useSingleBox as w}from"./useSingleBox.js";import{PointCloudContext as x}from"../PointCloudContext.js";import{cAnnotation as f}from"@labelbee/lb-annotation";import{PointCloudUtils as b}from"@labelbee/lb-utils";import{useThrottleFn as V}from"ahooks";const{ERotateDirection:g}=f,y=({currentData:t})=>{const e=p(x),{selectedBox:i,updateSelectedBox:u}=w(),{run:a}=V(l=>{const{topViewInstance:s,mainViewInstance:n,syncAllViewPointCloudColor:d}=e;if(!s||!n)return;const{pointCloud2dOperation:r}=s,o=i==null?void 0:i.info;if(!o||!(t==null?void 0:t.url)||!e.backViewInstance)return;const m=u({rotation:b.restrictAngleRange(o.rotation+Number(Math.PI*l)/180)});r.rotatePolygon(l,g.Anticlockwise);const c=r.selectedPolygon;n.generateBox(o),d(m),C(o,c,e.sideViewInstance,t.url),P(o,c,e.backViewInstance,t.url),n.render()},{wait:800});return{updateRotate:a}};export{y as useRotate};
1
+ import{useContext as p}from"react";import{synchronizeSideView as C,synchronizeBackView as P}from"./usePointCloudViews.js";import{useSingleBox as x}from"./useSingleBox.js";import{PointCloudContext as w}from"../PointCloudContext.js";import{cAnnotation as f}from"@labelbee/lb-annotation";import{PointCloudUtils as g}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as b}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{useThrottleFn as B}from"ahooks";const{ERotateDirection:V}=f,y=({currentData:t})=>{const e=p(w),{selectedBox:i,updateSelectedBox:u}=x(),{run:d}=B(l=>{const{topViewInstance:r,mainViewInstance:n,syncAllViewPointCloudColor:a}=e;if(!r||!n)return;const{pointCloud2dOperation:s}=r,o=i==null?void 0:i.info;if(!o||!(t==null?void 0:t.url)||!e.backViewInstance)return;const m=u({rotation:g.restrictAngleRange(o.rotation+Number(Math.PI*l)/180)});s.rotatePolygon(l,V.Anticlockwise);const c=s.selectedPolygon;n.generateBox(o),a(b.SingleRotate,m),C(o,c,e.sideViewInstance,t.url),P(o,c,e.backViewInstance,t.url),n.render()},{wait:800});return{updateRotate:d}};export{y as useRotate};
@@ -1 +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
+ import{useContext as g}from"react";import{synchronizeSideView as m,synchronizeBackView as P}from"./usePointCloudViews.js";import{useSingleBox as h}from"./useSingleBox.js";import{PointCloudContext as w}from"../PointCloudContext.js";import{useThrottleFn as x}from"ahooks";import{PointCloudUtils as C}from"@labelbee/lb-utils";const f=({currentData:t})=>{const e=g(w),{selectedBox:l,updateSelectedBox:c}=h(),{run:u}=x(a=>{const{topViewInstance:r,mainViewInstance:i}=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),c({newPointList:n,rotation:C.restrictAngleRange(o.rotation+Number(Math.PI*a)/180),width:o.height,height:o.width}),s.rotatePolygonEdge(n);const d=s.selectedPolygon;i.generateBox(o),m(o,d,e.sideViewInstance,t.url),P(o,d,e.backViewInstance,t.url),i.render()},{wait:800});return{updateRotateEdge:u}};export{f as useRotateEdge};
@@ -1 +1 @@
1
- import{useContext as ie,useMemo as A,useCallback as f}from"react";import m from"lodash";import{PointCloudContext as de}from"../PointCloudContext.js";import{EToolName as M,cAnnotation as le}from"@labelbee/lb-annotation";import{useHistory as se}from"./useHistory.js";import{usePolygon as re}from"./usePolygon.js";var ae=Object.defineProperty,ce=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,T=(d,t,l)=>t in d?ae(d,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[t]=l,ge=(d,t)=>{for(var l in t||(t={}))fe.call(t,l)&&T(d,l,t[l]);if(H)for(var l of H(t))pe.call(t,l)&&T(d,l,t[l]);return d},ve=(d,t)=>ce(d,ue(t));const{ESortDirection:B}=le,xe=d=>{const{pointCloudBoxList:t,setPointCloudResult:l,topViewInstance:r,backViewInstance:_,sideViewInstance:h,selectedIDs:y,selectedID:O,mainViewInstance:p,setSelectedIDs:k,syncAllViewPointCloudColor:R,polygonList:K,pointCloudPattern:V,rectList:D,updateRectIn2DView:Pe,removeRectIn2DView:U,addRectIn2DView:F,updateRectListByReducer:S}=ie(de),{selectedPolygon:g,updateSelectedPolygon:W,updatePolygonValidByID:q,deletePolygon:z}=re(),{pushHistoryWithList:b}=se(),a=A(()=>{const e=t.findIndex(n=>n.id===O);if(e>-1)return{info:t[e],index:e}},[O,t]),L=f(e=>{var n;if(a==null?void 0:a.info){(n=d==null?void 0:d.generateRects)==null||n.call(d,e),t.splice(a.index,1,m.merge(a.info,e));const o=m.cloneDeep(t);return l(o),b({pointCloudBoxList:o}),o}return t},[O,t]),G=f((e,n)=>{const o=t.findIndex(i=>i.id===n);if(o>-1){t.splice(o,1,m.merge(t[o],e));const i=m.cloneDeep(t);return l(i),i}return t},[t]),w=f(e=>{r==null||r.pointCloud2dOperation.setPolygonValidAndRender(e,!0),h==null||h.pointCloud2dOperation.setPolygonValidAndRender(e,!0),_==null||_.pointCloud2dOperation.setPolygonValidAndRender(e,!0)},[r,h,_]),J=f(()=>{if(a==null?void 0:a.info){const{id:e,valid:n=!0}=a.info,o=L({valid:!n});R(o),w(e)}g&&(W(ve(ge({},g),{valid:!g.valid})),r==null||r.pointCloud2dOperation.setPolygonValidAndRender(g.id,!0))},[w,a,g]),Q=f(e=>{const n=t.find(o=>o.id===e);if(n){const{id:o,valid:i=!0}=n,c=G({valid:!i},o);return w(o),c}q(e)},[w,t,K]),E=f((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:o}=r,i=o.switchToNextPolygon(e);i&&k(i)},[r,V,r==null?void 0:r.toolInstance]),X=(e=!1)=>{E(B.descend,e)},Y=(e=!1)=>{E(B.ascend,e)},N=(e,n=!0)=>{const o=t.filter(i=>i.id!==e);if(l(o),p==null||p.removeObjectByName(e,"box"),p==null||p.render(),R(o),n){const i=D.filter(s=>s.extId===e),c=new Set(i.map(s=>s.id));S(j(c))}},j=e=>(n,o)=>{let i=!1;const c=n.map(s=>e.has(s.id)?(i=!0,o(s)):s);return i?c:n},Z=f((e,n)=>{var o,i;const c=new Set((i=(o=n.mappingImgList)==null?void 0:o.map(u=>u.path))!=null?i:[]),s=new Map;e.forEach(u=>{const I=u.id;(u.rects||[]).forEach(C=>{const{imageName:P}=C;if(c.has(P)){let x=s.get(P);x||(x=new Set,s.set(P,x)),x.add(I)}})});const v=D.filter(u=>{var I;const C=u.extId,P=u.imageName;if(P!==void 0&&C!==void 0){const x=s.get(P);return(I=x==null?void 0:x.has(C))!=null?I:!1}return!1}),ne=new Set(v.map(u=>u.id));S(j(ne))},[D,U,F]),$=e=>{a&&(N(a.info.id,!1),r==null||r.pointCloud2dOperation.deletePolygon(a.info.id),Z([a.info],e)),g&&(z(g.id),r==null||r.pointCloud2dOperation.deletePolygon(g.id))},ee=A(()=>t.filter(e=>y.includes(e.id)),[y,t]),te=f(e=>{var n;const o=m.cloneDeep(t);let i=!1;for(const c of e){const s=o.findIndex(v=>v.id===c.id);if(s>-1){const v=m.merge(o[s],c);(n=d==null?void 0:d.generateRects)==null||n.call(d,v),o.splice(s,1,v),p==null||p.generateBox(v),i=!0}}if(i)return l(o),b({pointCloudBoxList:o}),p==null||p.render(),o},[y,t]),oe=f(e=>t.find(n=>n.id===e),[t]);return{selectedBox:a,updateSelectedBox:L,changeSelectedBoxValid:J,changeValidByID:Q,selectNextBox:Y,selectPrevBox:X,deletePointCloudBox:N,selectedBoxes:ee,updateSelectedBoxes:te,getPointCloudByID:oe,deleteSelectedPointCloudBoxAndPolygon:$}};export{xe as useSingleBox};
1
+ import{useContext as de,useMemo as A,useCallback as f}from"react";import m from"lodash";import{PointCloudContext as le}from"../PointCloudContext.js";import{EToolName as T,cAnnotation as re}from"@labelbee/lb-annotation";import{useHistory as se}from"./useHistory.js";import{usePolygon as ae}from"./usePolygon.js";import{EPointCloudBoxRenderTrigger as H}from"../../../utils/ToolPointCloudBoxRenderHelper.js";var ce=Object.defineProperty,ue=Object.defineProperties,fe=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,k=(d,t,l)=>t in d?ce(d,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[t]=l,xe=(d,t)=>{for(var l in t||(t={}))pe.call(t,l)&&k(d,l,t[l]);if(M)for(var l of M(t))ge.call(t,l)&&k(d,l,t[l]);return d},Pe=(d,t)=>ue(d,fe(t));const{ESortDirection:B}=re,ve=d=>{const{pointCloudBoxList:t,setPointCloudResult:l,topViewInstance:s,backViewInstance:_,sideViewInstance:h,selectedIDs:y,selectedID:O,mainViewInstance:p,setSelectedIDs:K,syncAllViewPointCloudColor:V,polygonList:U,pointCloudPattern:R,rectList:S,updateRectIn2DView:me,removeRectIn2DView:F,addRectIn2DView:W,updateRectListByReducer:D}=de(le),{selectedPolygon:g,updateSelectedPolygon:q,updatePolygonValidByID:z,deletePolygon:G}=ae(),{pushHistoryWithList:b}=se(),a=A(()=>{const e=t.findIndex(n=>n.id===O);if(e>-1)return{info:t[e],index:e}},[O,t]),L=f(e=>{var n;if(a==null?void 0:a.info){(n=d==null?void 0:d.generateRects)==null||n.call(d,e),t.splice(a.index,1,m.merge(a.info,e));const o=m.cloneDeep(t);return l(o),b({pointCloudBoxList:o}),o}return t},[O,t]),J=f((e,n)=>{const o=t.findIndex(i=>i.id===n);if(o>-1){t.splice(o,1,m.merge(t[o],e));const i=m.cloneDeep(t);return l(i),i}return t},[t]),w=f(e=>{s==null||s.pointCloud2dOperation.setPolygonValidAndRender(e,!0),h==null||h.pointCloud2dOperation.setPolygonValidAndRender(e,!0),_==null||_.pointCloud2dOperation.setPolygonValidAndRender(e,!0)},[s,h,_]),Q=f(()=>{if(a==null?void 0:a.info){const{id:e,valid:n=!0}=a.info,o=L({valid:!n});V(H.SingleToggleValid,o),w(e)}g&&(q(Pe(xe({},g),{valid:!g.valid})),s==null||s.pointCloud2dOperation.setPolygonValidAndRender(g.id,!0))},[w,a,g]),X=f(e=>{const n=t.find(o=>o.id===e);if(n){const{id:o,valid:i=!0}=n,c=J({valid:!i},o);return w(o),c}z(e)},[w,t,U]),E=f((e=B.ascend,n=!1)=>{if(!s||y.length>1)return;if(R!==T.Rect&&R!==T.Polygon){n&&document.dispatchEvent(new KeyboardEvent("keydown",{keyCode:9,shiftKey:e!==B.ascend}));return}const{pointCloud2dOperation:o}=s,i=o.switchToNextPolygon(e);i&&K(i)},[s,R,s==null?void 0:s.toolInstance]),Y=(e=!1)=>{E(B.descend,e)},Z=(e=!1)=>{E(B.ascend,e)},N=(e,n=!0)=>{const o=t.filter(i=>i.id!==e);if(l(o),p==null||p.removeObjectByName(e,"box"),p==null||p.render(),V(H.SingleDelete,o),n){const i=S.filter(r=>r.extId===e),c=new Set(i.map(r=>r.id));D(j(c))}},j=e=>(n,o)=>{let i=!1;const c=n.map(r=>e.has(r.id)?(i=!0,o(r)):r);return i?c:n},$=f((e,n)=>{var o,i;const c=new Set((i=(o=n.mappingImgList)==null?void 0:o.map(u=>u.path))!=null?i:[]),r=new Map;e.forEach(u=>{const I=u.id;(u.rects||[]).forEach(C=>{const{imageName:v}=C;if(c.has(v)){let P=r.get(v);P||(P=new Set,r.set(v,P)),P.add(I)}})});const x=S.filter(u=>{var I;const C=u.extId,v=u.imageName;if(v!==void 0&&C!==void 0){const P=r.get(v);return(I=P==null?void 0:P.has(C))!=null?I:!1}return!1}),ie=new Set(x.map(u=>u.id));D(j(ie))},[S,F,W]),ee=e=>{a&&(N(a.info.id,!1),s==null||s.pointCloud2dOperation.deletePolygon(a.info.id),$([a.info],e)),g&&(G(g.id),s==null||s.pointCloud2dOperation.deletePolygon(g.id))},te=A(()=>t.filter(e=>y.includes(e.id)),[y,t]),oe=f(e=>{var n;const o=m.cloneDeep(t);let i=!1;for(const c of e){const r=o.findIndex(x=>x.id===c.id);if(r>-1){const x=m.merge(o[r],c);(n=d==null?void 0:d.generateRects)==null||n.call(d,x),o.splice(r,1,x),p==null||p.generateBox(x),i=!0}}if(i)return l(o),b({pointCloudBoxList:o}),p==null||p.render(),o},[y,t]),ne=f(e=>t.find(n=>n.id===e),[t]);return{selectedBox:a,updateSelectedBox:L,changeSelectedBoxValid:Q,changeValidByID:X,selectNextBox:Z,selectPrevBox:Y,deletePointCloudBox:N,selectedBoxes:te,updateSelectedBoxes:oe,getPointCloudByID:ne,deleteSelectedPointCloudBoxAndPolygon:ee}};export{ve as useSingleBox};
@@ -1 +1 @@
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
+ import{useContext as x,useMemo as P}from"react";import{PointCloudContext as E}from"../PointCloudContext.js";import{cTool as I}from"@labelbee/lb-annotation";import{useHistory as T}from"./useHistory.js";import{EPointCloudPattern as C}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as A}from"../../../utils/ToolPointCloudBoxRenderHelper.js";const{EToolName:t,EPolygonPattern:p}=I,V=()=>{const{topViewInstance:s,sideViewInstance:a,backViewInstance:u,mainViewInstance:e,setPointCloudResult:m,setPointCloudSphereList:v,setPolygonList:h,setRectList:b,pointCloudPattern:c,setPointCloudPattern:l,syncAllViewPointCloudColor:g,globalPattern:n,setLineList:L}=x(E),{pushHistoryWithList:R}=T(),f=()=>{e==null||e.clearAllBox(),e==null||e.clearAllSphere(),e==null||e.render(),m([]),h([]),v([]),L([]),b([]),s==null||s.toolScheduler.clearStatusAndResult(),g(A.ClearAll,[]),R({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},i=()=>{a==null||a.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()},w=d=>{if(d===c)return;const r=[s,a,u];switch(d){case t.Rect:i(),r.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(p.Rect)}),l(t.Rect);break;case t.Polygon:i(),r.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(p.Normal)}),l(t.Polygon);break;case t.Point:i(),r.forEach(o=>{o==null||o.switchToCanvas(t.Point)}),l(t.Point);break;case t.Line:i(),r.forEach(o=>{o==null||o.switchToCanvas(t.Line)}),l(t.Line);break}},y=P(()=>n===C.Detection,[n]),S=P(()=>n===C.Segmentation,[n]);return{clearAllResult:f,updatePointCloudPattern:w,pointCloudPattern:c,isPointCloudDetectionPattern:y,isPointCloudSegmentationPattern:S}};export{V as useStatus};
@@ -0,0 +1 @@
1
+ import{getCuboidFromPointCloudBox as p}from"@labelbee/lb-annotation";var I=Object.defineProperty,_=Object.defineProperties,M=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,m=(e,t,n)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))S.call(t,n)&&m(e,n,t[n]);if(x)for(var n of x(t))O.call(t,n)&&m(e,n,t[n]);return e},A=(e,t)=>_(e,M(t)),s;(function(e){e.Default="Default",e.UndoRedo="UndoRedo",e.ClearAll="ClearAll",e.Single="Single",e.SingleDelete="SingleDelete",e.SingleToggleValid="SingleToggleValid",e.SingleRotate="SingleRotate",e.MultiPaste="MultiPaste",e.MultiMove="MultiMove"})(s||(s={}));var c;(function(e){e.ChangeAttribute="ChangeAttribute",e.Move="Move",e.ChangeDepth="ChangeDepth",e.ChangeSize="ChangeSize"})(c||(c={}));const D=e=>{const n=Math.max(e.width,e.height)/Math.sqrt(2);return A(b({},e),{width:n*2,height:n*2})},P=(e,t)=>{const n=v(e).concat(v(t));for(const o of n){const r=y(e,o),i=y(t,o);if(!C(r,i))return!1}return!0},v=e=>{const t=[];for(let n=0;n<e.length;n++){const o=e[n],r=e[(n+1)%e.length],i={x:r.x-o.x,y:r.y-o.y},a={x:-i.y,y:i.x};t.push(a)}return t},y=(e,t)=>{let n=B(e[0],t),o=n;for(const r of e){const i=B(r,t);i<n&&(n=i),i>o&&(o=i)}return{min:n,max:o}},C=(e,t)=>!(e.max<t.min||t.max<e.min),B=(e,t)=>e.x*t.x+e.y*t.y,j=(e,t)=>{const n=[];return t.forEach(o=>{const{polygonPointList:r}=p(o);P(e,r)&&n.push(o.id)}),n},w=(e,t)=>{const n=e.map(r=>r.id),o=t.map(r=>r.id);return n.find(r=>!o.includes(r))||""},R=(e,t)=>{const n=e.map(o=>o.id);return t.find(o=>!n.includes(o.id))},l=(e,t)=>e.find(o=>{const r=t.find(i=>i.id===o.id);return r&&(r.rotation!==o.rotation||r.valid!==o.valid)}),u=(e,t)=>{const n=D(e),o=p(n);return{ids:j(o.polygonPointList,t.filter(i=>i.id!==e.id)),rect:o.polygonPointList}},k=(e,t)=>{const n=(o,r)=>o.attribute===r.attribute&&o.center.x===r.center.x&&o.center.y===r.center.y&&o.depth===r.depth&&o.width===r.width&&o.height===r.height;for(const o of e){const r=t.find(i=>i.id===o.id);if(r&&!n(o,r)){let i;if(r.attribute!==o.attribute?i=c.ChangeAttribute:r.center.x!==o.center.x||r.center.y!==o.center.y?i=c.Move:r.depth!==o.depth?i=c.ChangeDepth:(r.width!==o.width||r.height!==o.height)&&(i=c.ChangeSize),i!==void 0)return{modifiedType:i,box:o}}}},V=(e,t,n)=>{const o=[],r=[];try{switch(e){case s.Single:if(t.length>n.length){const i=w(t,n);i&&r.push(i)}else{const i=k(t,n);if(i&&(r.push(i.box.id),t.length>1&&(i.modifiedType===c.ChangeSize||i.modifiedType===c.Move))){const a=n.find(g=>g.id===i.box.id),d=n.filter(g=>g.id!==i.box.id),{ids:h,rect:f}=u(a,d);r.push(...h),o.push(f)}}break;case s.SingleDelete:if(t.length<n.length){const i=R(t,n);if(i){const a=p(i);if(o.push(a.polygonPointList),t.length>1){const{ids:d}=u(i,n);d.length&&r.push(...d)}}}break;case s.SingleRotate:if(l(t,n)){const i=l(t,n);if(r.push(i.id),t.length>1){const a=n.filter(f=>f.id!==i.id),{ids:d,rect:h}=u(i,a);r.push(...d),o.push(h)}}break;case s.SingleToggleValid:if(l(t,n)){const i=l(t,n);r.push(i.id)}break;case s.MultiPaste:case s.MultiMove:break;case s.Default:case s.UndoRedo:case s.ClearAll:default:break}}catch(i){return console.error("calcResetAreasAndBoxIds error:",i),{resetAreas:o,modifiedBoxIds:r}}return{resetAreas:o,modifiedBoxIds:r}};export{s as EPointCloudBoxRenderTrigger,c as EPointCloudBoxSingleModifiedType,V as calcResetAreasAndBoxIds};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.56",
3
+ "version": "1.23.0-alpha.58",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.27.0-alpha.28",
46
+ "@labelbee/lb-annotation": "1.27.0-alpha.30",
47
47
  "@labelbee/lb-utils": "1.19.0-alpha.18",
48
48
  "@labelbee/wavesurfer": "1.0.0",
49
49
  "@types/react-dom": "^18.2.7",