@labelbee/lb-components 1.23.0-alpha.51 → 1.23.0-alpha.52

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";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,i,l)=>i in u?__defProp(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,__spreadValues=(u,i)=>{for(var l in i||(i={}))__hasOwnProp.call(i,l)&&__defNormalProp(u,l,i[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(i))__propIsEnum.call(i,l)&&__defNormalProp(u,l,i[l]);return u},__spreadProps=(u,i)=>__defProps(u,__getOwnPropDescs(i)),__async=(u,i,l)=>new Promise((a,d)=>{var v=s=>{try{p(l.next(s))}catch(f){d(f)}},D=s=>{try{p(l.throw(s))}catch(f){d(f)}},p=s=>s.done?a(s.value):Promise.resolve(s.value).then(v,D);p((l=l.apply(u,i)).next())});const PointCloud2DRectOperationView=u=>{var i,l;const{mappingData:a,size:d,config:v,checkMode:D,afterImgOnLoad:p,shouldExcludePointCloudBoxListUpdate:s}=u,f=(i=a==null?void 0:a.url)!=null?i:"",_=(l=a==null?void 0:a.fallbackUrl)!=null?l:"",{pointCloudBoxList:w,setPointCloudResult:I,defaultAttribute:P,rectList:h,addRectIn2DView:q,updateRectIn2DView:O,removeRectIn2DView:B}=React.useContext(PointCloudContext.PointCloudContext),{update2DViewRect:M,remove2DViewRect:z}=usePointCloudViews.usePointCloudViews(),x=React__default.default.useRef(null),r=React.useRef(null),E=ahooks.useMemoizedFn(M),g=ahooks.useMemoizedFn(z),R=React.useRef(null),[A,L]=React.useState(!0),C=React.useMemo(()=>h==null?void 0:h.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,h]),b=ahooks.useLatest(a==null?void 0:a.path),V=e=>{const{boxID:o}=e;if(!s&&o){const t=E==null?void 0:E(e);R.current=t,I(t);return}O(e,!0)},S=e=>{b.current&&q(__spreadProps(__spreadValues({},e),{imageName:b.current}))},N=e=>{if(e.length===0)return;if(!s){const t=e.find(n=>n.boxID);if(t){const n=g==null?void 0:g(t);R.current=n,I(n),m();return}}const o=e.find(t=>t.extId);if(o){const{imageName:t,extId:n}=o,c=g==null?void 0:g({boxID:n,imageName:t});R.current=c,I(c)}B(e)},F=ahooks.useMemoizedFn(()=>{let e=[];return w.forEach(o=>{const{rects:t=[],id:n,attribute:c,trackID:y}=o,j=t.find(k=>k.imageName===b.current),U=n+"_"+b.current;j&&(e=[...e,__spreadProps(__spreadValues({},j),{boxID:n,id:U,attribute:c,order:y})])}),e}),m=ahooks.useMemoizedFn(()=>{var e,o,t;const n=s?[]:F(),c=(e=r.current)==null?void 0:e.selectedRectID;(o=r.current)==null||o.setResult([...n,...C]),c&&((t=r.current)==null||t.setSelectedRectID(c))});return React.useEffect(()=>{if(x.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:x.current,size:d,config:__spreadProps(__spreadValues({},v),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:D});return r.current=e,r.current.init(),r.current.on("updateDragResult",V),r.current.on("afterAddingDrawingRect",S),r.current.on("deleteSelectedRects",N),()=>{var o,t,n,c;(o=r.current)==null||o.unbind("updateDragResult",V),(t=r.current)==null||t.unbind("afterAddingDrawingRect",S),(n=r.current)==null||n.unbind("deleteSelectedRects",N),(c=r.current)==null||c.destroy()}}},[]),React.useEffect(()=>{const e=t=>__async(void 0,null,function*(){try{return yield lbAnnotation.ImgUtils.load(t)}catch(n){return console.error("Error loading image:",n),null}}),o=()=>__async(void 0,null,function*(){var t;L(!0);let n=yield e(f);!n&&_&&(n=yield e(_)),n&&((t=r.current)==null||t.setImgNode(n),p(n)),L(!1)});r.current&&(f||_)&&o()},[f,_]),React.useEffect(()=>{var e;(e=r.current)==null||e.setSize(d)},[d]),React.useEffect(()=>{w!==R.current&&m()},[w]),React.useEffect(()=>{var e,o,t;const n=C.find(c=>c.id===r.current.selectedRectID);(o=(e=r.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,P),n&&O(__spreadProps(__spreadValues({},(t=r.current)==null?void 0:t.selectedRect),{attribute:P})),m()},[P]),React.useEffect(()=>{m()},[C]),React.useEffect(()=>{m()},[s]),React.useEffect(()=>{var e,o,t,n;const c=(o=(e=r.current)==null?void 0:e.config)!=null?o:{},y=__spreadProps(__spreadValues({},c),{attributeList:(t=v.attributeList)!=null?t:[]});(n=r.current)==null||n.setConfig(JSON.stringify(y))},[v.attributeList]),React__default.default.createElement(es.Spin,{spinning:A},React__default.default.createElement("div",{ref:x,style:__spreadValues({position:"relative"},d)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
1
+ "use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,i,l)=>i in u?__defProp(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,__spreadValues=(u,i)=>{for(var l in i||(i={}))__hasOwnProp.call(i,l)&&__defNormalProp(u,l,i[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(i))__propIsEnum.call(i,l)&&__defNormalProp(u,l,i[l]);return u},__spreadProps=(u,i)=>__defProps(u,__getOwnPropDescs(i)),__async=(u,i,l)=>new Promise((a,d)=>{var m=s=>{try{R(l.next(s))}catch(f){d(f)}},h=s=>{try{R(l.throw(s))}catch(f){d(f)}},R=s=>s.done?a(s.value):Promise.resolve(s.value).then(m,h);R((l=l.apply(u,i)).next())});const PointCloud2DRectOperationView=u=>{var i,l;const{mappingData:a,size:d,config:m,checkMode:h,afterImgOnLoad:R,shouldExcludePointCloudBoxListUpdate:s}=u,f=(i=a==null?void 0:a.url)!=null?i:"",D=(l=a==null?void 0:a.fallbackUrl)!=null?l:"",{pointCloudBoxList:P,setPointCloudResult:x,defaultAttribute:C,rectList:y,addRectIn2DView:q,updateRectIn2DView:B,removeRectIn2DView:M,updateRectListByReducer:z}=React.useContext(PointCloudContext.PointCloudContext),{update2DViewRect:A,remove2DViewRect:F}=usePointCloudViews.usePointCloudViews(),O=React__default.default.useRef(null),n=React.useRef(null),L=ahooks.useMemoizedFn(A),b=ahooks.useMemoizedFn(F),I=React.useRef(null),[U,V]=React.useState(!0),E=React.useMemo(()=>y==null?void 0:y.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,y]),w=ahooks.useLatest(a==null?void 0:a.path),S=e=>{const{boxID:o}=e;if(!s&&o){const r=L==null?void 0:L(e);I.current=r,x(r||[]);return}B(e,!0)},N=e=>{w.current&&q(__spreadProps(__spreadValues({},e),{imageName:w.current}))},j=e=>{if(e.length===0)return;if(!s){const r=e.find(t=>t.boxID);if(r){const t=b==null?void 0:b(r);I.current=t,x(t||[]),_();return}}const o=e.find(r=>r.extId);if(o){const{imageName:r,extId:t}=o,c=b==null?void 0:b({boxID:t,imageName:r});I.current=c,x(c||[])}M(e)},k=ahooks.useMemoizedFn(()=>{let e=[];return P.forEach(o=>{const{rects:r=[],id:t,attribute:c,trackID:v}=o,p=r.find(J=>J.imageName===w.current),g=t+"_"+w.current;p&&(e=[...e,__spreadProps(__spreadValues({},p),{boxID:t,id:g,attribute:c,order:v})])}),e}),_=ahooks.useMemoizedFn(()=>{var e,o,r;const t=s?[]:k(),c=(e=n.current)==null?void 0:e.selectedRectID;(o=n.current)==null||o.setResult([...t,...E]),c&&((r=n.current)==null||r.setSelectedRectID(c))});return React.useEffect(()=>{if(O.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:O.current,size:d,config:__spreadProps(__spreadValues({},m),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:h});return n.current=e,n.current.init(),n.current.on("updateDragResult",S),n.current.on("afterAddingDrawingRect",N),n.current.on("deleteSelectedRects",j),()=>{var o,r,t,c;(o=n.current)==null||o.unbind("updateDragResult",S),(r=n.current)==null||r.unbind("afterAddingDrawingRect",N),(t=n.current)==null||t.unbind("deleteSelectedRects",j),(c=n.current)==null||c.destroy()}}},[]),React.useEffect(()=>{const e=r=>__async(void 0,null,function*(){try{return yield lbAnnotation.ImgUtils.load(r)}catch(t){return console.error("Error loading image:",t),null}}),o=()=>__async(void 0,null,function*(){var r;V(!0);let t=yield e(f);!t&&D&&(t=yield e(D)),t&&((r=n.current)==null||r.setImgNode(t),R(t)),V(!1)});n.current&&(f||D)&&o()},[f,D]),React.useEffect(()=>{var e;(e=n.current)==null||e.setSize(d)},[d]),React.useEffect(()=>{P!==I.current&&_()},[P]),React.useEffect(()=>{var e,o;const r=E.find(t=>t.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,C),r&&z(t=>{var c;const v=[];let p=null;return t.forEach(g=>{g.id!==n.current.selectedRectID?v.push(g):p=g}),r.extId===void 0&&(p=(c=n.current)==null?void 0:c.selectedRect),[...v,__spreadProps(__spreadValues({},p||{}),{attribute:C})]}),_()},[C]),React.useEffect(()=>{_()},[E]),React.useEffect(()=>{_()},[s]),React.useEffect(()=>{var e,o,r,t;const c=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},v=__spreadProps(__spreadValues({},c),{attributeList:(r=m.attributeList)!=null?r:[]});(t=n.current)==null||t.setConfig(JSON.stringify(v))},[m.attributeList]),React__default.default.createElement(es.Spin,{spinning:U},React__default.default.createElement("div",{ref:O,style:__spreadValues({position:"relative"},d)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
@@ -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,D)=>{var R=p=>{try{P(l.next(p))}catch(y){D(y)}},O=p=>{try{P(l.throw(p))}catch(y){D(y)}},P=p=>p.done?w(p.value):Promise.resolve(p.value).then(R,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}),PointCloudProvider=({children:a})=>{const[n,l]=React.useState([]),[w,D]=React.useState([]),[R,O]=React.useState([]),[P,p]=React.useState([]),[y,fe]=React.useState([]),[h,H]=React.useState([]),[A,E]=React.useState([]),[T,ge]=React.useState(!0),[W,me]=React.useState(2),[Z,ve]=React.useState(!0),[U,he]=React.useState(1),[f,J]=React.useState(),[K,Q]=React.useState(),[X,Y]=React.useState(),[d,$]=React.useState(),[ee,Pe]=React.useState(""),[j,Ie]=React.useState(lbAnnotation.EToolName.Rect),Se=React.useRef(new lbAnnotation.ActionsHistory).current,[g,k]=React.useState([]),[te,ye]=React.useState(""),[F,Ce]=React.useState(lbUtils.EPointCloudPattern.Detection),[x,ne]=React.useState(void 0),[q,be]=React.useState([]),[z,we]=React.useState([]),m=index(),[ie,xe]=React.useState({}),Le=ctx.useDispatch(),De=i=>{const{imgNode:o,path:t}=i;t&&o&&xe(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 p(u=>{let C=!1;const b=u.filter(N=>{const G=N[c],M=r.has(G)?N.imageName!==i:!0;return M||(C=!0),M});return C?b:u}),!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:u}=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:u,extId:c,lineDash:[]})}return null}).filter(t=>t!==null);return o.length?(p(t=>{const c=new Set(t.filter(u=>i===u.imageName).map(u=>u.extId)),r=o.filter(u=>c.has(u.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:u}=r;if(!u){console.warn("Missing image name"),console.trace(r,t);return}map.addMapIndirectWeakSetItem(o,u,t.id,t)}),o},new Map),[n]),le=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 D(s),s},c=e=>{ge(e!==!1)},r=e=>{e===void 0&&H([]),typeof e=="string"&&H([e]),Array.isArray(e)&&H(Array.from(new Set(e)))},u=e=>{h.includes(e)?r(h.filter(s=>s!==e)):r([...h,e])},C=e=>{const s=pickRectObject(e);p(v=>[...v,s])},b=(e,s=!1)=>{const v=pickRectObject(e);p(S=>S.map(I=>I.id===e.id?s?__spreadValues(__spreadValues({},I),v):v:I))},N=e=>{p(s=>s.filter(v=>!e.find(S=>S.id===v.id)))},G=e=>{A.includes(e)?E([]):E([e])},M=()=>{if(j===lbAnnotation.EToolName.Rect){const e=n.map(s=>s.id);r(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},_e=e=>{r(n.filter(s=>s.attribute===e).map(s=>s.id))},ce=n.filter(e=>!g.includes(e.attribute)),de=w.filter(e=>!g.includes(e.attribute)),ue=y.filter(e=>e.attribute&&!g.includes(e.attribute)),Ae=e=>{if(g.includes(e))k(g.filter(s=>s!==e));else{const s=g.concat(e);k(s)}},Be=(e=ce,s=R,v=de,S=ue,I=q)=>{var L;d==null||d.clearAllBox(),d==null||d.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(v),f==null||f.updateLineList(S),d==null||d.generateBoxes(e),d==null||d.generateSpheres(v),(L=x==null?void 0:x.store)==null||L.updateCurrentSegment(I),pe(e)},Ve=()=>{J(void 0),Q(void 0),Y(void 0),$(void 0)},pe=(e,s)=>__async(void 0,null,function*(){var v;if(!d)return;const S=d.pointCloudObject;if(!!S)try{const I=yield d.getHighlightIndexByMappingImgList({mappingImgList:s!=null?s:z,points:S.geometry.attributes.position.array}),L=yield d==null?void 0:d.highlightOriginPointCloud(e,I);return L&&((v=f==null?void 0:f.pointCloudInstance)==null||v.updateColor(L)),L}catch(I){console.error(I)}});return{selectedID:oe,pointCloudBoxList:n,pointCloudSphereList:w,displayPointCloudList:ce,displaySphereList:de,displayLineList:ue,selectedIDs:h,setPointCloudResult:l,setSelectedIDs:r,addPointCloudBox:o,addPointCloudSphere:t,setPointCloudSphereList:D,valid:T,selectedPointCloudBox:i,setPointCloudValid:c,addSelectedID:u,addHighlightID:G,selectedAllBoxes:M,topViewInstance:f,setTopViewInstance:J,sideViewInstance:K,setSideViewInstance:Q,backViewInstance:X,setBackViewInstance:Y,mainViewInstance:d,setMainViewInstance:$,polygonList:R,setPolygonList:O,rectList:P,setRectList:p,addRectIn2DView:C,removeRectIn2DView:N,updateRectIn2DView:b,lineList:y,setLineList:fe,zoom:U,setZoom:he,history:Se,toggleAttributesVisible:Ae,hideAttributes:g,setHideAttributes:k,reRender:Be,attrPanelLayout:te,setAttrPanelLayout:ye,syncAllViewPointCloudColor:pe,defaultAttribute:ee,setDefaultAttribute:Pe,pointCloudPattern:j,setPointCloudPattern:Ie,selectSpecAttr:_e,globalPattern:F,setGlobalPattern:e=>{F!==e&&(Le(actionCreators.ChangeSave),Ce(e),e===lbUtils.EPointCloudPattern.Detection&&ne(void 0))},ptSegmentInstance:x,setPtSegmentInstance:ne,segmentation:q,setSegmentation:be,clearAllDetectionInstance:Ve,highlight2DDataList:z,setHighlight2DDataList:we,cuboidBoxIn2DView:Z,setCuboidBoxIn2DView:ve,imageSizes:ie,cacheImageNodeSize:De,highlightIDs:A,setHighlightIDs:E,removeRectByPointCloudBoxId:se,removeRectBySpecifyId:B,addRectFromPointCloudBoxByImageName:ae,rectRotateSensitivity:W,setRectRotateSensitivity:me,imageNamePointCloudBoxMap:re,linkageImageNameRectMap:le}},[T,h,n,w,R,y,P,f,K,X,d,U,g,te,ee,j,F,x,q,z,Z,ie,A,se,B,ae,W,re,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 Re=()=>{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;Re(),(o=(i=f==null?void 0:f.toolInstance)==null?void 0:i.setHiddenAttributes)==null||o.call(i,g),(c=(t=x==null?void 0:x.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"),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 +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,i)=>t in l?__defProp(l,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):l[t]=i,__spreadValues=(l,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(l,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(l,i,t[i]);return l},__spreadProps=(l,t)=>__defProps(l,__getOwnPropDescs(t));const{ESortDirection}=lbAnnotation.cAnnotation,useSingleBox=l=>{const{pointCloudBoxList:t,setPointCloudResult:i,topViewInstance:a,backViewInstance:m,sideViewInstance:w,selectedIDs:P,selectedID:b,mainViewInstance:u,setSelectedIDs:N,syncAllViewPointCloudColor:h,polygonList:j,pointCloudPattern:B,rectList:O,removeRectIn2DView:D,addRectIn2DView:V}=React.useContext(PointCloudContext.PointCloudContext),{selectedPolygon:c,updateSelectedPolygon:k,updatePolygonValidByID:A,deletePolygon:M}=usePolygon.usePolygon(),{pushHistoryWithList:S}=useHistory.useHistory(),s=React.useMemo(()=>{const e=t.findIndex(n=>n.id===b);if(e>-1)return{info:t[e],index:e}},[b,t]),L=React.useCallback(e=>{var n;if(s==null?void 0:s.info){(n=l==null?void 0:l.generateRects)==null||n.call(l,e),t.splice(s.index,1,___default.default.merge(s.info,e));const o=___default.default.cloneDeep(t);return i(o),S({pointCloudBoxList:o}),o}return t},[b,t]),q=React.useCallback((e,n)=>{const o=t.findIndex(d=>d.id===n);if(o>-1){t.splice(o,1,___default.default.merge(t[o],e));const d=___default.default.cloneDeep(t);return i(d),d}return t},[t]),y=React.useCallback(e=>{a==null||a.pointCloud2dOperation.setPolygonValidAndRender(e,!0),w==null||w.pointCloud2dOperation.setPolygonValidAndRender(e,!0),m==null||m.pointCloud2dOperation.setPolygonValidAndRender(e,!0)},[a,w,m]),H=React.useCallback(()=>{if(s==null?void 0:s.info){const{id:e,valid:n=!0}=s.info,o=L({valid:!n});h(o),y(e)}c&&(k(__spreadProps(__spreadValues({},c),{valid:!c.valid})),a==null||a.pointCloud2dOperation.setPolygonValidAndRender(c.id,!0))},[y,s,c]),T=React.useCallback(e=>{const n=t.find(o=>o.id===e);if(n){const{id:o,valid:d=!0}=n,g=q({valid:!d},o);return y(o),g}A(e)},[y,t,j]),E=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,d=o.switchToNextPolygon(e);d&&N(d)},[a,B,a==null?void 0:a.toolInstance]),K=(e=!1)=>{E(ESortDirection.descend,e)},W=(e=!1)=>{E(ESortDirection.ascend,e)},R=e=>{const n=t.filter(o=>o.id!==e);i(n),u==null||u.removeObjectByName(e,"box"),u==null||u.render(),h(n)},z=React.useCallback((e,n)=>{var o,d;const g=new Set((d=(o=n.mappingImgList)==null?void 0:o.map(r=>r.path))!=null?d:[]),p=new Map;e.forEach(r=>{const C=r.id;(r.rects||[]).forEach(I=>{const{imageName:x}=I;if(g.has(x)){let v=p.get(x);v||(v=new Set,p.set(x,v)),v.add(C)}})});const f=O.filter(r=>{var C;const I=r.extId,x=r.imageName;if(x!==void 0&&I!==void 0){const v=p.get(x);return(C=v==null?void 0:v.has(I))!=null?C:!1}return!1});D(f),f.forEach(r=>{V(r)})},[O,D,V]),F=e=>{s&&(R(s.info.id),a==null||a.pointCloud2dOperation.deletePolygon(s.info.id),z([s.info],e)),c&&(M(c.id),a==null||a.pointCloud2dOperation.deletePolygon(c.id))},G=React.useMemo(()=>t.filter(e=>P.includes(e.id)),[P,t]),J=React.useCallback(e=>{var n;const o=___default.default.cloneDeep(t);let d=!1;for(const g of e){const p=o.findIndex(f=>f.id===g.id);if(p>-1){const f=___default.default.merge(o[p],g);(n=l==null?void 0:l.generateRects)==null||n.call(l,f),o.splice(p,1,f),u==null||u.generateBox(f),d=!0}}if(d)return i(o),S({pointCloudBoxList:o}),u==null||u.render(),o},[P,t]),Q=React.useCallback(e=>t.find(n=>n.id===e),[t]);return{selectedBox:s,updateSelectedBox:L,changeSelectedBoxValid:H,changeValidByID:T,selectNextBox:W,selectPrevBox:K,deletePointCloudBox:R,selectedBoxes:G,updateSelectedBoxes:J,getPointCloudByID:Q,deleteSelectedPointCloudBoxAndPolygon:F}};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");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;
@@ -26,6 +26,8 @@ interface IHighlight2DData {
26
26
  fallbackUrl: string;
27
27
  calib?: ICalib;
28
28
  }
29
+ type PickRectObjct = Pick<IPointCloud2DRectOperationViewRect, 'id' | 'attribute' | 'width' | 'height' | 'x' | 'y' | 'imageName'>;
30
+ type UpdateRectListByReducer = (reducer: (prevRectList: IPointCloudBoxRect[], pickRectObject: (item: IPointCloud2DRectOperationViewRect) => PickRectObjct) => IPointCloudBoxRect[]) => void;
29
31
  export interface IPointCloudContext extends IPointCloudContextInstances, IPointCloudStatus, IPointCloudSegment {
30
32
  pointCloudBoxList: IPointCloudBoxList;
31
33
  rectList: IPointCloudBoxRect[];
@@ -94,6 +96,7 @@ export interface IPointCloudContext extends IPointCloudContextInstances, IPointC
94
96
  imageNamePointCloudBoxMap: MapIndirectWeakSet<IPointCloudBox>;
95
97
  /** imageName -> pointCloudBox.id -> [rect, ...] */
96
98
  linkageImageNameRectMap: MapIndirectWeakSet<IPointCloudBoxRect>;
99
+ updateRectListByReducer: UpdateRectListByReducer;
97
100
  }
98
101
  export declare const PointCloudContext: React.Context<IPointCloudContext>;
99
102
  export declare const PointCloudProvider: React.FC<PropsWithChildren<{}>>;
@@ -14,7 +14,7 @@ export declare const useSingleBox: (props?: IUseSingleBoxParams) => {
14
14
  changeValidByID: (id: string) => import("@labelbee/lb-utils").IPointCloudBoxList | undefined;
15
15
  selectNextBox: (manual?: boolean) => void;
16
16
  selectPrevBox: (manual?: boolean) => void;
17
- deletePointCloudBox: (id: string) => void;
17
+ deletePointCloudBox: (id: string, shouldUpdateMatchingRectList?: boolean) => void;
18
18
  selectedBoxes: IPointCloudBox[];
19
19
  updateSelectedBoxes: (updateList: PartialIPointCloudBoxList) => import("@labelbee/lb-utils").IPointCloudBoxList | undefined;
20
20
  getPointCloudByID: (id: string) => IPointCloudBox | undefined;
@@ -1 +1 @@
1
- import{useMemoizedFn as P,useLatest as Y}from"ahooks";import{Spin as Z}from"antd/es";import N,{useContext as ee,useRef as z,useState as te,useMemo as ne,useEffect as d}from"react";import{connect as re}from"react-redux";import{usePointCloudViews as oe}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as ie}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as le}from"../../store/annotation/map.js";import{LabelBeeContext as ce}from"../../store/ctx.js";import{PointCloud2DRectOperation as ue,ImgUtils as ae}from"@labelbee/lb-annotation";var se=Object.defineProperty,de=Object.defineProperties,fe=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,J=(u,i,l)=>i in u?se(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,m=(u,i)=>{for(var l in i||(i={}))pe.call(i,l)&&J(u,l,i[l]);if(F)for(var l of F(i))me.call(i,l)&&J(u,l,i[l]);return u},R=(u,i)=>de(u,fe(i)),T=(u,i,l)=>new Promise((a,f)=>{var v=s=>{try{_(l.next(s))}catch(p){f(p)}},h=s=>{try{_(l.throw(s))}catch(p){f(p)}},_=s=>s.done?a(s.value):Promise.resolve(s.value).then(v,h);_((l=l.apply(u,i)).next())});const ve=u=>{var i,l;const{mappingData:a,size:f,config:v,checkMode:h,afterImgOnLoad:_,shouldExcludePointCloudBoxListUpdate:s}=u,p=(i=a==null?void 0:a.url)!=null?i:"",D=(l=a==null?void 0:a.fallbackUrl)!=null?l:"",{pointCloudBoxList:x,setPointCloudResult:C,defaultAttribute:y,rectList:O,addRectIn2DView:$,updateRectIn2DView:E,removeRectIn2DView:q}=ee(ie),{update2DViewRect:G,remove2DViewRect:H}=oe(),L=N.useRef(null),r=z(null),j=P(G),b=P(H),w=z(null),[K,B]=te(!0),V=ne(()=>O==null?void 0:O.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,O]),I=Y(a==null?void 0:a.path),U=e=>{const{boxID:o}=e;if(!s&&o){const t=j==null?void 0:j(e);w.current=t,C(t);return}E(e,!0)},A=e=>{I.current&&$(R(m({},e),{imageName:I.current}))},k=e=>{if(e.length===0)return;if(!s){const t=e.find(n=>n.boxID);if(t){const n=b==null?void 0:b(t);w.current=n,C(n),g();return}}const o=e.find(t=>t.extId);if(o){const{imageName:t,extId:n}=o,c=b==null?void 0:b({boxID:n,imageName:t});w.current=c,C(c)}q(e)},Q=P(()=>{let e=[];return x.forEach(o=>{const{rects:t=[],id:n,attribute:c,trackID:S}=o,M=t.find(X=>X.imageName===I.current),W=n+"_"+I.current;M&&(e=[...e,R(m({},M),{boxID:n,id:W,attribute:c,order:S})])}),e}),g=P(()=>{var e,o,t;const n=s?[]:Q(),c=(e=r.current)==null?void 0:e.selectedRectID;(o=r.current)==null||o.setResult([...n,...V]),c&&((t=r.current)==null||t.setSelectedRectID(c))});return d(()=>{if(L.current){const e=new ue({container:L.current,size:f,config:R(m({},v),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:h});return r.current=e,r.current.init(),r.current.on("updateDragResult",U),r.current.on("afterAddingDrawingRect",A),r.current.on("deleteSelectedRects",k),()=>{var o,t,n,c;(o=r.current)==null||o.unbind("updateDragResult",U),(t=r.current)==null||t.unbind("afterAddingDrawingRect",A),(n=r.current)==null||n.unbind("deleteSelectedRects",k),(c=r.current)==null||c.destroy()}}},[]),d(()=>{const e=t=>T(void 0,null,function*(){try{return yield ae.load(t)}catch(n){return console.error("Error loading image:",n),null}}),o=()=>T(void 0,null,function*(){var t;B(!0);let n=yield e(p);!n&&D&&(n=yield e(D)),n&&((t=r.current)==null||t.setImgNode(n),_(n)),B(!1)});r.current&&(p||D)&&o()},[p,D]),d(()=>{var e;(e=r.current)==null||e.setSize(f)},[f]),d(()=>{x!==w.current&&g()},[x]),d(()=>{var e,o,t;const n=V.find(c=>c.id===r.current.selectedRectID);(o=(e=r.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,y),n&&E(R(m({},(t=r.current)==null?void 0:t.selectedRect),{attribute:y})),g()},[y]),d(()=>{g()},[V]),d(()=>{g()},[s]),d(()=>{var e,o,t,n;const c=(o=(e=r.current)==null?void 0:e.config)!=null?o:{},S=R(m({},c),{attributeList:(t=v.attributeList)!=null?t:[]});(n=r.current)==null||n.setConfig(JSON.stringify(S))},[v.attributeList]),N.createElement(Z,{spinning:K},N.createElement("div",{ref:L,style:m({position:"relative"},f)}))};var _e=re(le,null,null,{context:ce})(ve);export{_e as default};
1
+ import{useMemoizedFn as y,useLatest as Z}from"ahooks";import{Spin as ee}from"antd/es";import B,{useContext as te,useRef as z,useState as re,useMemo as ne,useEffect as d}from"react";import{connect as oe}from"react-redux";import{usePointCloudViews as ie}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as le}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ce}from"../../store/annotation/map.js";import{LabelBeeContext as ue}from"../../store/ctx.js";import{PointCloud2DRectOperation as ae,ImgUtils as se}from"@labelbee/lb-annotation";var de=Object.defineProperty,fe=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable,J=(u,i,l)=>i in u?de(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,_=(u,i)=>{for(var l in i||(i={}))me.call(i,l)&&J(u,l,i[l]);if(F)for(var l of F(i))ve.call(i,l)&&J(u,l,i[l]);return u},I=(u,i)=>fe(u,pe(i)),T=(u,i,l)=>new Promise((a,f)=>{var g=s=>{try{R(l.next(s))}catch(p){f(p)}},C=s=>{try{R(l.throw(s))}catch(p){f(p)}},R=s=>s.done?a(s.value):Promise.resolve(s.value).then(g,C);R((l=l.apply(u,i)).next())});const _e=u=>{var i,l;const{mappingData:a,size:f,config:g,checkMode:C,afterImgOnLoad:R,shouldExcludePointCloudBoxListUpdate:s}=u,p=(i=a==null?void 0:a.url)!=null?i:"",w=(l=a==null?void 0:a.fallbackUrl)!=null?l:"",{pointCloudBoxList:O,setPointCloudResult:L,defaultAttribute:V,rectList:S,addRectIn2DView:$,updateRectIn2DView:q,removeRectIn2DView:G,updateRectListByReducer:H}=te(le),{update2DViewRect:K,remove2DViewRect:Q}=ie(),E=B.useRef(null),n=z(null),j=y(K),h=y(Q),P=z(null),[W,U]=re(!0),N=ne(()=>S==null?void 0:S.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,S]),x=Z(a==null?void 0:a.path),A=e=>{const{boxID:o}=e;if(!s&&o){const r=j==null?void 0:j(e);P.current=r,L(r||[]);return}q(e,!0)},k=e=>{x.current&&$(I(_({},e),{imageName:x.current}))},M=e=>{if(e.length===0)return;if(!s){const r=e.find(t=>t.boxID);if(r){const t=h==null?void 0:h(r);P.current=t,L(t||[]),D();return}}const o=e.find(r=>r.extId);if(o){const{imageName:r,extId:t}=o,c=h==null?void 0:h({boxID:t,imageName:r});P.current=c,L(c||[])}G(e)},X=y(()=>{let e=[];return O.forEach(o=>{const{rects:r=[],id:t,attribute:c,trackID:m}=o,v=r.find(Y=>Y.imageName===x.current),b=t+"_"+x.current;v&&(e=[...e,I(_({},v),{boxID:t,id:b,attribute:c,order:m})])}),e}),D=y(()=>{var e,o,r;const t=s?[]:X(),c=(e=n.current)==null?void 0:e.selectedRectID;(o=n.current)==null||o.setResult([...t,...N]),c&&((r=n.current)==null||r.setSelectedRectID(c))});return d(()=>{if(E.current){const e=new ae({container:E.current,size:f,config:I(_({},g),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:C});return n.current=e,n.current.init(),n.current.on("updateDragResult",A),n.current.on("afterAddingDrawingRect",k),n.current.on("deleteSelectedRects",M),()=>{var o,r,t,c;(o=n.current)==null||o.unbind("updateDragResult",A),(r=n.current)==null||r.unbind("afterAddingDrawingRect",k),(t=n.current)==null||t.unbind("deleteSelectedRects",M),(c=n.current)==null||c.destroy()}}},[]),d(()=>{const e=r=>T(void 0,null,function*(){try{return yield se.load(r)}catch(t){return console.error("Error loading image:",t),null}}),o=()=>T(void 0,null,function*(){var r;U(!0);let t=yield e(p);!t&&w&&(t=yield e(w)),t&&((r=n.current)==null||r.setImgNode(t),R(t)),U(!1)});n.current&&(p||w)&&o()},[p,w]),d(()=>{var e;(e=n.current)==null||e.setSize(f)},[f]),d(()=>{O!==P.current&&D()},[O]),d(()=>{var e,o;const r=N.find(t=>t.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,V),r&&H(t=>{var c;const m=[];let v=null;return t.forEach(b=>{b.id!==n.current.selectedRectID?m.push(b):v=b}),r.extId===void 0&&(v=(c=n.current)==null?void 0:c.selectedRect),[...m,I(_({},v||{}),{attribute:V})]}),D()},[V]),d(()=>{D()},[N]),d(()=>{D()},[s]),d(()=>{var e,o,r,t;const c=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},m=I(_({},c),{attributeList:(r=g.attributeList)!=null?r:[]});(t=n.current)==null||t.setConfig(JSON.stringify(m))},[g.attributeList]),B.createElement(ee,{spinning:W},B.createElement("div",{ref:E,style:_({position:"relative"},f)}))};var ge=oe(ce,null,null,{context:ue})(_e);export{ge as default};
@@ -1 +1 @@
1
- import{EPointCloudPattern as q}from"@labelbee/lb-utils";import Pt,{useState as r,useRef as Kt,useMemo as H,useCallback as J,useEffect as K}from"react";import{ActionsHistory as yt,EToolName as Q,uuid as Qt}from"@labelbee/lb-annotation";import{useDispatch as Ut}from"../../store/ctx.js";import{ChangeSave as Xt}from"../../store/annotation/actionCreators.js";import Yt from"../../store/annotatedBox/index.js";import wt from"lodash";import{addMapIndirectWeakSetItem as bt}from"./utils/map.js";var $t=Object.defineProperty,te=Object.defineProperties,ee=Object.getOwnPropertyDescriptors,Ct=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable,St=(a,n,c)=>n in a?$t(a,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[n]=c,M=(a,n)=>{for(var c in n||(n={}))ne.call(n,c)&&St(a,c,n[c]);if(Ct)for(var c of Ct(n))ie.call(n,c)&&St(a,c,n[c]);return a},Lt=(a,n)=>te(a,ee(n)),oe=(a,n,c)=>new Promise((L,R)=>{var A=m=>{try{P(c.next(m))}catch(b){R(b)}},j=m=>{try{P(c.throw(m))}catch(b){R(b)}},P=m=>m.done?L(m.value):Promise.resolve(m.value).then(A,j);P((c=c.apply(a,n)).next())});const Dt=a=>wt.pick(a,["id","attribute","width","height","x","y","imageName"]),xt=Pt.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new yt,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:Q.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:q.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:a=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:a=>!1,removeRectBySpecifyId:(a,n,c)=>!1,removeRectByPointCloudBoxId:a=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map}),se=({children:a})=>{const[n,c]=r([]),[L,R]=r([]),[A,j]=r([]),[P,m]=r([]),[b,Rt]=r([]),[I,k]=r([]),[_,F]=r([]),[U,At]=r(!0),[X,_t]=r(2),[Y,Bt]=r(!0),[$,Vt]=r(1),[f,tt]=r(),[et,nt]=r(),[it,ot]=r(),[u,st]=r(),[rt,Nt]=r(""),[z,Ot]=r(Q.Rect),Ht=Kt(new yt).current,[g,E]=r([]),[lt,Mt]=r(""),[G,jt]=r(q.Detection),[D,at]=r(void 0),[T,kt]=r([]),[Z,Ft]=r([]),h=Yt(),[ct,zt]=r({}),Et=Ut(),Gt=i=>{const{imgNode:o,path:e}=i;e&&o&&zt(d=>Lt(M({},d),{[e]:{width:o.width,height:o.height}}))},dt=H(()=>I.length===1?I[0]:"",[I]),B=J((i,o,e="extId")=>{const d=e||"id",l=new Set(o);return m(p=>{let C=!1;const S=p.filter(N=>{const W=N[d],O=l.has(W)?N.imageName!==i:!0;return O||(C=!0),O});return C?S:p}),!0},[]),ut=J(i=>{const o=n.map(e=>e.id);return B(i,o,"extId")},[n,B]),pt=J(i=>{if(!i)return!1;const o=n.filter(e=>Array.isArray(e.rects)).map(e=>{const{id:d,attribute:l,trackID:p}=e,C=e.rects.find(S=>S.imageName===i);if(C){const S=wt.pick(C,["width","height","x","y","imageName"]);return Lt(M({},S),{id:Qt(),attribute:l,order:p,extId:d,lineDash:[]})}return null}).filter(e=>e!==null);return o.length?(m(e=>{const d=new Set(e.filter(p=>i===p.imageName).map(p=>p.extId)),l=o.filter(p=>d.has(p.extId)===!1);return l.length?[...e,...l]:e}),!0):!1},[n]),mt=H(()=>n.filter(o=>Array.isArray(o.rects)&&o.rects.length>0).reduce((o,e)=>{var d;return(d=e.rects)==null||d.forEach(l=>{const{imageName:p}=l;if(!p){console.warn("Missing image name"),console.trace(l,e);return}bt(o,p,e.id,e)}),o},new Map),[n]),ft=H(()=>P.filter(i=>i.extId!==void 0&&i.id!==void 0).reduce((i,o)=>{const e=o.imageName;return e?(bt(i,e,o.extId,o),i):(console.warn("missing image name"),console.log(o,P),i)},new Map),[P]),V=H(()=>{const i=n.find(t=>t.id===dt),o=t=>{const s=n.concat(t);return c(s),s},e=t=>{const s=L.concat(t);return R(s),s},d=t=>{At(t!==!1)},l=t=>{t===void 0&&k([]),typeof t=="string"&&k([t]),Array.isArray(t)&&k(Array.from(new Set(t)))},p=t=>{I.includes(t)?l(I.filter(s=>s!==t)):l([...I,t])},C=t=>{const s=Dt(t);m(v=>[...v,s])},S=(t,s=!1)=>{const v=Dt(t);m(w=>w.map(y=>y.id===t.id?s?M(M({},y),v):v:y))},N=t=>{m(s=>s.filter(v=>!t.find(w=>w.id===v.id)))},W=t=>{_.includes(t)?F([]):F([t])},O=()=>{if(z===Q.Rect){const t=n.map(s=>s.id);l(t),f==null||f.pointCloud2dOperation.setSelectedIDs(t)}},Zt=t=>{l(n.filter(s=>s.attribute===t).map(s=>s.id))},gt=n.filter(t=>!g.includes(t.attribute)),ht=L.filter(t=>!g.includes(t.attribute)),vt=b.filter(t=>t.attribute&&!g.includes(t.attribute)),Wt=t=>{if(g.includes(t))E(g.filter(s=>s!==t));else{const s=g.concat(t);E(s)}},qt=(t=gt,s=A,v=ht,w=vt,y=T)=>{var x;u==null||u.clearAllBox(),u==null||u.clearAllSphere(),f==null||f.updatePolygonList(t,s),f==null||f.updatePointList(v),f==null||f.updateLineList(w),u==null||u.generateBoxes(t),u==null||u.generateSpheres(v),(x=D==null?void 0:D.store)==null||x.updateCurrentSegment(y),It(t)},Jt=()=>{tt(void 0),nt(void 0),ot(void 0),st(void 0)},It=(t,s)=>oe(void 0,null,function*(){var v;if(!u)return;const w=u.pointCloudObject;if(!!w)try{const y=yield u.getHighlightIndexByMappingImgList({mappingImgList:s!=null?s:Z,points:w.geometry.attributes.position.array}),x=yield u==null?void 0:u.highlightOriginPointCloud(t,y);return x&&((v=f==null?void 0:f.pointCloudInstance)==null||v.updateColor(x)),x}catch(y){console.error(y)}});return{selectedID:dt,pointCloudBoxList:n,pointCloudSphereList:L,displayPointCloudList:gt,displaySphereList:ht,displayLineList:vt,selectedIDs:I,setPointCloudResult:c,setSelectedIDs:l,addPointCloudBox:o,addPointCloudSphere:e,setPointCloudSphereList:R,valid:U,selectedPointCloudBox:i,setPointCloudValid:d,addSelectedID:p,addHighlightID:W,selectedAllBoxes:O,topViewInstance:f,setTopViewInstance:tt,sideViewInstance:et,setSideViewInstance:nt,backViewInstance:it,setBackViewInstance:ot,mainViewInstance:u,setMainViewInstance:st,polygonList:A,setPolygonList:j,rectList:P,setRectList:m,addRectIn2DView:C,removeRectIn2DView:N,updateRectIn2DView:S,lineList:b,setLineList:Rt,zoom:$,setZoom:Vt,history:Ht,toggleAttributesVisible:Wt,hideAttributes:g,setHideAttributes:E,reRender:qt,attrPanelLayout:lt,setAttrPanelLayout:Mt,syncAllViewPointCloudColor:It,defaultAttribute:rt,setDefaultAttribute:Nt,pointCloudPattern:z,setPointCloudPattern:Ot,selectSpecAttr:Zt,globalPattern:G,setGlobalPattern:t=>{G!==t&&(Et(Xt),jt(t),t===q.Detection&&at(void 0))},ptSegmentInstance:D,setPtSegmentInstance:at,segmentation:T,setSegmentation:kt,clearAllDetectionInstance:Jt,highlight2DDataList:Z,setHighlight2DDataList:Ft,cuboidBoxIn2DView:Y,setCuboidBoxIn2DView:Bt,imageSizes:ct,cacheImageNodeSize:Gt,highlightIDs:_,setHighlightIDs:F,removeRectByPointCloudBoxId:ut,removeRectBySpecifyId:B,addRectFromPointCloudBoxByImageName:pt,rectRotateSensitivity:X,setRectRotateSensitivity:_t,imageNamePointCloudBoxMap:mt,linkageImageNameRectMap:ft}},[U,I,n,L,A,b,P,f,et,it,u,$,g,lt,rt,z,G,D,T,Z,Y,ct,_,ut,B,pt,X,mt,ft]);K(()=>{var i,o,e;(i=h==null?void 0:h.setPointCloudBoxList)==null||i.call(h,n),(o=h==null?void 0:h.setHighlightIDs)==null||o.call(h,_),(e=h==null?void 0:h.setSelectedIDs)==null||e.call(h,I)},[n,I,_]),K(()=>{var i;(i=h==null?void 0:h.setPtCtx)==null||i.call(h,V)},[V]);const Tt=()=>{const i=n.filter(l=>g.includes(l.attribute)),{setSelectedIDs:o,reRender:e}=V,d=i.map(l=>l.id);d.length>0&&o(I.filter(l=>!d.includes(l))),e()};return K(()=>{var i,o,e,d;Tt(),(o=(i=f==null?void 0:f.toolInstance)==null?void 0:i.setHiddenAttributes)==null||o.call(i,g),(d=(e=D==null?void 0:D.store)==null?void 0:e.setHiddenAttributes)==null||d.call(e,g)},[g]),Pt.createElement(xt.Provider,{value:V},a)};export{xt as PointCloudContext,se as PointCloudProvider};
1
+ 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 +1 @@
1
- import{useContext as oe,useMemo as A,useCallback as c}from"react";import m from"lodash";import{PointCloudContext as te}from"../PointCloudContext.js";import{EToolName as M,cAnnotation as ne}from"@labelbee/lb-annotation";import{useHistory as ie}from"./useHistory.js";import{usePolygon as le}from"./usePolygon.js";var de=Object.defineProperty,re=Object.defineProperties,se=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,T=(i,o,l)=>o in i?de(i,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[o]=l,ue=(i,o)=>{for(var l in o||(o={}))ae.call(o,l)&&T(i,l,o[l]);if(H)for(var l of H(o))ce.call(o,l)&&T(i,l,o[l]);return i},fe=(i,o)=>re(i,se(o));const{ESortDirection:B}=ne,pe=i=>{const{pointCloudBoxList:o,setPointCloudResult:l,topViewInstance:r,backViewInstance:_,sideViewInstance:h,selectedIDs:y,selectedID:O,mainViewInstance:u,setSelectedIDs:k,syncAllViewPointCloudColor:b,polygonList:K,pointCloudPattern:V,rectList:D,removeRectIn2DView:S,addRectIn2DView:L}=oe(te),{selectedPolygon:f,updateSelectedPolygon:W,updatePolygonValidByID:q,deletePolygon:z}=le(),{pushHistoryWithList:E}=ie(),s=A(()=>{const e=o.findIndex(n=>n.id===O);if(e>-1)return{info:o[e],index:e}},[O,o]),R=c(e=>{var n;if(s==null?void 0:s.info){(n=i==null?void 0:i.generateRects)==null||n.call(i,e),o.splice(s.index,1,m.merge(s.info,e));const t=m.cloneDeep(o);return l(t),E({pointCloudBoxList:t}),t}return o},[O,o]),F=c((e,n)=>{const t=o.findIndex(d=>d.id===n);if(t>-1){o.splice(t,1,m.merge(o[t],e));const d=m.cloneDeep(o);return l(d),d}return o},[o]),I=c(e=>{r==null||r.pointCloud2dOperation.setPolygonValidAndRender(e,!0),h==null||h.pointCloud2dOperation.setPolygonValidAndRender(e,!0),_==null||_.pointCloud2dOperation.setPolygonValidAndRender(e,!0)},[r,h,_]),G=c(()=>{if(s==null?void 0:s.info){const{id:e,valid:n=!0}=s.info,t=R({valid:!n});b(t),I(e)}f&&(W(fe(ue({},f),{valid:!f.valid})),r==null||r.pointCloud2dOperation.setPolygonValidAndRender(f.id,!0))},[I,s,f]),J=c(e=>{const n=o.find(t=>t.id===e);if(n){const{id:t,valid:d=!0}=n,x=F({valid:!d},t);return I(t),x}q(e)},[I,o,K]),N=c((e=B.ascend,n=!1)=>{if(!r||y.length>1)return;if(V!==M.Rect&&V!==M.Polygon){n&&document.dispatchEvent(new KeyboardEvent("keydown",{keyCode:9,shiftKey:e!==B.ascend}));return}const{pointCloud2dOperation:t}=r,d=t.switchToNextPolygon(e);d&&k(d)},[r,V,r==null?void 0:r.toolInstance]),Q=(e=!1)=>{N(B.descend,e)},U=(e=!1)=>{N(B.ascend,e)},j=e=>{const n=o.filter(t=>t.id!==e);l(n),u==null||u.removeObjectByName(e,"box"),u==null||u.render(),b(n)},X=c((e,n)=>{var t,d;const x=new Set((d=(t=n.mappingImgList)==null?void 0:t.map(a=>a.path))!=null?d:[]),v=new Map;e.forEach(a=>{const C=a.id;(a.rects||[]).forEach(w=>{const{imageName:P}=w;if(x.has(P)){let g=v.get(P);g||(g=new Set,v.set(P,g)),g.add(C)}})});const p=D.filter(a=>{var C;const w=a.extId,P=a.imageName;if(P!==void 0&&w!==void 0){const g=v.get(P);return(C=g==null?void 0:g.has(w))!=null?C:!1}return!1});S(p),p.forEach(a=>{L(a)})},[D,S,L]),Y=e=>{s&&(j(s.info.id),r==null||r.pointCloud2dOperation.deletePolygon(s.info.id),X([s.info],e)),f&&(z(f.id),r==null||r.pointCloud2dOperation.deletePolygon(f.id))},Z=A(()=>o.filter(e=>y.includes(e.id)),[y,o]),$=c(e=>{var n;const t=m.cloneDeep(o);let d=!1;for(const x of e){const v=t.findIndex(p=>p.id===x.id);if(v>-1){const p=m.merge(t[v],x);(n=i==null?void 0:i.generateRects)==null||n.call(i,p),t.splice(v,1,p),u==null||u.generateBox(p),d=!0}}if(d)return l(t),E({pointCloudBoxList:t}),u==null||u.render(),t},[y,o]),ee=c(e=>o.find(n=>n.id===e),[o]);return{selectedBox:s,updateSelectedBox:R,changeSelectedBoxValid:G,changeValidByID:J,selectNextBox:U,selectPrevBox:Q,deletePointCloudBox:j,selectedBoxes:Z,updateSelectedBoxes:$,getPointCloudByID:ee,deleteSelectedPointCloudBoxAndPolygon:Y}};export{pe as useSingleBox};
1
+ 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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.51",
3
+ "version": "1.23.0-alpha.52",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",