@labelbee/lb-components 1.24.0-alpha.23 → 1.24.0-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "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"),useTimeoutFunc=require("./hooks/useTimeoutFunc.js"),useWindowKeydownListener=require("./hooks/useWindowKeydownListener.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,s,c)=>s in r?__defProp(r,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):r[s]=c,__spreadValues=(r,s)=>{for(var c in s||(s={}))__hasOwnProp.call(s,c)&&__defNormalProp(r,c,s[c]);if(__getOwnPropSymbols)for(var c of __getOwnPropSymbols(s))__propIsEnum.call(s,c)&&__defNormalProp(r,c,s[c]);return r},__spreadProps=(r,s)=>__defProps(r,__getOwnPropDescs(s)),__async=(r,s,c)=>new Promise((x,B)=>{var D=u=>{try{P(c.next(u))}catch(R){B(R)}},E=u=>{try{P(c.throw(u))}catch(R){B(R)}},P=u=>u.done?x(u.value):Promise.resolve(u.value).then(D,E);P((c=c.apply(r,s)).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,visibleBatchSetValid:!1,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setBatchSetValidModal:()=>{},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:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,s,c)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),PointCloudProvider=({children:r})=>{const[s,c]=React.useState([]),[x,B]=React.useState([]),[D,E]=React.useState([]),[P,u]=React.useState([]),[R,Be]=React.useState([]),[v,K]=React.useState([]),[A,O]=React.useState([]),[U,De]=React.useState(!0),[Z,Ae]=React.useState(2),[J,_e]=React.useState(!0),[Q,Ve]=React.useState(1),[f,X]=React.useState(),[Y,$]=React.useState(),[ee,te]=React.useState(),[g,oe]=React.useState(),[ne,Ne]=React.useState(""),[j,He]=React.useState(lbAnnotation.EToolName.Rect),F=React.useRef(new lbAnnotation.ActionsHistory).current,[h,q]=React.useState([]),[ie,Me]=React.useState(""),[T,ke]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,se]=React.useState(void 0),[z,Ee]=React.useState([]),[W,Oe]=React.useState([]),[re,je]=React.useState(!1),[ae,le]=React.useState(!1),p=index(),[de,Fe]=React.useState(!1),[ce,qe]=React.useState({}),Te=ctx.useDispatch(),ze=o=>{const{imgNode:n,path:t}=o;t&&n&&qe(l=>__spreadProps(__spreadValues({},l),{[t]:{width:n.width,height:n.height}}))},ue=React.useMemo(()=>v.length===1?v[0]:"",[v]),ge=useWindowKeydownListener.default(),N=React.useCallback((o,n,t="extId")=>{const l=t||"id",d=new Set(n);return u(a=>{let I=!1;const S=a.filter(M=>{const G=M[l],k=d.has(G)?M.imageName!==o:!0;return k||(I=!0),k});return I?S:a}),!0},[]),fe=React.useCallback(o=>{const n=s.map(t=>t.id);return N(o,n,"extId")},[s,N]),he=React.useCallback(o=>{if(!o)return!1;const n=s.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:l,attribute:d,trackID:a}=t,I=t.rects.find(S=>S.imageName===o);if(I){const S=___default.default.pick(I,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},S),{id:lbAnnotation.uuid(),attribute:d,order:a,extId:l,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(u(t=>{const l=new Set(t.filter(a=>o===a.imageName).map(a=>a.extId)),d=n.filter(a=>l.has(a.extId)===!1);return d.length?[...t,...d]:t}),!0):!1},[s]),pe=React.useMemo(()=>s.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var l;return(l=t.rects)==null||l.forEach(d=>{const{imageName:a}=d;if(!a){console.warn("Missing image name"),console.trace(d,t);return}map.addMapIndirectWeakSetItem(n,a,t.id,t)}),n},new Map),[s]),me=React.useCallback(o=>{u(n=>o(n,pickRectObject))},[pickRectObject]),ve=React.useMemo(()=>P.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(map.addMapIndirectWeakSetItem(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,P),o)},new Map),[P]),{fn:We}=useTimeoutFunc.default(o=>{K(n=>{const t=o,l=new Set(t);let d=!1;const a=n.filter(I=>{const S=l.has(I);return S||(d=!0),S});return d?a:n})},200),Se=React.useCallback(o=>{const n=o.map(t=>t.id);c(o),We(n)},[]),H=React.useMemo(()=>{const o=s.find(e=>e.id===ue),n=e=>{const i=s.concat(e);return Se(i),i},t=e=>{const i=x.concat(e);return B(i),i},l=e=>{De(e!==!1)},d=e=>{Fe(e)},a=e=>{let i=[];e===void 0||e===""?i=[]:typeof e=="string"?i=[e]:Array.isArray(e)&&(i=e.length>1?Array.from(new Set(e)):e),K(i)},I=e=>{v.includes(e)?a(v.filter(i=>i!==e)):a([...v,e])},S=e=>{const i=pickRectObject(e);u(m=>[...m,i])},M=(e,i=!1)=>{const m=pickRectObject(e);u(C=>C.map(w=>w.id===e.id?i?__spreadValues(__spreadValues({},w),m):m:w))},G=e=>{u(i=>i.filter(m=>!e.find(C=>C.id===m.id)))},k=e=>{A.includes(e)?O([]):O([e])},Ke=()=>{if(j===lbAnnotation.EToolName.Rect){const e=s.map(i=>i.id);a(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},Ue=e=>{a(s.filter(i=>i.attribute===e).map(i=>i.id))},Pe=s.filter(e=>!h.includes(e.attribute)),Ie=x.filter(e=>!h.includes(e.attribute)),Ce=R.filter(e=>e.attribute&&!h.includes(e.attribute)),Ze=e=>{if(h.includes(e))q(h.filter(i=>i!==e));else{const i=h.concat(e);q(i)}},Je=(e=Pe,i=D,m=Ie,C=Ce,w=z)=>{var V;g==null||g.clearAllBox(),g==null||g.clearAllSphere(),f==null||f.updatePolygonList(e,i),f==null||f.updatePointList(m),f==null||f.updateLineList(C),g==null||g.generateBoxes(e),g==null||g.generateSpheres(m),(V=L==null?void 0:L.store)==null||V.updateCurrentSegment(w),we(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},Qe=()=>{X(void 0),$(void 0),te(void 0),oe(void 0)},we=(e,i,m)=>__async(void 0,null,function*(){var C,w,V;if(!g)return;const be=g.pointCloudObject;if(!be)return;let ye=[],Re=[];try{if(i&&F.record.length){const{record:b,recordIndex:y}=F;let xe=y;y>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&i.length===((C=b[y])==null?void 0:C.pointCloudBoxList.length))&&(xe=y-1);let Xe=(w=b[xe])==null?void 0:w.pointCloudBoxList;const Le=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,i,Xe);ye=Le.modifiedBoxIds,Re=Le.resetAreas}}catch(b){console.error("call calcResetAreasAndBoxIds error",b)}try{const b=yield g.getHighlightIndexByMappingImgList({mappingImgList:m!=null?m:W,points:be.geometry.attributes.position.array}),y=yield g==null?void 0:g.highlightOriginPointCloud(i,b,{modifiedBoxIds:ye,resetAreas:Re});return y&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(y)),y}catch(b){console.error("call highlightOriginPointCloud error",b)}});return{selectedID:ue,pointCloudBoxList:s,pointCloudSphereList:x,displayPointCloudList:Pe,displaySphereList:Ie,displayLineList:Ce,selectedIDs:v,setPointCloudResult:Se,setSelectedIDs:a,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:B,valid:U,visibleBatchSetValid:de,selectedPointCloudBox:o,setPointCloudValid:l,setBatchSetValidModal:d,addSelectedID:I,addHighlightID:k,selectedAllBoxes:Ke,topViewInstance:f,setTopViewInstance:X,sideViewInstance:Y,setSideViewInstance:$,backViewInstance:ee,setBackViewInstance:te,mainViewInstance:g,setMainViewInstance:oe,polygonList:D,setPolygonList:E,rectList:P,setRectList:u,addRectIn2DView:S,removeRectIn2DView:G,updateRectIn2DView:M,lineList:R,setLineList:Be,zoom:Q,setZoom:Ve,history:F,toggleAttributesVisible:Ze,hideAttributes:h,setHideAttributes:q,reRender:Je,attrPanelLayout:ie,setAttrPanelLayout:Me,syncAllViewPointCloudColor:we,defaultAttribute:ne,setDefaultAttribute:Ne,pointCloudPattern:j,setPointCloudPattern:He,selectSpecAttr:Ue,globalPattern:T,setGlobalPattern:e=>{T!==e&&(Te(actionCreators.ChangeSave),ke(e),e===lbUtils.EPointCloudPattern.Detection&&se(void 0))},ptSegmentInstance:L,setPtSegmentInstance:se,segmentation:z,setSegmentation:Ee,clearAllDetectionInstance:Qe,highlight2DDataList:W,setHighlight2DDataList:Oe,highlight2DLoading:re,setHighlight2DLoading:je,cuboidBoxIn2DView:J,setCuboidBoxIn2DView:_e,imageSizes:ce,cacheImageNodeSize:ze,highlightIDs:A,setHighlightIDs:O,removeRectByPointCloudBoxId:fe,removeRectBySpecifyId:N,addRectFromPointCloudBoxByImageName:he,rectRotateSensitivity:Z,setRectRotateSensitivity:Ae,imageNamePointCloudBoxMap:pe,linkageImageNameRectMap:ve,updateRectListByReducer:me,windowKeydownListenerHook:ge,isLargeStatus:ae,setIsLargeStatus:le}},[U,de,v,s,x,D,R,P,f,Y,ee,g,Q,h,ie,ne,j,T,L,z,W,re,J,ce,A,fe,N,he,Z,pe,ve,me,ge,ae,le]);React.useEffect(()=>{var o,n,t;(o=p==null?void 0:p.setPointCloudBoxList)==null||o.call(p,s),(n=p==null?void 0:p.setHighlightIDs)==null||n.call(p,A),(t=p==null?void 0:p.setSelectedIDs)==null||t.call(p,v)},[s,v,A]),React.useEffect(()=>{var o;(o=p==null?void 0:p.setPtCtx)==null||o.call(p,H)},[H]);const Ge=()=>{const o=s.filter(d=>h.includes(d.attribute)),{setSelectedIDs:n,reRender:t}=H,l=o.map(d=>d.id);l.length>0&&n(v.filter(d=>!l.includes(d))),t()};return React.useEffect(()=>{var o,n,t,l;Ge(),(n=(o=f==null?void 0:f.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,h),(l=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||l.call(t,h)},[h]),React__default.default.createElement(PointCloudContext.Provider,{value:H},r)};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"),useTimeoutFunc=require("./hooks/useTimeoutFunc.js"),useWindowKeydownListener=require("./hooks/useWindowKeydownListener.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,s,c)=>s in r?__defProp(r,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):r[s]=c,__spreadValues=(r,s)=>{for(var c in s||(s={}))__hasOwnProp.call(s,c)&&__defNormalProp(r,c,s[c]);if(__getOwnPropSymbols)for(var c of __getOwnPropSymbols(s))__propIsEnum.call(s,c)&&__defNormalProp(r,c,s[c]);return r},__spreadProps=(r,s)=>__defProps(r,__getOwnPropDescs(s)),__async=(r,s,c)=>new Promise((x,B)=>{var A=u=>{try{P(c.next(u))}catch(y){B(y)}},O=u=>{try{P(c.throw(u))}catch(y){B(y)}},P=u=>u.done?x(u.value):Promise.resolve(u.value).then(A,O);P((c=c.apply(r,s)).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,visibleBatchSetValid:!1,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setBatchSetValidModal:()=>{},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:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,s,c)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),PointCloudProvider=({children:r})=>{const[s,c]=React.useState([]),[x,B]=React.useState([]),[A,O]=React.useState([]),[P,u]=React.useState([]),[y,Be]=React.useState([]),[v,Z]=React.useState([]),[V,j]=React.useState([]),[J,Ae]=React.useState(!0),[Q,_e]=React.useState(2),[X,Ve]=React.useState(!0),[Y,Ne]=React.useState(1),[f,$]=React.useState(),[ee,te]=React.useState(),[oe,ne]=React.useState(),[g,ie]=React.useState(),[se,He]=React.useState(""),[F,Me]=React.useState(lbAnnotation.EToolName.Rect),q=React.useRef(new lbAnnotation.ActionsHistory).current,[h,T]=React.useState([]),[re,ke]=React.useState(""),[z,Ee]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,ae]=React.useState(void 0),[W,Oe]=React.useState([]),[G,je]=React.useState([]),[le,Fe]=React.useState(!1),[de,ce]=React.useState(!1),p=index(),[ue,qe]=React.useState(!1),[ge,Te]=React.useState({}),ze=ctx.useDispatch(),We=o=>{const{imgNode:n,path:t}=o;t&&n&&Te(l=>__spreadProps(__spreadValues({},l),{[t]:{width:n.width,height:n.height}}))},fe=React.useMemo(()=>v.length===1?v[0]:"",[v]),he=useWindowKeydownListener.default(),H=React.useCallback((o,n,t="extId")=>{const l=t||"id",d=new Set(n);return u(a=>{let I=!1;const S=a.filter(k=>{const K=k[l],E=d.has(K)?k.imageName!==o:!0;return E||(I=!0),E});return I?S:a}),!0},[]),pe=React.useCallback(o=>{const n=s.map(t=>t.id);return H(o,n,"extId")},[s,H]),me=React.useCallback(o=>{if(!o)return!1;const n=s.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:l,attribute:d,trackID:a}=t,I=t.rects.find(S=>S.imageName===o);if(I){const S=___default.default.pick(I,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},S),{id:lbAnnotation.uuid(),attribute:d,order:a,extId:l,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(u(t=>{const l=new Set(t.filter(a=>o===a.imageName).map(a=>a.extId)),d=n.filter(a=>l.has(a.extId)===!1);return d.length?[...t,...d]:t}),!0):!1},[s]),ve=React.useMemo(()=>s.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var l;return(l=t.rects)==null||l.forEach(d=>{const{imageName:a}=d;if(!a){console.warn("Missing image name"),console.trace(d,t);return}map.addMapIndirectWeakSetItem(n,a,t.id,t)}),n},new Map),[s]),Se=React.useCallback(o=>{u(n=>o(n,pickRectObject))},[pickRectObject]),Pe=React.useMemo(()=>P.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(map.addMapIndirectWeakSetItem(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,P),o)},new Map),[P]),{fn:Ge}=useTimeoutFunc.default(o=>{Z(n=>{const t=o,l=new Set(t);let d=!1;const a=n.filter(I=>{const S=l.has(I);return S||(d=!0),S});return d?a:n})},200),Ie=React.useCallback(o=>{const n=o.map(t=>t.id);c(o),Ge(n)},[]),M=React.useMemo(()=>{const o=s.find(e=>e.id===fe),n=e=>{const i=s.concat(e);return Ie(i),i},t=e=>{const i=x.concat(e);return B(i),i},l=e=>{Ae(e!==!1)},d=e=>{qe(e)},a=e=>{let i=[];e===void 0||e===""?i=[]:typeof e=="string"?i=[e]:Array.isArray(e)&&(i=e.length>1?Array.from(new Set(e)):e),Z(i)},I=e=>{v.includes(e)?a(v.filter(i=>i!==e)):a([...v,e])},S=e=>{const i=pickRectObject(e);u(m=>[...m,i])},k=(e,i=!1)=>{const m=pickRectObject(e);u(C=>C.map(w=>w.id===e.id?i?__spreadValues(__spreadValues({},w),m):m:w))},K=e=>{u(i=>i.filter(m=>!e.find(C=>C.id===m.id)))},E=e=>{V.includes(e)?j([]):j([e])},Ue=()=>{if(F===lbAnnotation.EToolName.Rect){const e=s.map(i=>i.id);a(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},Ze=e=>{a(s.filter(i=>i.attribute===e).map(i=>i.id))},Ce=s.filter(e=>!h.includes(e.attribute)),we=x.filter(e=>!h.includes(e.attribute)),be=y.filter(e=>e.attribute&&!h.includes(e.attribute)),Je=e=>{if(h.includes(e))T(h.filter(i=>i!==e));else{const i=h.concat(e);T(i)}},Qe=(e=Ce,i=A,m=we,C=be,w=W)=>{var N;g==null||g.clearAllBox(),g==null||g.clearAllSphere(),f==null||f.updatePolygonList(e,i),f==null||f.updatePointList(m),f==null||f.updateLineList(C),g==null||g.generateBoxes(e),g==null||g.generateSpheres(m),(N=L==null?void 0:L.store)==null||N.updateCurrentSegment(w),ye(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},Xe=()=>{$(void 0),te(void 0),ne(void 0),ie(void 0)},ye=(e,i,m)=>__async(void 0,null,function*(){var C,w,N;if(!g)return;const Re=g.pointCloudObject;if(!Re)return;let xe=[],Le=[];try{if(i&&q.record.length){const{record:b,recordIndex:R}=q;let D=R;R>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&i.length===((C=b[R])==null?void 0:C.pointCloudBoxList.length))&&(D=R-1);let U=(w=b[D])==null?void 0:w.pointCloudBoxList;const De=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,i,U);xe=De.modifiedBoxIds,Le=De.resetAreas}}catch(b){console.error("call calcResetAreasAndBoxIds error",b)}try{const b=yield g.getHighlightIndexByMappingImgList({mappingImgList:m!=null?m:G,points:Re.geometry.attributes.position.array}),R=yield g==null?void 0:g.highlightOriginPointCloud(i,b,{modifiedBoxIds:xe,resetAreas:Le}),{color:D,currentPCDSrc:U}=R!=null?R:{};return D&&((N=f==null?void 0:f.pointCloudInstance)==null||N.updateColor(D,U)),D}catch(b){console.error("call highlightOriginPointCloud error",b)}});return{selectedID:fe,pointCloudBoxList:s,pointCloudSphereList:x,displayPointCloudList:Ce,displaySphereList:we,displayLineList:be,selectedIDs:v,setPointCloudResult:Ie,setSelectedIDs:a,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:B,valid:J,visibleBatchSetValid:ue,selectedPointCloudBox:o,setPointCloudValid:l,setBatchSetValidModal:d,addSelectedID:I,addHighlightID:E,selectedAllBoxes:Ue,topViewInstance:f,setTopViewInstance:$,sideViewInstance:ee,setSideViewInstance:te,backViewInstance:oe,setBackViewInstance:ne,mainViewInstance:g,setMainViewInstance:ie,polygonList:A,setPolygonList:O,rectList:P,setRectList:u,addRectIn2DView:S,removeRectIn2DView:K,updateRectIn2DView:k,lineList:y,setLineList:Be,zoom:Y,setZoom:Ne,history:q,toggleAttributesVisible:Je,hideAttributes:h,setHideAttributes:T,reRender:Qe,attrPanelLayout:re,setAttrPanelLayout:ke,syncAllViewPointCloudColor:ye,defaultAttribute:se,setDefaultAttribute:He,pointCloudPattern:F,setPointCloudPattern:Me,selectSpecAttr:Ze,globalPattern:z,setGlobalPattern:e=>{z!==e&&(ze(actionCreators.ChangeSave),Ee(e),e===lbUtils.EPointCloudPattern.Detection&&ae(void 0))},ptSegmentInstance:L,setPtSegmentInstance:ae,segmentation:W,setSegmentation:Oe,clearAllDetectionInstance:Xe,highlight2DDataList:G,setHighlight2DDataList:je,highlight2DLoading:le,setHighlight2DLoading:Fe,cuboidBoxIn2DView:X,setCuboidBoxIn2DView:Ve,imageSizes:ge,cacheImageNodeSize:We,highlightIDs:V,setHighlightIDs:j,removeRectByPointCloudBoxId:pe,removeRectBySpecifyId:H,addRectFromPointCloudBoxByImageName:me,rectRotateSensitivity:Q,setRectRotateSensitivity:_e,imageNamePointCloudBoxMap:ve,linkageImageNameRectMap:Pe,updateRectListByReducer:Se,windowKeydownListenerHook:he,isLargeStatus:de,setIsLargeStatus:ce}},[J,ue,v,s,x,A,y,P,f,ee,oe,g,Y,h,re,se,F,z,L,W,G,le,X,ge,V,pe,H,me,Q,ve,Pe,Se,he,de,ce]);React.useEffect(()=>{var o,n,t;(o=p==null?void 0:p.setPointCloudBoxList)==null||o.call(p,s),(n=p==null?void 0:p.setHighlightIDs)==null||n.call(p,V),(t=p==null?void 0:p.setSelectedIDs)==null||t.call(p,v)},[s,v,V]),React.useEffect(()=>{var o;(o=p==null?void 0:p.setPtCtx)==null||o.call(p,M)},[M]);const Ke=()=>{const o=s.filter(d=>h.includes(d.attribute)),{setSelectedIDs:n,reRender:t}=M,l=o.map(d=>d.id);l.length>0&&n(v.filter(d=>!l.includes(d))),t()};return React.useEffect(()=>{var o,n,t,l;Ke(),(n=(o=f==null?void 0:f.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,h),(l=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||l.call(t,h)},[h]),React__default.default.createElement(PointCloudContext.Provider,{value:M},r)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
@@ -1 +1 @@
1
- "use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),useUpdatePointCloudColor=require("./hooks/useUpdatePointCloudColor.js"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(a,s,i)=>s in a?__defProp(a,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[s]=i,__spreadValues=(a,s)=>{for(var i in s||(s={}))__hasOwnProp.call(s,i)&&__defNormalProp(a,i,s[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(s))__propIsEnum.call(s,i)&&__defNormalProp(a,i,s[i]);return a},__spreadProps=(a,s)=>__defProps(a,__getOwnPropDescs(s));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:a,config:s,checkMode:i,configString:x,imgIndex:w,toolInstanceRef:u,setResourceLoading:y,isBatchSetValid:k})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:V,selectNextBox:_,selectPrevBox:E,updateSelectedBox:B,deleteSelectedPointCloudBoxAndPolygon:I}=useSingleBox.useSingleBox(),{selectedSphere:v,updatePointCloudSphere:q}=useSphere.useSphere(),{clearAllResult:P,updatePointCloudPattern:L}=useStatus.useStatus(),{copySelectedBoxes:O,pasteSelectedBoxes:j,copiedBoxes:Y}=useBoxes.useBoxes({config:s,currentData:a}),{updateRotate:C}=useRotate.useRotate({currentData:a}),{updateRotateEdge:A}=useRotateEdge.useRotateEdge({currentData:a}),{updatePointCloudData:d,topViewSelectedChanged:T}=usePointCloudViews.usePointCloudViews({setResourceLoading:y}),{redo:f,undo:g,pushHistoryWithList:D,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:N}=useHistory.useHistory(),{syncThreeViewsAttribute:h}=useAttribute.useAttribute(),{syncAllViewsConfig:R,reRenderTopViewRange:K}=useConfig.useConfig(),{selectedPolygon:m}=usePolygon.usePolygon(),{selectedLine:S}=useLine.useLine(),{t:b}=reactI18next.useTranslation(),{updatePointCloudColor:U}=useUpdatePointCloudColor.useUpdatePointCloudColor(y,s),z=ahooks.useLatest(a),p=t=>{var o;const{topViewInstance:r}=e;!r||(o=r.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},F=(t,o)=>{const{topViewInstance:r,mainViewInstance:n}=e;if(!r)return;const{pointCloud2dOperation:l}=r;switch(t){case"q":{C(e.rectRotateSensitivity);break}case"e":C(-Number(e.rectRotateSensitivity));break;case"g":A(-90);break;case"u":{const c=l.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;L(c);const W={[lbAnnotation.EToolName.Polygon]:b("PolygonPattern"),[lbAnnotation.EToolName.Rect]:b("RectPattern")};antd.message.success(b("ChangePatternMsg",{pattern:W[c]})),l.clearActiveStatus(),l.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":k?(antd.Modal.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){E();break}_(),o.preventDefault();break;case"f":V();break;case"arrowup":p({y:-1});break;case"arrowdown":p({y:1});break;case"arrowleft":p({x:-1});break;case"arrowright":p({x:1});break;case"delete":I(z.current);break}},M=(t,o)=>{switch(t){case"c":O();break;case"v":j();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?f():g();break}}},G=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||i===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){M(o,t);return}F(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(l=>G.current(l))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{R(s)},[x]),React.useEffect(()=>{(s==null?void 0:s.radius)&&K(s==null?void 0:s.radius)},[s==null?void 0:s.radius]),React.useEffect(()=>{d==null||d()},[w,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[w]),React.useEffect(()=>{u.current.setDefaultAttribute=t=>{var o;if(h(t),U(t),m&&H(__spreadProps(__spreadValues({},m),{attribute:t})),S&&N(__spreadProps(__spreadValues({},S),{attribute:t})),v){const r=q(__spreadProps(__spreadValues({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(r),T({newSelectedSphere:v,newSphereList:r}))}},u.current.setSubAttribute=(t,o)=>{var r;const n=e.selectedPointCloudBox;if(n){const l=(r=n==null?void 0:n.subAttribute)!=null?r:{};n.subAttribute=__spreadProps(__spreadValues({},l),{[t]:o}),B(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},u.current.clearResult=()=>{P==null||P()},u.current.redo=()=>{f()},u.current.undo=()=>{g()},u.current.setValid=t=>{u.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&P()})},u.current.setForbidOperation=t=>{var o,r;(r=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||r.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},u.current.setShowDefaultCursor=t=>{var o,r;(r=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||r.setShowDefaultCursor(t)},u.current.asyncData=t=>{setTimeout(()=>{d==null||d(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{u.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},u.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{u.current.history={pushHistory:t=>{D({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||i)return;const r=c=>{h(c)},n=c=>{antd.message.error(c)},l=c=>{antd.message.info(c)};return o.on("syncAttribute",r),o.on("messageError",n),o.on("messageInfo",l),()=>{o.unbind("syncAttribute",r),o.unbind("messageError",n),o.unbind("messageInfo",l)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$1;
1
+ "use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),useUpdatePointCloudColor=require("./hooks/useUpdatePointCloudColor.js"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(a,r,i)=>r in a?__defProp(a,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[r]=i,__spreadValues=(a,r)=>{for(var i in r||(r={}))__hasOwnProp.call(r,i)&&__defNormalProp(a,i,r[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(r))__propIsEnum.call(r,i)&&__defNormalProp(a,i,r[i]);return a},__spreadProps=(a,r)=>__defProps(a,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:a,config:r,checkMode:i,configString:x,imgIndex:b,toolInstanceRef:u,setResourceLoading:w,isBatchSetValid:k})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:V,selectNextBox:_,selectPrevBox:E,updateSelectedBox:B,deleteSelectedPointCloudBoxAndPolygon:I}=useSingleBox.useSingleBox(),{selectedSphere:v,updatePointCloudSphere:q}=useSphere.useSphere(),{clearAllResult:y,updatePointCloudPattern:L}=useStatus.useStatus(),{copySelectedBoxes:O,pasteSelectedBoxes:j,copiedBoxes:Y}=useBoxes.useBoxes({config:r,currentData:a}),{updateRotate:C}=useRotate.useRotate({currentData:a}),{updateRotateEdge:A}=useRotateEdge.useRotateEdge({currentData:a}),{updatePointCloudData:d,topViewSelectedChanged:T}=usePointCloudViews.usePointCloudViews({setResourceLoading:w}),{redo:g,undo:f,pushHistoryWithList:D,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:N}=useHistory.useHistory(),{syncThreeViewsAttribute:h}=useAttribute.useAttribute(),{syncAllViewsConfig:R,reRenderTopViewRange:K}=useConfig.useConfig(),{selectedPolygon:m}=usePolygon.usePolygon(),{selectedLine:S}=useLine.useLine(),{t:P}=reactI18next.useTranslation(),{updatePointCloudColor:U}=useUpdatePointCloudColor.useUpdatePointCloudColor(w,r),z=ahooks.useLatest(a),p=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},F=(t,o)=>{const{topViewInstance:s,mainViewInstance:n}=e;if(!s)return;const{pointCloud2dOperation:l}=s;switch(t){case"q":{C(e.rectRotateSensitivity);break}case"e":C(-Number(e.rectRotateSensitivity));break;case"g":A(-90);break;case"u":{const c=l.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;L(c);const W={[lbAnnotation.EToolName.Polygon]:P("PolygonPattern"),[lbAnnotation.EToolName.Rect]:P("RectPattern")};antd.message.success(P("ChangePatternMsg",{pattern:W[c]})),l.clearActiveStatus(),l.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":k?(antd.Modal.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){E();break}_(),o.preventDefault();break;case"f":V();break;case"arrowup":p({y:-1});break;case"arrowdown":p({y:1});break;case"arrowleft":p({x:-1});break;case"arrowright":p({x:1});break;case"delete":I(z.current);break}},M=(t,o)=>{switch(t){case"c":O();break;case"v":j();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?g():f();break}}},G=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||i===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){M(o,t);return}F(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(l=>G.current(l))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{R(r)},[x]),React.useEffect(()=>{(r==null?void 0:r.radius)&&K(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{d==null||d()},[b,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[b]),React.useEffect(()=>{u.current.setDefaultAttribute=t=>{var o;if(h(t),U(t),m&&H(__spreadProps(__spreadValues({},m),{attribute:t})),S&&N(__spreadProps(__spreadValues({},S),{attribute:t})),v){const s=q(__spreadProps(__spreadValues({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),T({newSelectedSphere:v,newSphereList:s}))}},u.current.setSubAttribute=(t,o)=>{var s;const n=e.selectedPointCloudBox;if(n){const l=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=__spreadProps(__spreadValues({},l),{[t]:o}),B(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},u.current.clearResult=()=>{y==null||y()},u.current.redo=()=>{g()},u.current.undo=()=>{f()},u.current.setValid=t=>{u.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},u.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},u.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},u.current.asyncData=t=>{setTimeout(()=>{d==null||d(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{u.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},u.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{u.current.history={pushHistory:t=>{D({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||i)return;const s=c=>{h(c)},n=c=>{antd.message.error(c)},l=c=>{antd.message.info(c)};return o.on("syncAttribute",s),o.on("messageError",n),o.on("messageInfo",l),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",n),o.unbind("messageInfo",l)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$1;
@@ -1 +1 @@
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
+ "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,f)=>__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:f}),d(h),!t||(o==null?void 0:o.length)===0)return;const v=t.pointCloudObject;if(!v)return;const m=yield t.getHighlightIndexByMappingImgList({mappingImgList:h,points:v.geometry.attributes.position.array});try{const e=yield t.highlightOriginPointCloud(a,m),{color:C}=e!=null?e:{};C&&((p=g==null?void 0:g.pointCloudInstance)==null||p.updateColor(C))}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
- import{EPointCloudPattern as X}from"@labelbee/lb-utils";import Me,{useState as r,useRef as pt,useMemo as k,useCallback as N,useEffect as Y}from"react";import{EPointCloudBoxRenderTrigger as F,calcResetAreasAndBoxIds as mt}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as je,EToolName as $,uuid as ht}from"@labelbee/lb-annotation";import{useDispatch as It}from"../../store/ctx.js";import{ChangeSave as vt}from"../../store/annotation/actionCreators.js";import Pt from"../../store/annotatedBox/index.js";import ke from"lodash";import{addMapIndirectWeakSetItem as Fe}from"./utils/map.js";import wt from"./hooks/useTimeoutFunc.js";import St,{getEmptyUseWindowKeydownListener as yt}from"./hooks/useWindowKeydownListener.js";var Lt=Object.defineProperty,bt=Object.defineProperties,Ct=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertySymbols,Rt=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,ze=(c,s,u)=>s in c?Lt(c,s,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[s]=u,E=(c,s)=>{for(var u in s||(s={}))Rt.call(s,u)&&ze(c,u,s[u]);if(Ee)for(var u of Ee(s))xt.call(s,u)&&ze(c,u,s[u]);return c},Ge=(c,s)=>bt(c,Ct(s)),Dt=(c,s,u)=>new Promise((x,B)=>{var A=g=>{try{w(u.next(g))}catch(R){B(R)}},G=g=>{try{w(u.throw(g))}catch(R){B(R)}},w=g=>g.done?x(g.value):Promise.resolve(g.value).then(A,G);w((u=u.apply(c,s)).next())});const z=c=>ke.pick(c,["id","attribute","width","height","x","y","imageName"]),Ke=Me.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,visibleBatchSetValid:!1,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setBatchSetValidModal:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new je,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:$.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:X.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:c=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:c=>!1,removeRectBySpecifyId:(c,s,u)=>!1,removeRectByPointCloudBoxId:c=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:yt(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),Bt=({children:c})=>{const[s,u]=r([]),[x,B]=r([]),[A,G]=r([]),[w,g]=r([]),[R,Te]=r([]),[v,ee]=r([]),[V,K]=r([]),[te,We]=r(!0),[oe,Ze]=r(2),[ne,Ue]=r(!0),[ie,qe]=r(1),[p,se]=r(),[re,le]=r(),[ae,de]=r(),[f,ce]=r(),[ue,Je]=r(""),[T,Qe]=r($.Rect),W=pt(new je).current,[m,Z]=r([]),[ge,Xe]=r(""),[U,Ye]=r(X.Detection),[D,fe]=r(void 0),[q,$e]=r([]),[J,et]=r([]),[pe,tt]=r(!1),[me,he]=r(!1),h=Pt(),[Ie,ot]=r(!1),[ve,nt]=r({}),it=It(),st=o=>{const{imgNode:n,path:t}=o;t&&n&&nt(a=>Ge(E({},a),{[t]:{width:n.width,height:n.height}}))},Pe=k(()=>v.length===1?v[0]:"",[v]),we=St(),H=N((o,n,t="extId")=>{const a=t||"id",d=new Set(n);return g(l=>{let S=!1;const P=l.filter(M=>{const Q=M[a],j=d.has(Q)?M.imageName!==o:!0;return j||(S=!0),j});return S?P:l}),!0},[]),Se=N(o=>{const n=s.map(t=>t.id);return H(o,n,"extId")},[s,H]),ye=N(o=>{if(!o)return!1;const n=s.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:a,attribute:d,trackID:l}=t,S=t.rects.find(P=>P.imageName===o);if(S){const P=ke.pick(S,["width","height","x","y","imageName"]);return Ge(E({},P),{id:ht(),attribute:d,order:l,extId:a,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(g(t=>{const a=new Set(t.filter(l=>o===l.imageName).map(l=>l.extId)),d=n.filter(l=>a.has(l.extId)===!1);return d.length?[...t,...d]:t}),!0):!1},[s]),Le=k(()=>s.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var a;return(a=t.rects)==null||a.forEach(d=>{const{imageName:l}=d;if(!l){console.warn("Missing image name"),console.trace(d,t);return}Fe(n,l,t.id,t)}),n},new Map),[s]),be=N(o=>{g(n=>o(n,z))},[z]),Ce=k(()=>w.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(Fe(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,w),o)},new Map),[w]),{fn:rt}=wt(o=>{ee(n=>{const t=o,a=new Set(t);let d=!1;const l=n.filter(S=>{const P=a.has(S);return P||(d=!0),P});return d?l:n})},200),Re=N(o=>{const n=o.map(t=>t.id);u(o),rt(n)},[]),O=k(()=>{const o=s.find(e=>e.id===Pe),n=e=>{const i=s.concat(e);return Re(i),i},t=e=>{const i=x.concat(e);return B(i),i},a=e=>{We(e!==!1)},d=e=>{ot(e)},l=e=>{let i=[];e===void 0||e===""?i=[]:typeof e=="string"?i=[e]:Array.isArray(e)&&(i=e.length>1?Array.from(new Set(e)):e),ee(i)},S=e=>{v.includes(e)?l(v.filter(i=>i!==e)):l([...v,e])},P=e=>{const i=z(e);g(I=>[...I,i])},M=(e,i=!1)=>{const I=z(e);g(y=>y.map(L=>L.id===e.id?i?E(E({},L),I):I:L))},Q=e=>{g(i=>i.filter(I=>!e.find(y=>y.id===I.id)))},j=e=>{V.includes(e)?K([]):K([e])},at=()=>{if(T===$.Rect){const e=s.map(i=>i.id);l(e),p==null||p.pointCloud2dOperation.setSelectedIDs(e)}},dt=e=>{l(s.filter(i=>i.attribute===e).map(i=>i.id))},xe=s.filter(e=>!m.includes(e.attribute)),De=x.filter(e=>!m.includes(e.attribute)),Be=R.filter(e=>e.attribute&&!m.includes(e.attribute)),ct=e=>{if(m.includes(e))Z(m.filter(i=>i!==e));else{const i=m.concat(e);Z(i)}},ut=(e=xe,i=A,I=De,y=Be,L=q)=>{var _;f==null||f.clearAllBox(),f==null||f.clearAllSphere(),p==null||p.updatePolygonList(e,i),p==null||p.updatePointList(I),p==null||p.updateLineList(y),f==null||f.generateBoxes(e),f==null||f.generateSpheres(I),(_=D==null?void 0:D.store)==null||_.updateCurrentSegment(L),Ae(F.Default,e)},gt=()=>{se(void 0),le(void 0),de(void 0),ce(void 0)},Ae=(e,i,I)=>Dt(void 0,null,function*(){var y,L,_;if(!f)return;const Ve=f.pointCloudObject;if(!Ve)return;let _e=[],Ne=[];try{if(i&&W.record.length){const{record:b,recordIndex:C}=W;let He=C;C>0&&(e===F.SingleToggleValid||e===F.SingleRotate||e===F.Single&&i.length===((y=b[C])==null?void 0:y.pointCloudBoxList.length))&&(He=C-1);let ft=(L=b[He])==null?void 0:L.pointCloudBoxList;const Oe=mt(e,i,ft);_e=Oe.modifiedBoxIds,Ne=Oe.resetAreas}}catch(b){console.error("call calcResetAreasAndBoxIds error",b)}try{const b=yield f.getHighlightIndexByMappingImgList({mappingImgList:I!=null?I:J,points:Ve.geometry.attributes.position.array}),C=yield f==null?void 0:f.highlightOriginPointCloud(i,b,{modifiedBoxIds:_e,resetAreas:Ne});return C&&((_=p==null?void 0:p.pointCloudInstance)==null||_.updateColor(C)),C}catch(b){console.error("call highlightOriginPointCloud error",b)}});return{selectedID:Pe,pointCloudBoxList:s,pointCloudSphereList:x,displayPointCloudList:xe,displaySphereList:De,displayLineList:Be,selectedIDs:v,setPointCloudResult:Re,setSelectedIDs:l,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:B,valid:te,visibleBatchSetValid:Ie,selectedPointCloudBox:o,setPointCloudValid:a,setBatchSetValidModal:d,addSelectedID:S,addHighlightID:j,selectedAllBoxes:at,topViewInstance:p,setTopViewInstance:se,sideViewInstance:re,setSideViewInstance:le,backViewInstance:ae,setBackViewInstance:de,mainViewInstance:f,setMainViewInstance:ce,polygonList:A,setPolygonList:G,rectList:w,setRectList:g,addRectIn2DView:P,removeRectIn2DView:Q,updateRectIn2DView:M,lineList:R,setLineList:Te,zoom:ie,setZoom:qe,history:W,toggleAttributesVisible:ct,hideAttributes:m,setHideAttributes:Z,reRender:ut,attrPanelLayout:ge,setAttrPanelLayout:Xe,syncAllViewPointCloudColor:Ae,defaultAttribute:ue,setDefaultAttribute:Je,pointCloudPattern:T,setPointCloudPattern:Qe,selectSpecAttr:dt,globalPattern:U,setGlobalPattern:e=>{U!==e&&(it(vt),Ye(e),e===X.Detection&&fe(void 0))},ptSegmentInstance:D,setPtSegmentInstance:fe,segmentation:q,setSegmentation:$e,clearAllDetectionInstance:gt,highlight2DDataList:J,setHighlight2DDataList:et,highlight2DLoading:pe,setHighlight2DLoading:tt,cuboidBoxIn2DView:ne,setCuboidBoxIn2DView:Ue,imageSizes:ve,cacheImageNodeSize:st,highlightIDs:V,setHighlightIDs:K,removeRectByPointCloudBoxId:Se,removeRectBySpecifyId:H,addRectFromPointCloudBoxByImageName:ye,rectRotateSensitivity:oe,setRectRotateSensitivity:Ze,imageNamePointCloudBoxMap:Le,linkageImageNameRectMap:Ce,updateRectListByReducer:be,windowKeydownListenerHook:we,isLargeStatus:me,setIsLargeStatus:he}},[te,Ie,v,s,x,A,R,w,p,re,ae,f,ie,m,ge,ue,T,U,D,q,J,pe,ne,ve,V,Se,H,ye,oe,Le,Ce,be,we,me,he]);Y(()=>{var o,n,t;(o=h==null?void 0:h.setPointCloudBoxList)==null||o.call(h,s),(n=h==null?void 0:h.setHighlightIDs)==null||n.call(h,V),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,v)},[s,v,V]),Y(()=>{var o;(o=h==null?void 0:h.setPtCtx)==null||o.call(h,O)},[O]);const lt=()=>{const o=s.filter(d=>m.includes(d.attribute)),{setSelectedIDs:n,reRender:t}=O,a=o.map(d=>d.id);a.length>0&&n(v.filter(d=>!a.includes(d))),t()};return Y(()=>{var o,n,t,a;lt(),(n=(o=p==null?void 0:p.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,m),(a=(t=D==null?void 0:D.store)==null?void 0:t.setHiddenAttributes)==null||a.call(t,m)},[m]),Me.createElement(Ke.Provider,{value:O},c)};export{Ke as PointCloudContext,Bt as PointCloudProvider};
1
+ import{EPointCloudPattern as $}from"@labelbee/lb-utils";import je,{useState as r,useRef as pt,useMemo as F,useCallback as H,useEffect as ee}from"react";import{EPointCloudBoxRenderTrigger as E,calcResetAreasAndBoxIds as mt}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as ke,EToolName as te,uuid as ht}from"@labelbee/lb-annotation";import{useDispatch as It}from"../../store/ctx.js";import{ChangeSave as vt}from"../../store/annotation/actionCreators.js";import Pt from"../../store/annotatedBox/index.js";import Fe from"lodash";import{addMapIndirectWeakSetItem as Ee}from"./utils/map.js";import wt from"./hooks/useTimeoutFunc.js";import St,{getEmptyUseWindowKeydownListener as yt}from"./hooks/useWindowKeydownListener.js";var Ct=Object.defineProperty,Lt=Object.defineProperties,bt=Object.getOwnPropertyDescriptors,ze=Object.getOwnPropertySymbols,Rt=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,Ge=(c,s,u)=>s in c?Ct(c,s,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[s]=u,z=(c,s)=>{for(var u in s||(s={}))Rt.call(s,u)&&Ge(c,u,s[u]);if(ze)for(var u of ze(s))xt.call(s,u)&&Ge(c,u,s[u]);return c},Ke=(c,s)=>Lt(c,bt(s)),Dt=(c,s,u)=>new Promise((x,A)=>{var V=g=>{try{w(u.next(g))}catch(b){A(b)}},K=g=>{try{w(u.throw(g))}catch(b){A(b)}},w=g=>g.done?x(g.value):Promise.resolve(g.value).then(V,K);w((u=u.apply(c,s)).next())});const G=c=>Fe.pick(c,["id","attribute","width","height","x","y","imageName"]),Te=je.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,visibleBatchSetValid:!1,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setBatchSetValidModal:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new ke,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:te.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:$.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:c=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:c=>!1,removeRectBySpecifyId:(c,s,u)=>!1,removeRectByPointCloudBoxId:c=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:yt(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),Bt=({children:c})=>{const[s,u]=r([]),[x,A]=r([]),[V,K]=r([]),[w,g]=r([]),[b,We]=r([]),[v,oe]=r([]),[_,T]=r([]),[ne,Ze]=r(!0),[ie,Ue]=r(2),[se,qe]=r(!0),[re,Je]=r(1),[p,le]=r(),[ae,de]=r(),[ce,ue]=r(),[f,ge]=r(),[fe,Qe]=r(""),[W,Xe]=r(te.Rect),Z=pt(new ke).current,[m,U]=r([]),[pe,Ye]=r(""),[q,$e]=r($.Detection),[D,me]=r(void 0),[J,et]=r([]),[Q,tt]=r([]),[he,ot]=r(!1),[Ie,ve]=r(!1),h=Pt(),[Pe,nt]=r(!1),[we,it]=r({}),st=It(),rt=o=>{const{imgNode:n,path:t}=o;t&&n&&it(a=>Ke(z({},a),{[t]:{width:n.width,height:n.height}}))},Se=F(()=>v.length===1?v[0]:"",[v]),ye=St(),O=H((o,n,t="extId")=>{const a=t||"id",d=new Set(n);return g(l=>{let S=!1;const P=l.filter(j=>{const X=j[a],k=d.has(X)?j.imageName!==o:!0;return k||(S=!0),k});return S?P:l}),!0},[]),Ce=H(o=>{const n=s.map(t=>t.id);return O(o,n,"extId")},[s,O]),Le=H(o=>{if(!o)return!1;const n=s.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:a,attribute:d,trackID:l}=t,S=t.rects.find(P=>P.imageName===o);if(S){const P=Fe.pick(S,["width","height","x","y","imageName"]);return Ke(z({},P),{id:ht(),attribute:d,order:l,extId:a,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(g(t=>{const a=new Set(t.filter(l=>o===l.imageName).map(l=>l.extId)),d=n.filter(l=>a.has(l.extId)===!1);return d.length?[...t,...d]:t}),!0):!1},[s]),be=F(()=>s.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var a;return(a=t.rects)==null||a.forEach(d=>{const{imageName:l}=d;if(!l){console.warn("Missing image name"),console.trace(d,t);return}Ee(n,l,t.id,t)}),n},new Map),[s]),Re=H(o=>{g(n=>o(n,G))},[G]),xe=F(()=>w.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(Ee(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,w),o)},new Map),[w]),{fn:lt}=wt(o=>{oe(n=>{const t=o,a=new Set(t);let d=!1;const l=n.filter(S=>{const P=a.has(S);return P||(d=!0),P});return d?l:n})},200),De=H(o=>{const n=o.map(t=>t.id);u(o),lt(n)},[]),M=F(()=>{const o=s.find(e=>e.id===Se),n=e=>{const i=s.concat(e);return De(i),i},t=e=>{const i=x.concat(e);return A(i),i},a=e=>{Ze(e!==!1)},d=e=>{nt(e)},l=e=>{let i=[];e===void 0||e===""?i=[]:typeof e=="string"?i=[e]:Array.isArray(e)&&(i=e.length>1?Array.from(new Set(e)):e),oe(i)},S=e=>{v.includes(e)?l(v.filter(i=>i!==e)):l([...v,e])},P=e=>{const i=G(e);g(I=>[...I,i])},j=(e,i=!1)=>{const I=G(e);g(y=>y.map(C=>C.id===e.id?i?z(z({},C),I):I:C))},X=e=>{g(i=>i.filter(I=>!e.find(y=>y.id===I.id)))},k=e=>{_.includes(e)?T([]):T([e])},dt=()=>{if(W===te.Rect){const e=s.map(i=>i.id);l(e),p==null||p.pointCloud2dOperation.setSelectedIDs(e)}},ct=e=>{l(s.filter(i=>i.attribute===e).map(i=>i.id))},Be=s.filter(e=>!m.includes(e.attribute)),Ae=x.filter(e=>!m.includes(e.attribute)),Ve=b.filter(e=>e.attribute&&!m.includes(e.attribute)),ut=e=>{if(m.includes(e))U(m.filter(i=>i!==e));else{const i=m.concat(e);U(i)}},gt=(e=Be,i=V,I=Ae,y=Ve,C=J)=>{var N;f==null||f.clearAllBox(),f==null||f.clearAllSphere(),p==null||p.updatePolygonList(e,i),p==null||p.updatePointList(I),p==null||p.updateLineList(y),f==null||f.generateBoxes(e),f==null||f.generateSpheres(I),(N=D==null?void 0:D.store)==null||N.updateCurrentSegment(C),_e(E.Default,e)},ft=()=>{le(void 0),de(void 0),ue(void 0),ge(void 0)},_e=(e,i,I)=>Dt(void 0,null,function*(){var y,C,N;if(!f)return;const Ne=f.pointCloudObject;if(!Ne)return;let He=[],Oe=[];try{if(i&&Z.record.length){const{record:L,recordIndex:R}=Z;let B=R;R>0&&(e===E.SingleToggleValid||e===E.SingleRotate||e===E.Single&&i.length===((y=L[R])==null?void 0:y.pointCloudBoxList.length))&&(B=R-1);let Y=(C=L[B])==null?void 0:C.pointCloudBoxList;const Me=mt(e,i,Y);He=Me.modifiedBoxIds,Oe=Me.resetAreas}}catch(L){console.error("call calcResetAreasAndBoxIds error",L)}try{const L=yield f.getHighlightIndexByMappingImgList({mappingImgList:I!=null?I:Q,points:Ne.geometry.attributes.position.array}),R=yield f==null?void 0:f.highlightOriginPointCloud(i,L,{modifiedBoxIds:He,resetAreas:Oe}),{color:B,currentPCDSrc:Y}=R!=null?R:{};return B&&((N=p==null?void 0:p.pointCloudInstance)==null||N.updateColor(B,Y)),B}catch(L){console.error("call highlightOriginPointCloud error",L)}});return{selectedID:Se,pointCloudBoxList:s,pointCloudSphereList:x,displayPointCloudList:Be,displaySphereList:Ae,displayLineList:Ve,selectedIDs:v,setPointCloudResult:De,setSelectedIDs:l,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:A,valid:ne,visibleBatchSetValid:Pe,selectedPointCloudBox:o,setPointCloudValid:a,setBatchSetValidModal:d,addSelectedID:S,addHighlightID:k,selectedAllBoxes:dt,topViewInstance:p,setTopViewInstance:le,sideViewInstance:ae,setSideViewInstance:de,backViewInstance:ce,setBackViewInstance:ue,mainViewInstance:f,setMainViewInstance:ge,polygonList:V,setPolygonList:K,rectList:w,setRectList:g,addRectIn2DView:P,removeRectIn2DView:X,updateRectIn2DView:j,lineList:b,setLineList:We,zoom:re,setZoom:Je,history:Z,toggleAttributesVisible:ut,hideAttributes:m,setHideAttributes:U,reRender:gt,attrPanelLayout:pe,setAttrPanelLayout:Ye,syncAllViewPointCloudColor:_e,defaultAttribute:fe,setDefaultAttribute:Qe,pointCloudPattern:W,setPointCloudPattern:Xe,selectSpecAttr:ct,globalPattern:q,setGlobalPattern:e=>{q!==e&&(st(vt),$e(e),e===$.Detection&&me(void 0))},ptSegmentInstance:D,setPtSegmentInstance:me,segmentation:J,setSegmentation:et,clearAllDetectionInstance:ft,highlight2DDataList:Q,setHighlight2DDataList:tt,highlight2DLoading:he,setHighlight2DLoading:ot,cuboidBoxIn2DView:se,setCuboidBoxIn2DView:qe,imageSizes:we,cacheImageNodeSize:rt,highlightIDs:_,setHighlightIDs:T,removeRectByPointCloudBoxId:Ce,removeRectBySpecifyId:O,addRectFromPointCloudBoxByImageName:Le,rectRotateSensitivity:ie,setRectRotateSensitivity:Ue,imageNamePointCloudBoxMap:be,linkageImageNameRectMap:xe,updateRectListByReducer:Re,windowKeydownListenerHook:ye,isLargeStatus:Ie,setIsLargeStatus:ve}},[ne,Pe,v,s,x,V,b,w,p,ae,ce,f,re,m,pe,fe,W,q,D,J,Q,he,se,we,_,Ce,O,Le,ie,be,xe,Re,ye,Ie,ve]);ee(()=>{var o,n,t;(o=h==null?void 0:h.setPointCloudBoxList)==null||o.call(h,s),(n=h==null?void 0:h.setHighlightIDs)==null||n.call(h,_),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,v)},[s,v,_]),ee(()=>{var o;(o=h==null?void 0:h.setPtCtx)==null||o.call(h,M)},[M]);const at=()=>{const o=s.filter(d=>m.includes(d.attribute)),{setSelectedIDs:n,reRender:t}=M,a=o.map(d=>d.id);a.length>0&&n(v.filter(d=>!a.includes(d))),t()};return ee(()=>{var o,n,t,a;at(),(n=(o=p==null?void 0:p.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,m),(a=(t=D==null?void 0:D.store)==null?void 0:t.setHiddenAttributes)==null||a.call(t,m)},[m]),je.createElement(Te.Provider,{value:M},c)};export{Te as PointCloudContext,Bt as PointCloudProvider};
@@ -1 +1 @@
1
- import{PointCloudContext as oe}from"./PointCloudContext.js";import{useRotate as re}from"./hooks/useRotate.js";import{useRotateEdge as se}from"./hooks/useRotateEdge.js";import{useBoxes as ne}from"./hooks/useBoxes.js";import{useSingleBox as ie}from"./hooks/useSingleBox.js";import{useSphere as ae}from"./hooks/useSphere.js";import{useContext as ue,useEffect as c}from"react";import{CommonToolUtils as le,EToolName as f,cTool as ce}from"@labelbee/lb-annotation";import{Modal as de,message as h}from"antd";import{connect as pe}from"react-redux";import{a2MapStateToProps as me}from"../../store/annotation/map.js";import{useStatus as fe}from"./hooks/useStatus.js";import{usePointCloudViews as Pe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as we}from"../../store/ctx.js";import{useHistory as be}from"./hooks/useHistory.js";import{useAttribute as ye}from"./hooks/useAttribute.js";import{useConfig as ve}from"./hooks/useConfig.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useLine as Ce}from"./hooks/useLine.js";import{useUpdatePointCloudColor as ge}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as Se}from"react-i18next";import{useLatest as I}from"ahooks";var ke=Object.defineProperty,xe=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable,j=(i,r,a)=>r in i?ke(i,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[r]=a,P=(i,r)=>{for(var a in r||(r={}))_e.call(r,a)&&j(i,a,r[a]);if(O)for(var a of O(r))Be.call(r,a)&&j(i,a,r[a]);return i},w=(i,r)=>xe(i,Ve(r));const{EPolygonPattern:Ie}=ce,Oe=({currentData:i,config:r,checkMode:a,configString:L,imgIndex:C,toolInstanceRef:u,setResourceLoading:g,isBatchSetValid:A})=>{const e=ue(oe),{changeSelectedBoxValid:E,selectNextBox:T,selectPrevBox:D,updateSelectedBox:H,deleteSelectedPointCloudBoxAndPolygon:K}=ie(),{selectedSphere:b,updatePointCloudSphere:N}=ae(),{clearAllResult:y,updatePointCloudPattern:U}=fe(),{copySelectedBoxes:z,pasteSelectedBoxes:R,copiedBoxes:Le}=ne({config:r,currentData:i}),{updateRotate:S}=re({currentData:i}),{updateRotateEdge:F}=se({currentData:i}),{updatePointCloudData:p,topViewSelectedChanged:M}=Pe({setResourceLoading:g}),{redo:k,undo:x,pushHistoryWithList:q,pushHistoryUnderUpdatePolygon:G,pushHistoryUnderUpdateLine:W}=be(),{syncThreeViewsAttribute:V}=ye(),{syncAllViewsConfig:Y,reRenderTopViewRange:$}=ve(),{selectedPolygon:_}=he(),{selectedLine:B}=Ce(),{t:v}=Se(),{updatePointCloudColor:J}=ge(g,r),Q=I(i),m=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},X=(t,o)=>{const{topViewInstance:s,mainViewInstance:n}=e;if(!s)return;const{pointCloud2dOperation:l}=s;switch(t){case"q":{S(e.rectRotateSensitivity);break}case"e":S(-Number(e.rectRotateSensitivity));break;case"g":F(-90);break;case"u":{const d=l.pattern===Ie.Normal?f.Rect:f.Polygon;U(d);const te={[f.Polygon]:v("PolygonPattern"),[f.Rect]:v("RectPattern")};h.success(v("ChangePatternMsg",{pattern:te[d]})),l.clearActiveStatus(),l.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":A?(de.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){D();break}T(),o.preventDefault();break;case"f":E();break;case"arrowup":m({y:-1});break;case"arrowdown":m({y:1});break;case"arrowleft":m({x:-1});break;case"arrowright":m({x:1});break;case"delete":K(Q.current);break}},Z=(t,o)=>{switch(t){case"c":z();break;case"v":R();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?k():x();break}}},ee=I(t=>{if(!le.hotkeyFilter(t)||a===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){Z(o,t);return}X(o,t)});return c(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(l=>ee.current(l))},[e,e.topViewInstance,e.windowKeydownListenerHook]),c(()=>{Y(r)},[L]),c(()=>{(r==null?void 0:r.radius)&&$(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{p==null||p()},[C,e.mainViewInstance]),c(()=>{e.setHideAttributes([])},[C]),c(()=>{u.current.setDefaultAttribute=t=>{var o;if(V(t),J(t),_&&G(w(P({},_),{attribute:t})),B&&W(w(P({},B),{attribute:t})),b){const s=N(w(P({},b),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),M({newSelectedSphere:b,newSphereList:s}))}},u.current.setSubAttribute=(t,o)=>{var s;const n=e.selectedPointCloudBox;if(n){const l=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=w(P({},l),{[t]:o}),H(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},u.current.clearResult=()=>{y==null||y()},u.current.redo=()=>{k()},u.current.undo=()=>{x()},u.current.setValid=t=>{u.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&y()})},u.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},u.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},u.current.asyncData=t=>{setTimeout(()=>{p==null||p(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),c(()=>{u.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},u.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),c(()=>{u.current.history={pushHistory:t=>{q({pointCloudBoxList:t})},initRecord:()=>{}}},[]),c(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||a)return;const s=d=>{V(d)},n=d=>{h.error(d)},l=d=>{h.info(d)};return o.on("syncAttribute",s),o.on("messageError",n),o.on("messageInfo",l),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",n),o.unbind("messageInfo",l)}},[e.topViewInstance]),null};var je=pe(me,null,null,{context:we})(Oe);export{je as default};
1
+ import{PointCloudContext as oe}from"./PointCloudContext.js";import{useRotate as re}from"./hooks/useRotate.js";import{useRotateEdge as se}from"./hooks/useRotateEdge.js";import{useBoxes as ne}from"./hooks/useBoxes.js";import{useSingleBox as ie}from"./hooks/useSingleBox.js";import{useSphere as ae}from"./hooks/useSphere.js";import{useContext as ue,useEffect as c}from"react";import{CommonToolUtils as le,EToolName as P,cTool as ce}from"@labelbee/lb-annotation";import{Modal as de,message as y}from"antd";import{connect as pe}from"react-redux";import{a2MapStateToProps as me}from"../../store/annotation/map.js";import{useStatus as Pe}from"./hooks/useStatus.js";import{usePointCloudViews as fe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as we}from"../../store/ctx.js";import{useHistory as be}from"./hooks/useHistory.js";import{useAttribute as ve}from"./hooks/useAttribute.js";import{useConfig as ye}from"./hooks/useConfig.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useLine as Ce}from"./hooks/useLine.js";import{useUpdatePointCloudColor as ge}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as Se}from"react-i18next";import{useLatest as I}from"ahooks";var ke=Object.defineProperty,xe=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable,j=(i,r,a)=>r in i?ke(i,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[r]=a,f=(i,r)=>{for(var a in r||(r={}))_e.call(r,a)&&j(i,a,r[a]);if(O)for(var a of O(r))Be.call(r,a)&&j(i,a,r[a]);return i},w=(i,r)=>xe(i,Ve(r));const{EPolygonPattern:Ie}=ce,Oe=({currentData:i,config:r,checkMode:a,configString:L,imgIndex:h,toolInstanceRef:u,setResourceLoading:C,isBatchSetValid:A})=>{const e=ue(oe),{changeSelectedBoxValid:E,selectNextBox:T,selectPrevBox:D,updateSelectedBox:H,deleteSelectedPointCloudBoxAndPolygon:K}=ie(),{selectedSphere:b,updatePointCloudSphere:N}=ae(),{clearAllResult:g,updatePointCloudPattern:U}=Pe(),{copySelectedBoxes:z,pasteSelectedBoxes:R,copiedBoxes:Le}=ne({config:r,currentData:i}),{updateRotate:S}=re({currentData:i}),{updateRotateEdge:F}=se({currentData:i}),{updatePointCloudData:p,topViewSelectedChanged:M}=fe({setResourceLoading:C}),{redo:k,undo:x,pushHistoryWithList:q,pushHistoryUnderUpdatePolygon:G,pushHistoryUnderUpdateLine:W}=be(),{syncThreeViewsAttribute:V}=ve(),{syncAllViewsConfig:Y,reRenderTopViewRange:$}=ye(),{selectedPolygon:_}=he(),{selectedLine:B}=Ce(),{t:v}=Se(),{updatePointCloudColor:J}=ge(C,r),Q=I(i),m=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},X=(t,o)=>{const{topViewInstance:s,mainViewInstance:n}=e;if(!s)return;const{pointCloud2dOperation:l}=s;switch(t){case"q":{S(e.rectRotateSensitivity);break}case"e":S(-Number(e.rectRotateSensitivity));break;case"g":F(-90);break;case"u":{const d=l.pattern===Ie.Normal?P.Rect:P.Polygon;U(d);const te={[P.Polygon]:v("PolygonPattern"),[P.Rect]:v("RectPattern")};y.success(v("ChangePatternMsg",{pattern:te[d]})),l.clearActiveStatus(),l.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":A?(de.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){D();break}T(),o.preventDefault();break;case"f":E();break;case"arrowup":m({y:-1});break;case"arrowdown":m({y:1});break;case"arrowleft":m({x:-1});break;case"arrowright":m({x:1});break;case"delete":K(Q.current);break}},Z=(t,o)=>{switch(t){case"c":z();break;case"v":R();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?k():x();break}}},ee=I(t=>{if(!le.hotkeyFilter(t)||a===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){Z(o,t);return}X(o,t)});return c(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(l=>ee.current(l))},[e,e.topViewInstance,e.windowKeydownListenerHook]),c(()=>{Y(r)},[L]),c(()=>{(r==null?void 0:r.radius)&&$(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{p==null||p()},[h,e.mainViewInstance]),c(()=>{e.setHideAttributes([])},[h]),c(()=>{u.current.setDefaultAttribute=t=>{var o;if(V(t),J(t),_&&G(w(f({},_),{attribute:t})),B&&W(w(f({},B),{attribute:t})),b){const s=N(w(f({},b),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),M({newSelectedSphere:b,newSphereList:s}))}},u.current.setSubAttribute=(t,o)=>{var s;const n=e.selectedPointCloudBox;if(n){const l=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=w(f({},l),{[t]:o}),H(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},u.current.clearResult=()=>{g==null||g()},u.current.redo=()=>{k()},u.current.undo=()=>{x()},u.current.setValid=t=>{u.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},u.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},u.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},u.current.asyncData=t=>{setTimeout(()=>{p==null||p(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),c(()=>{u.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},u.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),c(()=>{u.current.history={pushHistory:t=>{q({pointCloudBoxList:t})},initRecord:()=>{}}},[]),c(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||a)return;const s=d=>{V(d)},n=d=>{y.error(d)},l=d=>{y.info(d)};return o.on("syncAttribute",s),o.on("messageError",n),o.on("messageInfo",l),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",n),o.unbind("messageInfo",l)}},[e.topViewInstance]),null};var je=pe(me,null,null,{context:we})(Oe);export{je as default};
@@ -1 +1 @@
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
+ import{useContext as I,useCallback as y}from"react";import{PointCloudContext as x}from"../PointCloudContext.js";var L=(s,g,t)=>new Promise((u,a)=>{var o=i=>{try{e(t.next(i))}catch(l){a(l)}},d=i=>{try{e(t.throw(i))}catch(l){a(l)}},e=i=>i.done?u(i.value):Promise.resolve(i.value).then(o,d);e((t=t.apply(s,g)).next())});const b=({currentData:s})=>{var g;const{mainViewInstance:t,topViewInstance:u,pointCloudBoxList:a,highlight2DDataList:o,setHighlight2DDataList:d}=I(x),e=(g=s==null?void 0:s.mappingImgList)!=null?g:[],i=(r,c,v)=>L(void 0,null,function*(){var p;let h=[...o];if(o.find(n=>n.url===r)?h=o.filter(n=>n.url!==r):h.push({url:r,fallbackUrl:c,calib:v}),d(h),!t||(e==null?void 0:e.length)===0)return;const m=t.pointCloudObject;if(!m)return;const C=yield t.getHighlightIndexByMappingImgList({mappingImgList:h,points:m.geometry.attributes.position.array});try{const n=yield t.highlightOriginPointCloud(a,C),{color:f}=n!=null?n:{};f&&((p=u==null?void 0:u.pointCloudInstance)==null||p.updateColor(f))}catch(n){console.error("toggle2dVisible highlightOriginPointCloud error:",n)}}),l=y(r=>o.findIndex(c=>c.url===r)>=0,[o]);return{toggle2dVisible:i,isHighlightVisible:l}};export{b as useHighlight};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.24.0-alpha.23",
3
+ "version": "1.24.0-alpha.25",
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.28.0-alpha.12",
46
+ "@labelbee/lb-annotation": "1.28.0-alpha.13",
47
47
  "@labelbee/lb-utils": "1.20.0-alpha.1",
48
48
  "@labelbee/wavesurfer": "1.1.0",
49
49
  "@types/react-dom": "18.3.1",