@labelbee/lb-components 1.23.0-alpha.77 → 1.23.0-alpha.78
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(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}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=(l,n,d)=>n in l?__defProp(l,n,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[n]=d,__spreadValues=(l,n)=>{for(var d in n||(n={}))__hasOwnProp.call(n,d)&&__defNormalProp(l,d,n[d]);if(__getOwnPropSymbols)for(var d of __getOwnPropSymbols(n))__propIsEnum.call(n,d)&&__defNormalProp(l,d,n[d]);return l},__spreadProps=(l,n)=>__defProps(l,__getOwnPropDescs(n)),__async=(l,n,d)=>new Promise((S,y)=>{var R=c=>{try{f(d.next(c))}catch(b){y(b)}},H=c=>{try{f(d.throw(c))}catch(b){y(b)}},f=c=>c.done?S(c.value):Promise.resolve(c.value).then(R,H);f((d=d.apply(l,n)).next())});const pickRectObject=l=>___default.default.pick(l,["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:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:l=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:l=>!1,removeRectBySpecifyId:(l,n,d)=>!1,removeRectByPointCloudBoxId:l=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener()}),PointCloudProvider=({children:l})=>{const[n,d]=React.useState([]),[S,y]=React.useState([]),[R,H]=React.useState([]),[f,c]=React.useState([]),[b,me]=React.useState([]),[h,D]=React.useState([]),[w,O]=React.useState([]),[W,ve]=React.useState(!0),[K,Ce]=React.useState(2),[G,Ie]=React.useState(!0),[U,Pe]=React.useState(1),[u,Z]=React.useState(),[J,Q]=React.useState(),[X,Y]=React.useState(),[a,$]=React.useState(),[ee,Se]=React.useState(""),[A,be]=React.useState(lbAnnotation.EToolName.Rect),B=React.useRef(new lbAnnotation.ActionsHistory).current,[g,E]=React.useState([]),[te,we]=React.useState(""),[k,ye]=React.useState(lbUtils.EPointCloudPattern.Detection),[P,oe]=React.useState(void 0),[j,Re]=React.useState([]),[V,xe]=React.useState([]),[ne,Le]=React.useState(!1),p=index(),[ie,De]=React.useState({}),Ae=ctx.useDispatch(),Be=e=>{const{imgNode:t,path:o}=e;o&&t&&De(i=>__spreadProps(__spreadValues({},i),{[o]:{width:t.width,height:t.height}}))},q=React.useMemo(()=>h.length===1?h[0]:"",[h]),se=useWindowKeydownListener.default(),M=React.useCallback((e,t,o="extId")=>{const i=o||"id",s=new Set(t);return c(r=>{let C=!1;const m=r.filter(L=>{const I=L[i],v=s.has(I)?L.imageName!==e:!0;return v||(C=!0),v});return C?m:r}),!0},[]),le=React.useCallback(e=>{const t=n.map(o=>o.id);return M(e,t,"extId")},[n,M]),re=React.useCallback(e=>{if(!e)return!1;const t=n.filter(o=>Array.isArray(o.rects)).map(o=>{const{id:i,attribute:s,trackID:r}=o,C=o.rects.find(m=>m.imageName===e);if(C){const m=___default.default.pick(C,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},m),{id:lbAnnotation.uuid(),attribute:s,order:r,extId:i,lineDash:[]})}return null}).filter(o=>o!==null);return t.length?(c(o=>{const i=new Set(o.filter(r=>e===r.imageName).map(r=>r.extId)),s=t.filter(r=>i.has(r.extId)===!1);return s.length?[...o,...s]:o}),!0):!1},[n]),ae=React.useMemo(()=>n.filter(t=>Array.isArray(t.rects)&&t.rects.length>0).reduce((t,o)=>{var i;return(i=o.rects)==null||i.forEach(s=>{const{imageName:r}=s;if(!r){console.warn("Missing image name"),console.trace(s,o);return}map.addMapIndirectWeakSetItem(t,r,o.id,o)}),t},new Map),[n]),de=React.useCallback(e=>{c(t=>e(t,pickRectObject))},[pickRectObject]),ue=React.useMemo(()=>f.filter(e=>e.extId!==void 0&&e.id!==void 0).reduce((e,t)=>{const o=t.imageName;return o?(map.addMapIndirectWeakSetItem(e,o,t.extId,t),e):(console.warn("missing image name"),console.log(t,f),e)},new Map),[f]),{fn:_e}=useTimeoutFunc.default(e=>{D(t=>{const o=e,i=new Set(o);let s=!1;const r=t.filter(C=>{const m=i.has(C);return m||(s=!0),m});return s?r:t})},200),ce=React.useCallback(e=>{const t=e.map(o=>o.id);d(e),_e(t)},[]),ge=React.useMemo(()=>n.find(e=>e.id===q),[n,q]),F=React.useMemo(()=>n.filter(e=>!g.includes(e.attribute)),[n,g]),T=React.useMemo(()=>S.filter(e=>!g.includes(e.attribute)),[S,g]),z=React.useMemo(()=>b.filter(e=>e.attribute&&!g.includes(e.attribute)),[b,g]),ke=React.useCallback(e=>{const t=n.concat(e);return ce(t),t},[n]),Ve=React.useCallback(e=>{const t=S.concat(e);return y(t),t},[S]),Me=React.useCallback(e=>{ve(e!==!1)},[]),x=React.useCallback(e=>{e===void 0&&D([]),typeof e=="string"&&D([e]),Array.isArray(e)&&D(Array.from(new Set(e)))},[]),Ne=React.useCallback(e=>{h.includes(e)?x(h.filter(t=>t!==e)):x([...h,e])},[h]),He=React.useCallback(e=>{const t=pickRectObject(e);c(o=>[...o,t])},[f]),Oe=React.useCallback((e,t=!1)=>{const o=pickRectObject(e);c(i=>i.map(s=>s.id===e.id?t?__spreadValues(__spreadValues({},s),o):o:s))},[f]),Ee=React.useCallback(e=>{c(t=>t.filter(o=>!e.find(i=>i.id===o.id)))},[f]),je=React.useCallback(e=>{w.includes(e)?O([]):O([e])},[w]),qe=React.useCallback(()=>{if(A===lbAnnotation.EToolName.Rect){const e=n.map(t=>t.id);x(e),u==null||u.pointCloud2dOperation.setSelectedIDs(e)}},[A,n,u,u==null?void 0:u.pointCloud2dOperation]),Fe=React.useCallback(e=>{x(n.filter(t=>t.attribute===e).map(t=>t.id))},[n]),Te=React.useCallback(e=>{if(g.includes(e))E(g.filter(t=>t!==e));else{const t=g.concat(e);E(t)}},[g]),ze=React.useCallback((e=F,t=R,o=T,i=z,s=j)=>{var r;a==null||a.clearAllBox(),a==null||a.clearAllSphere(),u==null||u.updatePolygonList(e,t),u==null||u.updatePointList(o),u==null||u.updateLineList(i),a==null||a.generateBoxes(e),a==null||a.generateSpheres(o),(r=P==null?void 0:P.store)==null||r.updateCurrentSegment(s),fe(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},[a,u,P,P==null?void 0:P.store]),We=React.useCallback(()=>{Z(void 0),Q(void 0),Y(void 0),$(void 0)},[]),fe=React.useCallback((e,t,o)=>__async(void 0,null,function*(){var i,s,r;if(!a)return;const C=a.pointCloudObject;if(!C)return;let m=[],L=[];try{if(t&&B.record.length){const{record:I,recordIndex:v}=B;let pe=v;v>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&t.length===((i=I[v])==null?void 0:i.pointCloudBoxList.length))&&(pe=v-1);let Ue=(s=I[pe])==null?void 0:s.pointCloudBoxList;const he=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,t,Ue);m=he.modifiedBoxIds,L=he.resetAreas}}catch(I){console.error("call calcResetAreasAndBoxIds error",I)}try{const I=yield a.getHighlightIndexByMappingImgList({mappingImgList:o!=null?o:V,points:C.geometry.attributes.position.array}),v=yield a==null?void 0:a.highlightOriginPointCloud(t,I,{modifiedBoxIds:m,resetAreas:L});return v&&((r=u==null?void 0:u.pointCloudInstance)==null||r.updateColor(v)),v}catch(I){console.error("call highlightOriginPointCloud error",I)}}),[a,a==null?void 0:a.pointCloudObject,B,V]),Ke=React.useCallback(e=>{k!==e&&(Ae(actionCreators.ChangeSave),ye(e),e===lbUtils.EPointCloudPattern.Detection&&oe(void 0))},[k]),N=React.useMemo(()=>({selectedID:q,pointCloudBoxList:n,pointCloudSphereList:S,displayPointCloudList:F,displaySphereList:T,displayLineList:z,selectedIDs:h,setPointCloudResult:ce,setSelectedIDs:x,addPointCloudBox:ke,addPointCloudSphere:Ve,setPointCloudSphereList:y,valid:W,selectedPointCloudBox:ge,setPointCloudValid:Me,addSelectedID:Ne,addHighlightID:je,selectedAllBoxes:qe,topViewInstance:u,setTopViewInstance:Z,sideViewInstance:J,setSideViewInstance:Q,backViewInstance:X,setBackViewInstance:Y,mainViewInstance:a,setMainViewInstance:$,polygonList:R,setPolygonList:H,rectList:f,setRectList:c,addRectIn2DView:He,removeRectIn2DView:Ee,updateRectIn2DView:Oe,lineList:b,setLineList:me,zoom:U,setZoom:Pe,history:B,toggleAttributesVisible:Te,hideAttributes:g,setHideAttributes:E,reRender:ze,attrPanelLayout:te,setAttrPanelLayout:we,syncAllViewPointCloudColor:fe,defaultAttribute:ee,setDefaultAttribute:Se,pointCloudPattern:A,setPointCloudPattern:be,selectSpecAttr:Fe,globalPattern:k,setGlobalPattern:Ke,ptSegmentInstance:P,setPtSegmentInstance:oe,segmentation:j,setSegmentation:Re,clearAllDetectionInstance:We,highlight2DDataList:V,setHighlight2DDataList:xe,highlight2DLoading:ne,setHighlight2DLoading:Le,cuboidBoxIn2DView:G,setCuboidBoxIn2DView:Ie,imageSizes:ie,cacheImageNodeSize:Be,highlightIDs:w,setHighlightIDs:O,removeRectByPointCloudBoxId:le,removeRectBySpecifyId:M,addRectFromPointCloudBoxByImageName:re,rectRotateSensitivity:K,setRectRotateSensitivity:Ce,imageNamePointCloudBoxMap:ae,linkageImageNameRectMap:ue,updateRectListByReducer:de,windowKeydownListenerHook:se}),[W,ge,F,T,z,R,f,u,J,X,a,U,te,ee,A,k,P,j,V,ne,G,ie,w,le,M,re,K,ae,ue,de,se]);React.useEffect(()=>{var e,t,o;(e=p==null?void 0:p.setPointCloudBoxList)==null||e.call(p,n),(t=p==null?void 0:p.setHighlightIDs)==null||t.call(p,w),(o=p==null?void 0:p.setSelectedIDs)==null||o.call(p,h)},[n,h,w]),React.useEffect(()=>{var e;(e=p==null?void 0:p.setPtCtx)==null||e.call(p,N)},[N]);const Ge=()=>{const e=n.filter(s=>g.includes(s.attribute)),{setSelectedIDs:t,reRender:o}=N,i=e.map(s=>s.id);i.length>0&&t(h.filter(s=>!i.includes(s))),o()};return React.useEffect(()=>{var e,t,o,i;Ge(),(t=(e=u==null?void 0:u.toolInstance)==null?void 0:e.setHiddenAttributes)==null||t.call(e,g),(i=(o=P==null?void 0:P.store)==null?void 0:o.setHiddenAttributes)==null||i.call(o,g)},[g]),React__default.default.createElement(PointCloudContext.Provider,{value:N},l)};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,i,d)=>i in r?__defProp(r,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):r[i]=d,__spreadValues=(r,i)=>{for(var d in i||(i={}))__hasOwnProp.call(i,d)&&__defNormalProp(r,d,i[d]);if(__getOwnPropSymbols)for(var d of __getOwnPropSymbols(i))__propIsEnum.call(i,d)&&__defNormalProp(r,d,i[d]);return r},__spreadProps=(r,i)=>__defProps(r,__getOwnPropDescs(i)),__async=(r,i,d)=>new Promise((x,D)=>{var A=u=>{try{I(d.next(u))}catch(R){D(R)}},O=u=>{try{I(d.throw(u))}catch(R){D(R)}},I=u=>u.done?x(u.value):Promise.resolve(u.value).then(A,O);I((d=d.apply(r,i)).next())});const pickRectObject=r=>___default.default.pick(r,["id","attribute","width","height","x","y","imageName"]),PointCloudContext=React__default.default.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new lbAnnotation.ActionsHistory,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:lbAnnotation.EToolName.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:lbUtils.EPointCloudPattern.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,i,d)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener()}),PointCloudProvider=({children:r})=>{const[i,d]=React.useState([]),[x,D]=React.useState([]),[A,O]=React.useState([]),[I,u]=React.useState([]),[R,Re]=React.useState([]),[v,N]=React.useState([]),[B,j]=React.useState([]),[U,xe]=React.useState(!0),[Z,Le]=React.useState(2),[J,De]=React.useState(!0),[Q,Ae]=React.useState(1),[f,X]=React.useState(),[Y,$]=React.useState(),[ee,te]=React.useState(),[g,oe]=React.useState(),[ne,Be]=React.useState(""),[F,_e]=React.useState(lbAnnotation.EToolName.Rect),q=React.useRef(new lbAnnotation.ActionsHistory).current,[p,T]=React.useState([]),[ie,Ve]=React.useState(""),[z,Ne]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,se]=React.useState(void 0),[W,He]=React.useState([]),[G,Me]=React.useState([]),[re,ke]=React.useState(!1),h=index(),[le,Ee]=React.useState({}),Oe=ctx.useDispatch(),je=o=>{const{imgNode:n,path:t}=o;t&&n&&Ee(a=>__spreadProps(__spreadValues({},a),{[t]:{width:n.width,height:n.height}}))},ae=React.useMemo(()=>v.length===1?v[0]:"",[v]),de=useWindowKeydownListener.default(),H=React.useCallback((o,n,t="extId")=>{const a=t||"id",l=new Set(n);return u(c=>{let S=!1;const P=c.filter(k=>{const K=k[a],E=l.has(K)?k.imageName!==o:!0;return E||(S=!0),E});return S?P:c}),!0},[]),ce=React.useCallback(o=>{const n=i.map(t=>t.id);return H(o,n,"extId")},[i,H]),ue=React.useCallback(o=>{if(!o)return!1;const n=i.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:a,attribute:l,trackID:c}=t,S=t.rects.find(P=>P.imageName===o);if(S){const P=___default.default.pick(S,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},P),{id:lbAnnotation.uuid(),attribute:l,order:c,extId:a,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(u(t=>{const a=new Set(t.filter(c=>o===c.imageName).map(c=>c.extId)),l=n.filter(c=>a.has(c.extId)===!1);return l.length?[...t,...l]:t}),!0):!1},[i]),ge=React.useMemo(()=>i.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var a;return(a=t.rects)==null||a.forEach(l=>{const{imageName:c}=l;if(!c){console.warn("Missing image name"),console.trace(l,t);return}map.addMapIndirectWeakSetItem(n,c,t.id,t)}),n},new Map),[i]),fe=React.useCallback(o=>{u(n=>o(n,pickRectObject))},[pickRectObject]),pe=React.useMemo(()=>I.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,I),o)},new Map),[I]),{fn:Fe}=useTimeoutFunc.default(o=>{N(n=>{const t=o,a=new Set(t);let l=!1;const c=n.filter(S=>{const P=a.has(S);return P||(l=!0),P});return l?c:n})},200),he=React.useCallback(o=>{const n=o.map(t=>t.id);d(o),Fe(n)},[]),M=React.useMemo(()=>{const o=i.find(e=>e.id===ae),n=e=>{const s=i.concat(e);return he(s),s},t=e=>{const s=x.concat(e);return D(s),s},a=e=>{xe(e!==!1)},l=e=>{e===void 0&&N([]),typeof e=="string"&&N([e]),Array.isArray(e)&&N(Array.from(new Set(e)))},c=e=>{v.includes(e)?l(v.filter(s=>s!==e)):l([...v,e])},S=e=>{const s=pickRectObject(e);u(m=>[...m,s])},P=(e,s=!1)=>{const m=pickRectObject(e);u(C=>C.map(w=>w.id===e.id?s?__spreadValues(__spreadValues({},w),m):m:w))},k=e=>{u(s=>s.filter(m=>!e.find(C=>C.id===m.id)))},K=e=>{B.includes(e)?j([]):j([e])},E=()=>{if(F===lbAnnotation.EToolName.Rect){const e=i.map(s=>s.id);l(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},Te=e=>{l(i.filter(s=>s.attribute===e).map(s=>s.id))},me=i.filter(e=>!p.includes(e.attribute)),ve=x.filter(e=>!p.includes(e.attribute)),Pe=R.filter(e=>e.attribute&&!p.includes(e.attribute)),ze=e=>{if(p.includes(e))T(p.filter(s=>s!==e));else{const s=p.concat(e);T(s)}},We=(e=me,s=A,m=ve,C=Pe,w=W)=>{var V;g==null||g.clearAllBox(),g==null||g.clearAllSphere(),f==null||f.updatePolygonList(e,s),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),Ie(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},Ge=()=>{X(void 0),$(void 0),te(void 0),oe(void 0)},Ie=(e,s,m)=>__async(void 0,null,function*(){var C,w,V;if(!g)return;const Se=g.pointCloudObject;if(!Se)return;let Ce=[],we=[];try{if(s&&q.record.length){const{record:y,recordIndex:b}=q;let ye=b;b>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&s.length===((C=y[b])==null?void 0:C.pointCloudBoxList.length))&&(ye=b-1);let Ke=(w=y[ye])==null?void 0:w.pointCloudBoxList;const be=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,s,Ke);Ce=be.modifiedBoxIds,we=be.resetAreas}}catch(y){console.error("call calcResetAreasAndBoxIds error",y)}try{const y=yield g.getHighlightIndexByMappingImgList({mappingImgList:m!=null?m:G,points:Se.geometry.attributes.position.array}),b=yield g==null?void 0:g.highlightOriginPointCloud(s,y,{modifiedBoxIds:Ce,resetAreas:we});return b&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(b)),b}catch(y){console.error("call highlightOriginPointCloud error",y)}});return{selectedID:ae,pointCloudBoxList:i,pointCloudSphereList:x,displayPointCloudList:me,displaySphereList:ve,displayLineList:Pe,selectedIDs:v,setPointCloudResult:he,setSelectedIDs:l,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:D,valid:U,selectedPointCloudBox:o,setPointCloudValid:a,addSelectedID:c,addHighlightID:K,selectedAllBoxes:E,topViewInstance:f,setTopViewInstance:X,sideViewInstance:Y,setSideViewInstance:$,backViewInstance:ee,setBackViewInstance:te,mainViewInstance:g,setMainViewInstance:oe,polygonList:A,setPolygonList:O,rectList:I,setRectList:u,addRectIn2DView:S,removeRectIn2DView:k,updateRectIn2DView:P,lineList:R,setLineList:Re,zoom:Q,setZoom:Ae,history:q,toggleAttributesVisible:ze,hideAttributes:p,setHideAttributes:T,reRender:We,attrPanelLayout:ie,setAttrPanelLayout:Ve,syncAllViewPointCloudColor:Ie,defaultAttribute:ne,setDefaultAttribute:Be,pointCloudPattern:F,setPointCloudPattern:_e,selectSpecAttr:Te,globalPattern:z,setGlobalPattern:e=>{z!==e&&(Oe(actionCreators.ChangeSave),Ne(e),e===lbUtils.EPointCloudPattern.Detection&&se(void 0))},ptSegmentInstance:L,setPtSegmentInstance:se,segmentation:W,setSegmentation:He,clearAllDetectionInstance:Ge,highlight2DDataList:G,setHighlight2DDataList:Me,highlight2DLoading:re,setHighlight2DLoading:ke,cuboidBoxIn2DView:J,setCuboidBoxIn2DView:De,imageSizes:le,cacheImageNodeSize:je,highlightIDs:B,setHighlightIDs:j,removeRectByPointCloudBoxId:ce,removeRectBySpecifyId:H,addRectFromPointCloudBoxByImageName:ue,rectRotateSensitivity:Z,setRectRotateSensitivity:Le,imageNamePointCloudBoxMap:ge,linkageImageNameRectMap:pe,updateRectListByReducer:fe,windowKeydownListenerHook:de}},[U,v,i,x,A,R,I,f,Y,ee,g,Q,p,ie,ne,F,z,L,W,G,re,J,le,B,ce,H,ue,Z,ge,pe,fe,de]);React.useEffect(()=>{var o,n,t;(o=h==null?void 0:h.setPointCloudBoxList)==null||o.call(h,i),(n=h==null?void 0:h.setHighlightIDs)==null||n.call(h,B),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,v)},[i,v,B]),React.useEffect(()=>{var o;(o=h==null?void 0:h.setPtCtx)==null||o.call(h,M)},[M]);const qe=()=>{const o=i.filter(l=>p.includes(l.attribute)),{setSelectedIDs:n,reRender:t}=M,a=o.map(l=>l.id);a.length>0&&n(v.filter(l=>!a.includes(l))),t()};return React.useEffect(()=>{var o,n,t,a;qe(),(n=(o=f==null?void 0:f.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,p),(a=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||a.call(t,p)},[p]),React__default.default.createElement(PointCloudContext.Provider,{value:M},r)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudPattern as
|
|
1
|
+
import{EPointCloudPattern as Y}from"@labelbee/lb-utils";import Ne,{useState as r,useRef as dt,useMemo as F,useCallback as N,useEffect as $}from"react";import{EPointCloudBoxRenderTrigger as E,calcResetAreasAndBoxIds as ct}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as He,EToolName as ee,uuid as ut}from"@labelbee/lb-annotation";import{useDispatch as gt}from"../../store/ctx.js";import{ChangeSave as pt}from"../../store/annotation/actionCreators.js";import ft from"../../store/annotatedBox/index.js";import Oe from"lodash";import{addMapIndirectWeakSetItem as Me}from"./utils/map.js";import mt from"./hooks/useTimeoutFunc.js";import ht,{getEmptyUseWindowKeydownListener as It}from"./hooks/useWindowKeydownListener.js";var vt=Object.defineProperty,Pt=Object.defineProperties,wt=Object.getOwnPropertyDescriptors,je=Object.getOwnPropertySymbols,yt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,ke=(d,i,c)=>i in d?vt(d,i,{enumerable:!0,configurable:!0,writable:!0,value:c}):d[i]=c,z=(d,i)=>{for(var c in i||(i={}))yt.call(i,c)&&ke(d,c,i[c]);if(je)for(var c of je(i))Ct.call(i,c)&&ke(d,c,i[c]);return d},Fe=(d,i)=>Pt(d,wt(i)),Rt=(d,i,c)=>new Promise((x,A)=>{var B=g=>{try{w(c.next(g))}catch(L){A(L)}},K=g=>{try{w(c.throw(g))}catch(L){A(L)}},w=g=>g.done?x(g.value):Promise.resolve(g.value).then(B,K);w((c=c.apply(d,i)).next())});const G=d=>Oe.pick(d,["id","attribute","width","height","x","y","imageName"]),Ee=Ne.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 He,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:ee.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:Y.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:d=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:d=>!1,removeRectBySpecifyId:(d,i,c)=>!1,removeRectByPointCloudBoxId:d=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:It()}),St=({children:d})=>{const[i,c]=r([]),[x,A]=r([]),[B,K]=r([]),[w,g]=r([]),[L,ze]=r([]),[v,H]=r([]),[_,T]=r([]),[te,Ge]=r(!0),[oe,Ke]=r(2),[ne,Te]=r(!0),[ie,We]=r(1),[f,se]=r(),[re,le]=r(),[ae,de]=r(),[p,ce]=r(),[ue,Ze]=r(""),[W,Ue]=r(ee.Rect),Z=dt(new He).current,[m,U]=r([]),[ge,qe]=r(""),[q,Je]=r(Y.Detection),[D,pe]=r(void 0),[J,Qe]=r([]),[Q,Xe]=r([]),[fe,Ye]=r(!1),h=ft(),[me,$e]=r({}),et=gt(),tt=o=>{const{imgNode:n,path:t}=o;t&&n&&$e(a=>Fe(z({},a),{[t]:{width:n.width,height:n.height}}))},he=F(()=>v.length===1?v[0]:"",[v]),Ie=ht(),O=N((o,n,t="extId")=>{const a=t||"id",l=new Set(n);return g(u=>{let y=!1;const P=u.filter(j=>{const X=j[a],k=l.has(X)?j.imageName!==o:!0;return k||(y=!0),k});return y?P:u}),!0},[]),ve=N(o=>{const n=i.map(t=>t.id);return O(o,n,"extId")},[i,O]),Pe=N(o=>{if(!o)return!1;const n=i.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:a,attribute:l,trackID:u}=t,y=t.rects.find(P=>P.imageName===o);if(y){const P=Oe.pick(y,["width","height","x","y","imageName"]);return Fe(z({},P),{id:ut(),attribute:l,order:u,extId:a,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(g(t=>{const a=new Set(t.filter(u=>o===u.imageName).map(u=>u.extId)),l=n.filter(u=>a.has(u.extId)===!1);return l.length?[...t,...l]:t}),!0):!1},[i]),we=F(()=>i.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var a;return(a=t.rects)==null||a.forEach(l=>{const{imageName:u}=l;if(!u){console.warn("Missing image name"),console.trace(l,t);return}Me(n,u,t.id,t)}),n},new Map),[i]),ye=N(o=>{g(n=>o(n,G))},[G]),Ce=F(()=>w.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(Me(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,w),o)},new Map),[w]),{fn:ot}=mt(o=>{H(n=>{const t=o,a=new Set(t);let l=!1;const u=n.filter(y=>{const P=a.has(y);return P||(l=!0),P});return l?u:n})},200),Re=N(o=>{const n=o.map(t=>t.id);c(o),ot(n)},[]),M=F(()=>{const o=i.find(e=>e.id===he),n=e=>{const s=i.concat(e);return Re(s),s},t=e=>{const s=x.concat(e);return A(s),s},a=e=>{Ge(e!==!1)},l=e=>{e===void 0&&H([]),typeof e=="string"&&H([e]),Array.isArray(e)&&H(Array.from(new Set(e)))},u=e=>{v.includes(e)?l(v.filter(s=>s!==e)):l([...v,e])},y=e=>{const s=G(e);g(I=>[...I,s])},P=(e,s=!1)=>{const I=G(e);g(C=>C.map(R=>R.id===e.id?s?z(z({},R),I):I:R))},j=e=>{g(s=>s.filter(I=>!e.find(C=>C.id===I.id)))},X=e=>{_.includes(e)?T([]):T([e])},k=()=>{if(W===ee.Rect){const e=i.map(s=>s.id);l(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},it=e=>{l(i.filter(s=>s.attribute===e).map(s=>s.id))},Se=i.filter(e=>!m.includes(e.attribute)),be=x.filter(e=>!m.includes(e.attribute)),Le=L.filter(e=>e.attribute&&!m.includes(e.attribute)),st=e=>{if(m.includes(e))U(m.filter(s=>s!==e));else{const s=m.concat(e);U(s)}},rt=(e=Se,s=B,I=be,C=Le,R=J)=>{var V;p==null||p.clearAllBox(),p==null||p.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(I),f==null||f.updateLineList(C),p==null||p.generateBoxes(e),p==null||p.generateSpheres(I),(V=D==null?void 0:D.store)==null||V.updateCurrentSegment(R),xe(E.Default,e)},lt=()=>{se(void 0),le(void 0),de(void 0),ce(void 0)},xe=(e,s,I)=>Rt(void 0,null,function*(){var C,R,V;if(!p)return;const De=p.pointCloudObject;if(!De)return;let Ae=[],Be=[];try{if(s&&Z.record.length){const{record:S,recordIndex:b}=Z;let _e=b;b>0&&(e===E.SingleToggleValid||e===E.SingleRotate||e===E.Single&&s.length===((C=S[b])==null?void 0:C.pointCloudBoxList.length))&&(_e=b-1);let at=(R=S[_e])==null?void 0:R.pointCloudBoxList;const Ve=ct(e,s,at);Ae=Ve.modifiedBoxIds,Be=Ve.resetAreas}}catch(S){console.error("call calcResetAreasAndBoxIds error",S)}try{const S=yield p.getHighlightIndexByMappingImgList({mappingImgList:I!=null?I:Q,points:De.geometry.attributes.position.array}),b=yield p==null?void 0:p.highlightOriginPointCloud(s,S,{modifiedBoxIds:Ae,resetAreas:Be});return b&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(b)),b}catch(S){console.error("call highlightOriginPointCloud error",S)}});return{selectedID:he,pointCloudBoxList:i,pointCloudSphereList:x,displayPointCloudList:Se,displaySphereList:be,displayLineList:Le,selectedIDs:v,setPointCloudResult:Re,setSelectedIDs:l,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:A,valid:te,selectedPointCloudBox:o,setPointCloudValid:a,addSelectedID:u,addHighlightID:X,selectedAllBoxes:k,topViewInstance:f,setTopViewInstance:se,sideViewInstance:re,setSideViewInstance:le,backViewInstance:ae,setBackViewInstance:de,mainViewInstance:p,setMainViewInstance:ce,polygonList:B,setPolygonList:K,rectList:w,setRectList:g,addRectIn2DView:y,removeRectIn2DView:j,updateRectIn2DView:P,lineList:L,setLineList:ze,zoom:ie,setZoom:We,history:Z,toggleAttributesVisible:st,hideAttributes:m,setHideAttributes:U,reRender:rt,attrPanelLayout:ge,setAttrPanelLayout:qe,syncAllViewPointCloudColor:xe,defaultAttribute:ue,setDefaultAttribute:Ze,pointCloudPattern:W,setPointCloudPattern:Ue,selectSpecAttr:it,globalPattern:q,setGlobalPattern:e=>{q!==e&&(et(pt),Je(e),e===Y.Detection&&pe(void 0))},ptSegmentInstance:D,setPtSegmentInstance:pe,segmentation:J,setSegmentation:Qe,clearAllDetectionInstance:lt,highlight2DDataList:Q,setHighlight2DDataList:Xe,highlight2DLoading:fe,setHighlight2DLoading:Ye,cuboidBoxIn2DView:ne,setCuboidBoxIn2DView:Te,imageSizes:me,cacheImageNodeSize:tt,highlightIDs:_,setHighlightIDs:T,removeRectByPointCloudBoxId:ve,removeRectBySpecifyId:O,addRectFromPointCloudBoxByImageName:Pe,rectRotateSensitivity:oe,setRectRotateSensitivity:Ke,imageNamePointCloudBoxMap:we,linkageImageNameRectMap:Ce,updateRectListByReducer:ye,windowKeydownListenerHook:Ie}},[te,v,i,x,B,L,w,f,re,ae,p,ie,m,ge,ue,W,q,D,J,Q,fe,ne,me,_,ve,O,Pe,oe,we,Ce,ye,Ie]);$(()=>{var o,n,t;(o=h==null?void 0:h.setPointCloudBoxList)==null||o.call(h,i),(n=h==null?void 0:h.setHighlightIDs)==null||n.call(h,_),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,v)},[i,v,_]),$(()=>{var o;(o=h==null?void 0:h.setPtCtx)==null||o.call(h,M)},[M]);const nt=()=>{const o=i.filter(l=>m.includes(l.attribute)),{setSelectedIDs:n,reRender:t}=M,a=o.map(l=>l.id);a.length>0&&n(v.filter(l=>!a.includes(l))),t()};return $(()=>{var o,n,t,a;nt(),(n=(o=f==null?void 0:f.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]),Ne.createElement(Ee.Provider,{value:M},d)};export{Ee as PointCloudContext,St as PointCloudProvider};
|